Skip to content

[Bug]: injected/sent prompts land in agent composer but are never submitted. Send reports success, worker sits idle. #14822

Open

Description

@itspokchop93

Operating system

macOS

Orca version

1.4.182

Details

Summary

orca orchestration worker-start / dispatch --inject and orca terminal send --text ... --enter frequently deliver the prompt into the spawned agent's composer without it ever being submitted. The CLI reports a successful send (bytes accepted), but the agent (Claude Code in our case) sits idle indefinitely with the full prompt visible in its input field. From the coordinator's side this is indistinguishable from a slow worker, so orchestrators wait, then respawn — and the respawned worker hits the same thing.

Environment

  • macOS (Apple Silicon, M4) — Darwin 25.5.0
  • Orca 1.4.182 (also observed on earlier 1.4.x builds over the past several days)
  • Workers: Claude Code agents launched via orca orchestration worker-start --task <id> --worktree current --agent claude --model opus

Reproduction

  1. orca orchestration run-create + task-create (spec ~1.5-2.5 KB)
  2. orca orchestration worker-start --task <id> --worktree current --agent claude --model opus --json → returns dispatch + terminal handle, dispatch_input: accepted
  3. Observe the worker terminal: the injected preamble+spec sits in the Claude composer, never submitted. No error anywhere.
  4. Manually pressing Enter in the terminal (or orca terminal send --terminal <handle> --enter) submits it and everything proceeds normally.

Frequency: intermittent but frequent — multiple times per day across different sessions/worktrees for the past several days.

What it is NOT

Impact

Silent orchestration deadlock: check --wait never receives worker_done, coordinators burn their timeout, and users conclude workers are dead. We now unconditionally send a follow-up bare Enter and verify via worker-read (source: "transcript" vs "terminal") after every dispatch, which works but shouldn't be necessary.

Related

#10662 (confirmed-send primitive) and PR #13763 (honest submit verdict) would both mitigate this — an honest verdict at send time is exactly what's missing.

