Skip to content

fix(core): switch OpenAI credential routes atomically - #45336

Open
major wants to merge 2 commits into
anomalyco:v2from
major:openai-route-switch
Open

fix(core): switch OpenAI credential routes atomically#45336
major wants to merge 2 commits into
anomalyco:v2from
major:openai-route-switch

Conversation

@major

@major major commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #45334

Type of change

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

What does this PR do?

Resolve the active OpenAI credential and transport together for each model request instead of relying on asynchronously refreshed provider state. ChatGPT OAuth requests always use the Codex endpoint and headers, while OpenAI API-key requests use the normal configured API endpoint without Codex headers.

Persist non-secret route provenance with assistant messages so OpenAI item IDs and encrypted reasoning from ChatGPT Codex are not replayed to the OpenAI API after an account switch. Visible reasoning and tool content remain available.

How did you verify your code works?

  • bun test test/plugin/provider-openai.test.ts test/session-runner-message.test.ts test/session-message-update.test.ts from packages/core: 34 passed.
  • bun typecheck from packages/core, packages/schema, packages/protocol, and packages/client: passed.
  • bun run build from packages/core: passed.
  • bun run generate from packages/client: passed.
  • Prettier check for all changed files and git diff --check: passed.
  • The full Core suite exceeded the local two-minute command limit in the unrelated filesystem watcher test. The focused regression tests above passed after rebasing onto current v2.

Screenshots / recordings

Not applicable.

Checklist

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

@github-actions

Copy link
Copy Markdown
Contributor

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.

major added 2 commits August 26, 2026 12:27
- Snapshot the active OpenAI credential with its transport\n- Route ChatGPT OAuth and OpenAI API keys to their respective endpoints

Signed-off-by: Major Hayden <major@mhtx.net>
- Persist non-secret route provenance with assistant messages\n- Omit incompatible Codex state from OpenAI API requests

Signed-off-by: Major Hayden <major@mhtx.net>
@major
major force-pushed the openai-route-switch branch from 8fe33da to 3bea171 Compare August 26, 2026 17:27
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.

1 participant