Worker preamble runs bare `orca`, so a nested login shell on a host with its own Orca CLI can send `worker_done` to the wrong runtime
Summary
When an agent runs in an SSH worktree on a host that also runs its own Orca.app (with the CLI registered at /usr/local/bin/orca), the agent's child process can resolve orca to the host's local CLI instead of the relay-deployed shim. That CLI talks to the local runtime, not the coordinator's.
The worker's worker_done and heartbeat are then accepted by the wrong runtime, assigned message ids, and persisted into that machine's orchestration.db. The coordinator on the other machine never sees them. Its check --wait calls keep timing out and the task stays dispatched indefinitely, with no error surfaced on the coordinator side.
Preconditions (all required)
This does not trigger merely by having Orca installed on both machines:
- The remote host has Orca.app installed and its CLI registered (
/usr/local/bin/orca→Orca.app/Contents/Resources/bin/orca), and that local Orca runtime is running (otherwise the misrouted call would fail loudly instead of being persisted). - The agent's child process resolves
orcato that local CLI — i.e./usr/local/binprecedes the relay bin dir in that process's PATH.
Observed with Codex 0.144.x as the worker; any agent whose child-process PATH orders /usr/local/bin ahead of the relay bin dir is affected.
Root cause
SshPtyProvider only prepends the relay CLI bin dir when it is entirely absent from PATH. If it is already present anywhere — including at the very back — the PATH is left untouched:
// src/main/providers/ssh-pty-provider.ts:188-192
merged[pathKey] = pathValue.split(pathDelimiter).includes(this.remoteCliBridgeEnv.binDir)
? pathValue // ← already present → left as-is, NOT moved to front
: pathValue
? `${this.remoteCliBridgeEnv.binDir}${pathDelimiter}${pathValue}`
: this.remoteCliBridgeEnv.binDir
Same pattern in the shell wrapper path (src/main/providers/pty-shell-launch.ts:114,130,152).
So if the user's shell rc (or the agent's own PATH handling) puts the relay bin dir behind /usr/local/bin, Orca will not correct it. The interactive shell may happen to resolve correctly while the agent's child process does not — which is exactly what we observed:
# coordinator agent terminal:
$ which -a orca
/Users/happy/.orca-relay/bin/orca ← relay shim first ✅
/usr/local/bin/orca
# Codex worker child process, same host, same worktree:
$ which -a orca
/usr/local/bin/orca ← local Orca CLI first 🔴
/Users/happy/.orca-relay/bin/orca
Secondary factor: the two binaries behave very differently, and only one of them knows about the relay.
| Binary | What it is | Runtime it reaches |
|---|---|---|
~/.orca-relay/bin/orca |
relay shim (sh script) — reads ORCA_RELAY_SOCKET_PATH, execs relay.js --sock-path … --orca-cli (src/main/ssh/ssh-relay-session.ts:1293-1306) |
✅ the coordinator's runtime |
/usr/local/bin/orca |
→ Orca.app/Contents/Resources/bin/orca (bash launcher) → the ordinary CLI (resources/darwin/bin/orca:21-33). Its RuntimeClient never reads ORCA_RELAY_SOCKET_PATH |
🔴 the host's local runtime |
Verified: forcing the full relay env into the local CLI still yields the local runtime id.
Why it is silent
On the receiving (wrong) runtime, orchestration.send inserts the message first, then reconciles, then returns the message id (src/main/runtime/rpc/methods/orchestration.ts:216-249). Reconciliation finds no such task:
// src/main/runtime/orchestration/lifecycle-reconciliation.ts:185-188
const task = db.getTask(taskId)
if (!task) {
onLog(`Warning: worker_done for unknown task ${taskId}`)
return { action: 'ignored' }
}
So the caller gets a success + message id, the row is persisted, and the only trace is a warning in the wrong machine's log — where nobody is looking. (heartbeat for an unknown/inactive dispatch is likewise marked read+delivered, then suppressed: lifecycle-reconciliation.ts:131-137.)
Evidence — the worker's lifecycle messages sitting in the wrong host's DB, whose tasks table is empty:
$ sqlite3 ~/Library/Application\ Support/Orca/orchestration.db \
"SELECT id, type, from_handle, to_handle, substr(subject,1,40) FROM messages ORDER BY rowid DESC LIMIT 5;"
msg_75a3511b7144|worker_done|term_e0df6938…|term_b7ead2bc…|task completed: found source-only flags
msg_c8b52cba5296|heartbeat |term_e0df6938…|term_b7ead2bc…|alive
Impact
- Orchestration on an affected SSH worktree stalls after the first dispatch: the task stays
dispatched, everycheck --waitreturns empty until its timeout (default 2 minutes;orca-runtime.ts:21530-21566). - Not literally silent, but effectively so: the coordinator logs stale-heartbeat warnings after ~10 minutes (
coordinator.ts:90-95,234-247) but never fails the task, and the decisive evidence lives in another machine's database and log. - The worker behaves perfectly and reports success, so the failure looks like "the agent never finished."
Not the cause (ruled out with controlled experiments)
The orchestration layer itself works correctly over the relay. All of these were sent through the relay shim and delivered, auto-completing the task:
worker_donefrom an SSH-remote agent pane (relay preserves pane identity)- with
--fromexplicitly passed - with an empty
--files-modified '' - with a 400+ char body containing literal
--task-id/--dispatch-idtext - cross-pane: a separate shell worker → coordinator
The worker's ORCA_PANE_KEY matched dispatch_contexts.assignee_pane_key exactly, and its handle matched assignee_handle. Every lifecycle-authority precondition was satisfied — the message just went to a different machine.
Suggested fix
- Primary — fix the PATH gap. When the relay CLI bin dir is already present in PATH but not first, move it to the front rather than leaving PATH untouched (
ssh-pty-provider.ts:188-192,pty-shell-launch.ts:114,130,152). Right now Orca only helps when the dir is entirely absent, which is the easier case. - Defense in depth — make the ordinary CLI relay-aware. If
ORCA_RELAY_SOCKET_PATHpoints at a live socket, the request belongs to the relay's runtime; forward it instead of falling back to the localorca-runtime.json. - Fail loudly. A
worker_donecarrying ataskId/dispatchIdunknown to the receiving runtime should return an error to the caller, not a success + message id. That alone turns a multi-minute silent stall into an immediate, obvious failure at the worker.
Workarounds (in order of preference)
# 1. Non-destructive: force the relay shim to win inside the agent's shell
export PATH="$ORCA_REMOTE_CLI_BIN_DIR:$PATH"
# or invoke it explicitly:
"$ORCA_REMOTE_CLI_BIN_DIR/orca" orchestration send …
# 2. Destructive fallback: remove the host's own Orca CLI symlink
# (only if that host is used purely as a worker box — it disables the local Orca CLI)
sudo rm /usr/local/bin/orca
Update after the SSH relay was retired (#27214, #27215): SSH terminals now run on the host's managed remote server (orcad). Its PTY spawn already moves the CLI launcher directory to the front of PATH, even when it is already listed (prependOrcaCliDirToChildPath in src/main/cli/orca-cli-child-path.ts). The shell wrappers restore it after rc files run. One part still applies: the worker lifecycle preamble runs bare orca (resolveTerminalOrchestrationCliCommand), so a nested bash -lc/zsh -lc that reorders PATH can still pick up a host-installed Orca. #9835 (thanks @Jinwoo-H) proposed pinning these commands to the exact launcher, and that idea still fits.