Activity

  1. added theissue type on Aug 15, 2026
  2. added
    bug
    on Aug 15, 2026
  3. added
    os:macos
    on Aug 15, 2026
  4. Tauri-EPO commented on Aug 16, 2026

    @Tauri-EPO
    Contributor

    Same failure on Windows dogfooding of unattended Claude / cursor-agent workers (also #14505; the closed #14525 came back). Coordinator sees send / dispatch --inject success; the prompt sits in the composer; the worker never starts.

    Runtime already knows the Enter can be swallowed and currently recovers with a blind 500ms \r, not a delivery check:

    // src/main/runtime/orca-runtime.ts — mail/inject submit
    // Why: agent TUIs can swallow a \r in the same PTY write; submit separately after a delay.
    flight.enterTimer = setTimeout(() => {
      ...
      this.ptyController?.write(deliveryPtyId, '\r')
    }, 500)

    That timer reports success even when the composer still holds the draft. Cursor Agent is explicitly not auto-submitted (isCursorAgentOrchestrationTarget returns before the timer), so cursor-agent workers launched via .cmd never get an Enter from this path at all.

    #10662 / PR #13763 (honest submit verdict) is the right primitive. Until inject/send is verify-then-retry, coordinators cannot tell “unsubmitted draft” from “thinking.”

  5. OrcaWin commented on Aug 16, 2026

    @OrcaWin
    Collaborator

    Related: #14505 is the same unsubmitted-inject symptom on packaged Windows. #14342 (wait for Claude composer render) merged after v1.4.182 and is in v1.4.183, but this report is on v1.4.182 and explicitly rules out a TUI-boot race (tui-idle already satisfied; also reproduces on later terminal send --enter). Leaving open — not a confident "already fixed in 1.4.183" match. A retest on latest would help.

  6. mestrecs commented on Aug 21, 2026

    @mestrecs

    Retest on v1.4.187 (latest): still present. Adding the bundle-level root cause and a patch we have been running in production for 3 days, since @OrcaWin asked for a retest on latest.

    We hit this 10 times in 5 days on Windows 11 (7 on one day, 3 on another) with Claude Code workers and preambles of ~4–6 KB, on 1.4.184 (packaged Windows x64, ConPTY, several agent terminals live at once).

    Still unfixed on latest

    Checked against the source at tag v1.4.187:

    • src/shared/agent-prompt-injection.ts still submits on a fixed timer — WINDOWS_AGENT_PROMPT_SUBMIT_DELAY_MS = 1_500, DEFAULT_AGENT_PROMPT_SUBMIT_DELAY_MS = 500;
    • there is no verification layer anywhere in the repo (no symbol like confirmAgentPromptSubmitted).

    So #14342 (wait for Claude composer render, in 1.4.183) narrowed the boot race but did not close this one, which matches the report: it reproduces after tui-idle is satisfied.

    Root cause, at line level

    All references to out/main/index.js inside resources/app.asar (unminified in the shipped build).

    1. The submit is blind and time-based — writeTerminalAgentPrompt (~197427):

    // ... writes pastePayload in 16 KB chunks ...
    await new Promise((resolve) => setTimeout(resolve, AGENT_PROMPT_SUBMIT_DELAY_MS));
    await options.beforeWrite?.(ptyId);
    if (!(this.ptyController?.write(ptyId, "\r") ?? false)) throw new Error(/* ... */);

    The delay is measured from "we finished writing bytes to the pty", not from "the TUI finished consuming the paste". Those are different clocks: a 4–6 KB paste through ConPTY on a busy machine can still be in flight after 1500 ms. When it is, the \r lands inside the ESC[200~ … ESC[201~ window and the TUI treats it as pasted text — which is exactly the extra blank line you see in the composer.

    2. Delivery is never verified — worker-start (~87945):

    failedStage = "dispatch_input";
    const preamble = buildDispatchPreamble({ /* ... */ });
    await runtime.sendTerminalAgentPrompt(terminalHandle, preamble);
    effects.push({ kind: "dispatch_input", role: "agent", id: terminalHandle, state: "accepted" });
    const worker = db.markWorkerDispatchReady(started.dispatch.id, effects);

    state: "accepted" is unconditional — the only evidence behind it is that a PTY write did not throw. Note the asymmetry: the code does wait for tui-idle before sending (~87921), but never checks that the terminal left idle afterwards, which is precisely the observable that separates success from this failure.

    The decision-gate preamble (~83881), re-dispatch (~88654) and send --preamble (~89572) all go through the same sendTerminalAgentPrompt funnel, so all four paths share the defect — and would share a fix.

    Making it deterministic

    Temporarily lower WINDOWS_AGENT_PROMPT_SUBMIT_DELAY_MS (e.g. to 50). The failure becomes reliable, which is what confirms it is a race against paste ingestion rather than a TUI-boot race.

    The patch we run

    Patched at the sendTerminalAgentPrompt level so all four call sites are covered (+1048 bytes, 3 hunks). Verify-and-resubmit while the terminal is still idle:

    async confirmAgentPromptSubmitted(handle, options = {}) {
        const maxResubmits = 4;
        const intervalMs = 2e3;
        for (let attempt = 0; attempt <= maxResubmits; attempt += 1) {
            await new Promise((resolve) => setTimeout(resolve, intervalMs));
            let status;
            try {
                status = await this.getTerminalAgentStatus(handle);
            } catch {
                return;
            }
            if (status.status !== "idle") return;          // consumed: agent left the prompt
            if (attempt === maxResubmits) {
                console.error("[preamble-submit] agent prompt still unsent after re-submits", { handle });
                return;
            }
            let ptyId;
            try {
                ptyId = this.getTerminalAgentStatusPtyId(handle);
                await options.beforeWrite?.(ptyId);
            } catch {
                return;
            }
            if (!(this.ptyController?.write(ptyId, AGENT_PROMPT_SUBMIT) ?? false)) return;
        }
    }

    Two properties worth keeping in whatever you land:

    • Never re-send \r when the status is permission. A blind Enter on a permission dialog would silently accept it. Only idle should trigger a re-submit; null/unknown should do nothing.
    • An extra \r on an empty composer is a no-op, which is what makes the retry safe.

    Result on our side: since applying it, 7+ consecutive dispatches submitted on their own with no manual Enter, on the same machine and the same workload that was failing several times a day.

    The part that actually cost us the time

    Even with a retry, a dispatch that was never consumed should not be recorded as ready. dispatch_input: accepted on bytes-written alone is what turned all 10 of our incidents from visible into silent — there was nothing to alert on and nothing to retry, because every participant believed the handoff had happened. Marking it unverified, or even just logging it, would have been enough. #10662 / PR #13763 (honest submit verdict) is the right primitive for this half.

    An adaptive delay scaled by payload size would narrow the race but cannot close it; only an observation of the terminal state can.

  7. Tauri-EPO commented on Aug 22, 2026

    @Tauri-EPO
    Contributor

    Two corrections to the v1.4.187 retest above, plus one thing it surfaced that is now being reported separately. Everything below is checked against the tag rather than against main.

    The verification layer does exist at v1.4.187

    there is no verification layer anywhere in the repo (no symbol like confirmAgentPromptSubmitted)

    That symbol is not there, but the layer is — under a different name:

    $ git ls-tree -r v1.4.187 --name-only | grep agent-prompt-submission
    src/main/runtime/agent-prompt-submission-runtime.test.ts
    src/main/runtime/agent-prompt-submission-verification.test.ts
    src/main/runtime/agent-prompt-submission-verification.ts
    
    $ git grep -n verifyAgentPromptSubmission v1.4.187 -- src/main/runtime/orca-runtime.ts
    19308:    await verifyAgentPromptSubmission({
    

    It sits immediately after the \r, inside the same funnel this report identifies:

    const suffixWrote = this.ptyController?.write(ptyId, AGENT_PROMPT_SUBMIT) ?? false
    if (!suffixWrote) {
      throw new Error(options.suffixFailureError ?? 'terminal_not_writable')
    }
    await verifyAgentPromptSubmission({
      baseline,
      readActivity: () => this.getAgentPromptActivity(handle, ptyId),
      signal: options.signal
    })

    and it polls for up to AGENT_PROMPT_EFFECT_TIMEOUT_MS = 5_000 looking for current.workingSequence > baseline.workingSequence, throwing agent_prompt_stalled when the agent never starts working. It arrived with #14962, merged 2026-08-17 and released in v1.4.187. The line-level analysis above is from the 1.4.184 asar, which predates it.

    dispatch_input: accepted is no longer unconditional in effect

    The line is still written unconditionally in source at v1.4.187 (orchestration-workers.ts:236), but it is unreachable when submission fails, because the await above it rejects:

    await runtime.sendTerminalAgentPrompt(terminalHandle, preamble)
    effects.push({ kind: 'dispatch_input', role: 'agent', id: terminalHandle, state: 'accepted' })
    const worker = db.markWorkerDispatchReady(started.dispatch.id, effects)

    So the half of this report that made the incidents silent — "every participant believed the handoff had happened" — is closed on v1.4.187. worker-start now returns state: failed, stage: dispatch_input, lastError: agent_prompt_stalled.

    The safety property is already implemented

    Never re-send \r when the status is permission.

    That is assertPromptNotBlocked in the same file: it throws agent_prompt_blocked when current.status === 'permission' or the permission sequence has advanced since the baseline. Worth knowing if a resubmit is layered on top of it, since the guard is already there to compose with.

    What the retest gets right, and what the fix turned the failure into

    The blind timer is unchanged. WINDOWS_AGENT_PROMPT_SUBMIT_DELAY_MS = 1_500 still measures from "we finished writing bytes", not "the TUI finished consuming the paste", so the race this report identifies still fires. The verification catches it after the fact; it does not prevent it. The conclusion that only an observation of terminal state can close this, not an adaptive delay, is unaffected by anything above.

    What did change is the shape of the failure, and it has its own cost. A dispatch that fails at dispatch_input revokes its capability before any worker_done and leaves its agent terminal behind as a residualResources entry, with worker-release able to answer release_unknown / tab_not_found. That is #15920 (macOS, filed today) and #15826 (Windows). On a released build the failure is no longer silent — it is loud, and it leaves a terminal that no CLI command can reclaim.

    None of this argues against the verify-and-resubmit direction proposed here. It does mean such a change would now compose with an existing verification step rather than introduce the first one, and that whatever lands should also say what happens to the residue when it gives up.

  8. yoyofreeman commented on Oct 22, 2026

    @yoyofreeman

    Same failure class, Linux + OpenCode 2.1.3 (our case: text never even reaches the composer)

    Reproducing this on Linux (Ubuntu 24.04), Orca 1.4.237, OpenCode 2.1.3 TUI, with
    orca orchestration dispatch --task <id> --to <opencode-terminal-handle> (no --inject).
    Difference from the report: the spec text does not appear in the composer either — the
    OpenCode TUI stays on its idle welcome banner (Ask anything…). So it is one step further
    along than "delivered but not submitted".

    Evidence (two dispatches, same coordinator terminal, ~10 min apart)

    dispatch worker-list says what actually happened artifact that should exist
    ctx_59ecd1b1cf68 (task task_32a76b08809c) [ready/done] liveness=live provider=opencode — looks green worker-read --dispatch … --limit 12 returns only the idle OpenCode welcome screen /tmp/threading-research.md missing
    ctx_e5c4e69cb0de (task task_9421dab02e1a) [unsupervised/unknown] attention=failure,interruption liveness=exited worker-read → No terminal output returned. /tmp/xtool-eval/ missing

    worker-read metadata in both cases:

    Fallback reason: session_not_reported
    Content complete: false
    Clipping: terminal_buffer, terminal_fallback
    

    The dispatch call itself returned success with dispatch_input … state: "accepted".

    Why this is worse than a plain failure

    state: "accepted" plus worker-list [ready] / [done] is read by coordinators as
    "dispatched and running". I acted on that reading and reported to a human that two
    jobs were in flight; neither had started. The only signal that would have caught it is
    checking for the expected artifact, which the contract does not require.

    Suggestions (matching the ask in this issue)

    1. Deliverability gate before reporting success: after injecting, read the terminal
      buffer back and require the task text (or a hash of it) to appear. Only then report
      dispatched; otherwise report undelivered with the buffer excerpt.
    2. worker-list: add a delivered field distinguishing coordinator accepted from
      agent session actually received it, so [ready] stops being read as "running".
    3. Terminal-backend-aware injection: OpenCode TUI apparently needs a different
      keystroke/paste sequence than the Claude/Codex paths; pick it automatically instead of
      making the caller guess (--inject also fails with the same "already has an active
      dispatch" guard in this scenario, so there is no working fallback).
    4. Docs/skill: state plainly that artifact existence is the required post-dispatch
      assertion — the current orca-subagents flow implies dispatch returning OK is enough.

    Environment

    • Orca 1.4.237, OpenCode 2.1.3 (TUI, provider opencode, default free model), Linux x86-64.
    • Coordinator: pi terminal (term_e9a…) in the same Orca instance; workspace
      /home/leon/studio/devel/cellforth.
    • pi --version 1.4.0.

    Local record: our own issue tracker entry issue_20261023010848_8a13 (repo-side evidence +
    repro steps) — happy to attach more logs if useful.

  9. hgijeon commented on Dec 1, 2026

    @hgijeon

    I hit what looks like the same symptom (macOS, Claude worker, brief typed but never submitted, intermittent) and traced one concrete cause (it explains only part of my failures; see below).

    Mechanism. On exit, Node.js unconditionally writes the termios it saw at startup back to a tty stdio, even when it is a background process (nodejs/node#66753 fixes this on main; not in a release yet). If a shell startup script runs a Node-based CLI in the background with the terminal inherited, and that process starts in the few tens of ms before Claude enables raw mode, its exit puts the tty back into canonical mode under Claude. After that, the kernel echoes the pasted brief and ICRNL turns Orca's Enter (\r) into \n, which Claude treats as a newline, not submit. Orca then reports turn_start_unobserved.

    Evidence.

    • Of 5 watched failures, 2 had the tty cooked (icanon echo icrnl) while Claude was running, and in both an Orca CLI process (orca account list --json, invoked by a status script from .zshrc) exited at the raw→cooked flip. The other 3 stayed in raw mode with [Pasted text #1 +171 lines] left in the composer, so they are a different cause that this does not explain.
    • Deterministic A/B: a background Node process that inherits the tty and is alive when claude starts leaves the tty cooked in 4/4 runs, and the brief is not submitted in 3/3. Detaching the same process (</dev/null >/dev/null 2>&1) gives 0/4 and 3/3 submitted.
    • It is intermittent because it needs that timing; failures clustered at high load.

    Workaround. Detach background jobs in shell startup files from the terminal.

    Note for Orca. The bundled Orca CLI runs on Electron's Node, so it is one such process until the bundled Node includes nodejs/node#66753.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggitorchestrationos:macos

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions