agent-orchestrator icon indicating copy to clipboard operation
agent-orchestrator copied to clipboard

First-run Codex selection leaves global config on claude-code and breaks dashboard session routing

Open whoisasx opened this issue 6 months ago • 1 comments

Bug

First-time ao start with Codex selected can create a split-brain config state: the project-local config records agent: codex, but the global config keeps defaults.agent: claude-code. The CLI then spawns the orchestrator under one project identity while the dashboard resolves the project through the global portfolio identity, so the session detail page shows Session not found even though tmux and the worktree exist.

Source: local live report / debugging session from Adil Shaikh Analyzed against: 45de80ce3f8bae4f8a2f8ff00bf81b09af874025 AO version observed: 0.8.0 Environment observed: macOS Darwin 25.5.0 arm64, zsh, Node v24.15.0 Confidence: High - traced through config generation, global project registration, dashboard resolution, session metadata, and worktree state.

Reproduction

  1. Start from a project without an existing local agent-orchestrator.yaml.
  2. Run ao start for the first time.
  3. When prompted for the agent, choose Codex.
  4. Continue through the release-channel/onboarding prompt.
  5. Observe that the project-local config is generated with Codex, but the global config may still retain Claude Code as the default agent.
  6. Open the dashboard session detail route for the orchestrator.

Observed route shape from the report:

http://localhost:3000/projects/ao/sessions/ao-orchestrator

Actual Behavior

The local config initially used a wrapped project config shape similar to:

port: 3000
defaults:
  runtime: tmux
  agent: codex
  workspace: worktree
  notifiers: []
projects:
  ao:
    name: ao
    sessionPrefix: ao
    path: /path/to/project

But the global config still had:

defaults:
  runtime: tmux
  agent: claude-code
  workspace: worktree
projects:
  ao_<hash>:
    path: /path/to/project
    sessionPrefix: ao

Resulting symptoms:

  • Dashboard session page shows Session not found.
  • Sidebar shows a generated session/project identity such as ao_0242ccdd19.
  • Project is marked degraded with config needs repair.
  • tmux session is alive, e.g. ao-orchestrator.
  • Worktree exists under the older project storage identity.
  • After clicking repair, local config is flattened, but existing session/worktree storage is not migrated, so a subsequent spawn can show an older-orchestrator-workspace warning.

Example older-workspace warning from the report:

AO found an older orchestrator workspace for "ao_0242ccdd19" but could not safely reuse it automatically. Your repository is safe. Review the existing workspace, then either reuse it manually or remove it and create a fresh orchestrator workspace.

Expected Behavior

After first-run onboarding selects Codex:

  • Local project config should be flat and behavior-only:
runtime: tmux
agent: codex
workspace: worktree
agentRules: ...
  • Global config should persist the selected first-run defaults:
defaults:
  runtime: tmux
  agent: codex
  workspace: worktree
  notifiers: []
  • CLI and dashboard should resolve the same effective project id.
  • The dashboard should find the orchestrator session created by ao start.
  • Repair should not be required immediately after first-run onboarding.

Root Cause

The first-run path mixed the old wrapped local config model with the newer global portfolio config model.

Likely code path:

  • packages/cli/src/commands/start.ts / autoCreateConfig() generated a wrapped local config with defaults.agent: codex and projects.ao.
  • The same flow registered the project globally through registerProjectInGlobalConfig(...), which can create a generated global project id such as ao_<hash>.
  • The selected first-run agent was not persisted into ~/.agent-orchestrator/config.yaml defaults, so global defaults could remain claude-code.
  • Dashboard and web APIs load through the global-backed config, while the CLI/session metadata from first-run was created under the local project identity.
  • SessionManager.list/get operates over config.projects, so metadata stored under the old project id is invisible when the effective project id is the generated global id.
  • Dashboard repair flattens local config, but does not migrate existing session metadata/worktree storage from the old local id to the generated global id.

Suspected Regression

High-confidence direct regression candidate:

  • PR #1819 / commit d95c9def1 - fix(cli): first-run startup creates global config with project registered (#1766) (#1819)

Related architectural changes that made the bug visible:

  • PR #1343 / commit f3ce113c4 - multi-project storage, global/local config resolution, degraded repair
  • PR #1466 / commit 36fed87b2 - generated project ids such as ao_<hash>
  • commit f674422a6 - canonical {sessionPrefix}-orchestrator ids
  • commit be061a398 - older-orchestrator-workspace warning behavior

Impact

  • Breaks first-run onboarding for users who choose Codex when global defaults are still Claude Code.
  • Makes the dashboard appear broken even though the orchestrator process and worktree exist.
  • Can leave users in a confusing repair loop: Session not found -> config needs repair -> older workspace warning.
  • High severity because this affects the install/start path and makes AO look unusable immediately after onboarding.

Fix Approach

The first-run path should:

  1. Write a flat local project config, not a wrapped projects: config.
  2. Register the project globally.
  3. Persist the selected first-run defaults globally, including agent, runtime, workspace, notifiers, and port.
  4. Reload/return the effective global-backed config so CLI and dashboard operate on the same project id.
  5. Add a regression test for first-run Codex selection proving local config is flat and global defaults resolve to codex.

A local fix has been validated with:

pnpm --filter @aoagents/ao-cli test -- __tests__/commands/start.test.ts
pnpm --filter @aoagents/ao-cli typecheck
pnpm build

Notes

The observed repaired state after the fix resolves to:

{
  "effectiveProjectIds": ["ao_0242ccdd19"],
  "effectiveProjectAgents": {
    "ao_0242ccdd19": "codex"
  },
  "effectiveSessionPrefixes": {
    "ao_0242ccdd19": "ao"
  }
}

whoisasx avatar May 20 '26 11:05 whoisasx

This issue was created before the AO rewrite and is no longer relevant to the current codebase, so we’re closing it as part of the repository cleanup.

AO is now available as an app on macOS and Windows, with iOS currently in beta and Android coming soon.

If the issue still exists in the latest version of AO, feel free to open a new issue with updated details, reproduction steps, logs, and screenshots where applicable.

Stay connected with AO:

GitHub: https://github.com/AgentWrapper/agent-orchestrator Discord: https://discord.gg/kGbBRRDPv X: https://x.com/aoagents LinkedIn: https://www.linkedin.com/company/agent-orchestrator Instagram: https://www.instagram.com/aoagents

illegalcall avatar Jul 25 '26 05:07 illegalcall