[codex] fix(cli): ao start --interactive honors agent selection#904
Draft
yyovil wants to merge 1 commit intoComposioHQ:mainfrom
Draft
[codex] fix(cli): ao start --interactive honors agent selection#904yyovil wants to merge 1 commit intoComposioHQ:mainfrom
yyovil wants to merge 1 commit intoComposioHQ:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #896 —
ao start --interactiveignores the user's agent selection and launches Claude Code even when OpenAI Codex is chosen.Problem
When a user runs
ao start --interactiveand selects OpenAI Codex (or any non-default agent), the config YAML is correctly updated (orchestrator.agent: codex), but the orchestrator session still boots Claude Code. Theao doctorcommand confirms the config is correct, yet the runtime ignores it.Root Cause
The bug is in
spawnOrchestrator()inpackages/core/src/session-manager.ts. The defaultorchestratorSessionStrategyis"reuse", which means if an existing tmux session from a previous run is still alive, it is returned as-is — without checking whether the configured agent has changed.The flow:
ao startwith Claude Code (default). A tmux session is created withagent: "claude-code"persisted in metadata.ao start --interactive, selects Codex. The YAML is updated, config reloaded —project.orchestrator.agentis now"codex".spawnOrchestrator()correctly resolves the agent as"codex"viaresolveAgentSelection()."reuse", returns the persisted session (running Claude Code) immediately — never launching Codex.Fix
Before reusing an existing alive session, compare the persisted agent name (
metadata["agent"]) against the resolved agent name (selection.agentName). If they differ, treat the session as non-reusable: destroy the old runtime and create a fresh session with the correct agent.This check is applied in both the primary reuse path and the concurrent-session reuse path.
Changed files:
packages/core/src/session-manager.ts— AddedagentChangedguard to the reuse logic inspawnOrchestrator()packages/core/src/__tests__/session-manager/spawn.test.ts— Added regression test: "destroys and replaces existing session when agent changed (reuse strategy)"Validation
agent: "mock-agent"but config selectsorchestrator.agent: "codex", the old session is destroyed (not reused) and a new session launches with Codexpnpm --filter @composio/ao-core typecheckpasses cleanly