Repository navigation
fix(codex): pick up a new login without restarting T3 #11147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
8d3035d
31f7b4a
91e1f5e
6aad9f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,7 @@ import { makeCodexAdapter } from "../Layers/CodexAdapter.ts"; | |
| import * as ResetCreditCoordinator from "../Layers/resetCreditCoordinator.ts"; | ||
| import { | ||
| checkCodexProviderStatus, | ||
| makeCodexAccountSwitchTracker, | ||
| makePendingCodexProvider, | ||
| probeCodexSkillsForCwd, | ||
| withCodexAppServerClient, | ||
|
|
@@ -188,6 +189,16 @@ export const CodexDriver: ProviderDriver<CodexSettings, CodexDriverEnv> = { | |
| ), | ||
| ); | ||
|
|
||
| // Live sessions keep the account they spawned with. When a probe shows a | ||
| // different login, stop them so the next send respawns app-server with | ||
| // the current credentials (the same path as Stop or the idle reaper). | ||
| const trackAccountSwitch = yield* makeCodexAccountSwitchTracker( | ||
| Effect.logInfo("Codex account changed; stopping live sessions.", { instanceId }).pipe( | ||
| // `adapter` is created below; suspend so the stop resolves it lazily. | ||
| Effect.andThen(Effect.suspend(() => adapter.stopAll())), | ||
| ), | ||
| ); | ||
|
|
||
| // Build a managed snapshot whose settings never change — mutations come | ||
| // in as instance rebuilds from the registry rather than in-place | ||
| // updates. Pre-provide `ChildProcessSpawner` so the check fits | ||
|
|
@@ -205,6 +216,16 @@ export const CodexDriver: ProviderDriver<CodexSettings, CodexDriverEnv> = { | |
| { concurrent: true }, | ||
| ), | ||
| ), | ||
| Effect.tap((probed) => | ||
|
Gigioxx marked this conversation as resolved.
Resolved
|
||
| trackAccountSwitch(probed.auth).pipe( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 High The first 🤖 Copy this AI Prompt to have your agent fix this: |
||
| Effect.catchCause((cause) => | ||
| Effect.logWarning("Failed to stop Codex sessions after account change.", { | ||
| instanceId, | ||
| cause, | ||
| }), | ||
| ), | ||
| ), | ||
| ), | ||
| Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner), | ||
| ); | ||
| const snapshotSettings = makeProviderSnapshotSettingsSource(effectiveConfig, serverSettings); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟠 High
Drivers/CodexDriver.ts:198adapter.stopAll()can leave an old-credential app-server running after an account switch, so subsequent turns reuse that stale session.CodexAdapter.stopAllsnapshotssessionswhilestartSessionadds the runtime only afterawait runtime.start(), allowing an in-flight start to be missed; synchronize session creation with stopping or makestopAllawait and stop in-flight starts.🤖 Copy this AI Prompt to have your agent fix this: