Skip to content

feat: switch providers for loaded Codex sessions - #404

Merged
EugeneTheDev merged 4 commits into
agentclientprotocol:mainfrom
serjic:fix/live-provider-switching
Aug 17, 2026
Merged

feat: switch providers for loaded Codex sessions#404
EugeneTheDev merged 4 commits into
agentclientprotocol:mainfrom
serjic:fix/live-provider-switching

Conversation

@serjic

@serjic serjic commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Problem

Codex fixes modelProvider in the app-server thread runtime. Updating the adapter's Providers API state therefore affected newly created threads, while already loaded ACP sessions continued sending turns through the old backend.

The app-server does not currently expose an API that replaces a loaded thread's provider/config while preserving its ID.

Solution

  • Serialize provider updates and wait for active prompts to complete.
  • Restart the adapter-owned Codex app-server between turns.
  • Reinitialize the replacement client and resume every loaded thread with its existing session ID, cwd, additional directories, and MCP servers.
  • Preserve startup/native provider state and restore it on providers/disable.
  • Block session operations only while the coordinated restart is in progress.
  • Attempt every thread resume even if one fails, report aggregate failures, and allow a later provider update to recover.
  • Add PID and provider/restart routing details to opt-in app-server logs without exposing provider headers.

Tests

Added coverage for:

  • native behavior when Providers API is unused;
  • gateway config passed to thread/start;
  • multiple loaded sessions across native → proxy A → proxy B → native;
  • all-session resume after app-server restart;
  • partial resume failure and successful subsequent recovery;
  • startup proxy restoration and legacy gateway auth interoperability.

Verification:

  • provider suite: 14 passed
  • npm run typecheck
  • npm run build
  • git diff --check

The repository's full suite still has the pre-existing approval/elicitation/session-close fixture mismatches; the provider suite and static/build checks are green.

@EugeneTheDev
EugeneTheDev self-requested a review August 17, 2026 09:30
Comment thread src/CodexAcpServer.ts Outdated
Comment thread src/index.ts Outdated
@EugeneTheDev EugeneTheDev changed the title Switch providers for loaded Codex sessions feat: switch providers for loaded Codex sessions Aug 17, 2026
serjic and others added 3 commits August 17, 2026 15:02
@serjic
serjic force-pushed the fix/live-provider-switching branch from 4e3cb0f to 9fed911 Compare August 17, 2026 13:10
Co-authored-by: Junie <junie@jetbrains.com>
@serjic
serjic requested a review from EugeneTheDev August 17, 2026 13:31
@EugeneTheDev
EugeneTheDev merged commit 47b57da into agentclientprotocol:main Aug 17, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants