bug(spawn): workspace + OpenCode fails chat start (ACP additionalDirectories unsupported)
Summary
ao spawn on a workspace project can create the git worktrees, then fail when starting the worker chat:
chat controller: ACP agent does not support additional workspace directories (CHAT_CONTROLLER_FAILED)
Seen on AgentLab (agentlab-in, kind workspace, default worker harness OpenCode) while spawning a new worker (agentlab-in-11) on 2026-09-19. Retry failed the same way. Existing workers on that project (agentlab-in-9, agentlab-in-10) already had a chat controller and kept running.
Why it happens
Workspace spawn does not only set cwd to the session root. It passes every child worktree path (except the root) as ACP additionalDirectories.
workspaceProjectDirectoriesinbackend/internal/session_manager/chat_spawn.go(collectsproject.Worktreeswhose path is not the session root)ChatStart.AdditionalDirectorieson the chat controller- ACP driver
backend/internal/adapters/chatdriver/acp/driver.gocallsnormalizeAdditionalDirectories backend/internal/adapters/chatdriver/acp/session_setup.go: ifdirectoriesis non-empty andinit.AgentCapabilities.SessionCapabilities.AdditionalDirectories == nil, return that error
OpenCode’s ACP initialize does not advertise sessionCapabilities.additionalDirectories. AO fails closed. The session is then a failed spawn even though worktree add may have already run.
This is not a bad ao spawn invocation. It is workspace project + ACP harness without that capability + at least one child worktree.
Repro
- Workspace project with multiple registered children (e.g. six git children).
- Default worker agent: OpenCode (ACP).
ao spawn --project <id> --name test --prompt "ping"- Observe
CHAT_CONTROLLER_FAILED/ACP agent does not support additional workspace directories.
Single-repo projects should not hit this path (workspaceProjectDirectories returns nil when project is nil / not workspace).
Expected
Either:
- Skip
additionalDirectorieswhen the agent does not advertise the capability, and still start chat with cwd = workspace root (children remain on disk under that root), or - Fail earlier with a harness/capability error before creating worktrees, or
- Document that workspace workers require a harness that advertises additional directories (e.g. Claude Code) and refuse OpenCode at spawn validation.
Failing closed after worktree create leaves a half-made session.
Non-goals
- Auto-registering unregistered clones on disk as workspace children (that is #5644).
- Changing the “all children in one worktree” workspace model.
Unregistered extra checkouts (we had cloned alab-cli into the workspace folder without registering it) are not in workspaceRepos and should not be the dirs AO sends. The dirs that trigger this are the registered child worktrees.
Related
- #5644 workspace CLI lifecycle (list/add/rm/sync). Different bug; same area.
- #5643 add-repo CLI only.
Environment
- AO CLI + daemon, 2026-09-19
- Project kind: workspace (
agentlab-in) - Worker harness: OpenCode
- Error code:
CHAT_CONTROLLER_FAILED
Re-verified today (2026-09-25) on a different machine/project. Same root cause, two additional data points that extend the scope of the fix.
Repro (2026-09-25, workspace project censored, kind=workspace, 2 registered children: app + community-store, orchestrator harness opencode)
ao spawn --project censored --kind orchestrator --harness opencode --mode chat-> fails:spawn censored-1: chat controller: ACP agent does not support additional workspace directories (CHAT_CONTROLLER_FAILED)[daemon request idbgAImmJG3P-084525]- Same spawn with
--mode tui-> works; session comes up. - New: in the desktop UI, switching that running TUI session to chat fails with the same error. So the chat-controller mode-switch/attach path hits the same
additionalDirectoriesfail-closed check, not just spawn-timeChatStart. Fix must cover both entry points. - Control: a single-repo project runs opencode chat-mode sessions fine (verified in parallel) -> confirms this is specific to the multi-directory workspace shape, not a general opencode/ACP breakage.
Side note (separate, likely environmental): same workspace spawn with --harness claude-code --mode chat fails earlier and differently: chat driver incompatible: ACP initialize: peer disconnected before response (CHAT_DRIVER_INCOMPATIBLE) — ao doctor flags the claude binary as not on the daemon PATH on this machine. Not part of this fix.
Fix direction (endorsed, refined)
Degrade gracefully rather than fail closed, at both entry points:
- When
init.AgentCapabilities.SessionCapabilities.AdditionalDirectoriesis absent, start/attach chat withcwdonly (workspace root or primary repo) and dropadditionalDirectories. Children remain on disk under the root; agents that never advertise the capability still work. - Alternatively/additionally: capability-gate up front and surface a clear harness-capability error before side effects (worktree creation), instead of a half-made session.
- The desktop UI mode-switch (TUI -> chat) must show a human-readable error for whichever failure mode remains; today it surfaces the opaque
CHAT_CONTROLLER_FAILEDtext.
Where to look
backend/internal/session_manager/chat_spawn.go(workspaceProjectDirectories) — spawn path- chat controller mode-switch/attach path (same helper appears to be consulted when attaching a chat controller to a running TUI session) — confirm in source
backend/internal/adapters/chatdriver/acp/session_setup.go+driver.go(normalizeAdditionalDirectories) — the fail-closed check
Daemon records for the failed request: request id bgAImmJG3P-084525 (2026-09-25).
I'm picking this up in a new follow-up, with #5684 and #5875 as prior context. I’m checking a scope-preserving approach: omit unsupported additional directories only when they are already contained within the session cwd, and continue rejecting genuinely external roots. No blanket cwd-only downgrade. I’ll verify fresh start and restore paths before posting results.