Skip to content

fix: sdk.responses fallback + codex baseURL correction#16048

Open
coleleavitt wants to merge 1 commit intoanomalyco:devfrom
coleleavitt:fix/sdk-responses-undefined-fallback
Open

fix: sdk.responses fallback + codex baseURL correction#16048
coleleavitt wants to merge 1 commit intoanomalyco:devfrom
coleleavitt:fix/sdk-responses-undefined-fallback

Conversation

@coleleavitt
Copy link
Copy Markdown
Contributor

@coleleavitt coleleavitt commented Mar 4, 2026

Issue for this PR

Closes #16049

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Fixes two related bugs when switching between AI models:

1. SDK responses fallback (provider.ts)
The openai, azure, and azure-cognitive-services loaders call sdk.responses(modelID) unconditionally. But @ai-sdk/openai-compatible doesn't have a .responses() method - only .languageModel(). When switching to a model using that SDK, it crashes with TypeError: sdk.responses is not a function.

Fix: Added checks before calling sdk.responses(). If undefined, fall back to sdk.languageModel(modelID). This matches what the github-copilot loader already does.

2. Codex baseURL (codex.ts)
The gpt-5.3-codex model had api.url set to https://chatgpt.com/backend-api/codex which is a ChatGPT internal endpoint, not the OpenAI API. This caused requests to route incorrectly when switching models.

Fix: Changed to https://api.openai.com/v1.

How did you verify your code works?

  • Switched between Claude and ChatGPT models - no crash
  • Switched from Codex back to Claude - works correctly
  • Ran LSP diagnostics on changed files - no errors

Screenshots / recordings

N/A - not a UI change

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions Bot added contributor needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Mar 4, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 4, 2026

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

- Add fallback checks for sdk.responses in openai, azure, azure-cognitive-services loaders
- Fix gpt-5.3-codex to use correct OpenAI API baseURL instead of ChatGPT backend endpoint
@coleleavitt coleleavitt force-pushed the fix/sdk-responses-undefined-fallback branch from 1761c93 to 3d96c60 Compare March 4, 2026 21:55
@coleleavitt coleleavitt changed the title fix(provider): add fallback for sdk.responses undefined fix: sdk.responses fallback + codex baseURL correction Mar 4, 2026
@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Mar 4, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 4, 2026

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@Jaxx7594
Copy link
Copy Markdown

This PR is critical for my usecase, thanks for making it! For the time being, I have manually built opencode with this PR, but it would be much appreciated if this can be merged. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeError: sdk.responses is not a function when switching models

2 participants