Skip to content

[codex] fix(cli): ao start --interactive honors agent selection#904

Draft
yyovil wants to merge 1 commit intoComposioHQ:mainfrom
yyovil:emdash/fix-ignored-agent-selection-claude-25k
Draft

[codex] fix(cli): ao start --interactive honors agent selection#904
yyovil wants to merge 1 commit intoComposioHQ:mainfrom
yyovil:emdash/fix-ignored-agent-selection-claude-25k

Conversation

@yyovil
Copy link
Copy Markdown
Contributor

@yyovil yyovil commented Apr 4, 2026

Summary

Fixes #896ao start --interactive ignores the user's agent selection and launches Claude Code even when OpenAI Codex is chosen.

Problem

When a user runs ao start --interactive and 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. The ao doctor command confirms the config is correct, yet the runtime ignores it.

Root Cause

The bug is in spawnOrchestrator() in packages/core/src/session-manager.ts. The default orchestratorSessionStrategy is "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:

  1. User previously ran ao start with Claude Code (default). A tmux session is created with agent: "claude-code" persisted in metadata.
  2. User runs ao start --interactive, selects Codex. The YAML is updated, config reloaded — project.orchestrator.agent is now "codex".
  3. spawnOrchestrator() correctly resolves the agent as "codex" via resolveAgentSelection().
  4. But then it finds the old tmux session alive, and with strategy "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 — Added agentChanged guard to the reuse logic in spawnOrchestrator()
  • packages/core/src/__tests__/session-manager/spawn.test.ts — Added regression test: "destroys and replaces existing session when agent changed (reuse strategy)"

Validation

  • All 73 existing spawn tests pass
  • New regression test verifies: when metadata has agent: "mock-agent" but config selects orchestrator.agent: "codex", the old session is destroyed (not reused) and a new session launches with Codex
  • pnpm --filter @composio/ao-core typecheck passes cleanly

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.

fix(cli): ao start --interactive launches Claude Code after selecting OpenAI Codex

1 participant