Skip to content

Never fail a claude turn on a timer while the CLI is still working (#17) - #45

Merged
currentbits merged 1 commit into
mainfrom
coder/agent-task-shows-starting-agent-and-agen-8165b0
Aug 15, 2026
Merged

currentbits merged 1 commit into
mainfrom
coder/agent-task-shows-starting-agent-and-agen-8165b0

Conversation

@currentbits

@currentbits currentbits commented Aug 15, 2026 •

Copy link
Copy Markdown
Owner

Fixes #17 — "Starting agent ✓, Agent working ✓, then nothing happens".

Root cause (reconstructed from real data, not inference)

The one occurrence under the current build is fully traceable: coder-store.json thread 107aa530, run at 2026-08-15T06:53:42Z, cross-referenced with the claude session transcript ~/.claude/projects/-Users-willem-code-AppVideo/374136fe-….jsonl.

time (UTC) what happened
06:53:42.957 Solenta sends continue to a resumed CLI
06:53:44.046 the CLI settles a queued <task-notification> as its own turn, answering it with an empty success result → the runner correctly holds it as a phantom
06:53:44.062 our prompt is accepted by the CLI
06:54:14.131 the 30s phantom grace expires → Run error: no output from agent, run slot cleared
06:54:32.890 the real turn's first token lands (48s of thinking on a 21MB session) — and is dropped by the runId guard, along with the rest of the turn

The grace timer treated wall-clock silence as proof the turn was over. No timeout can be both short enough to catch a dead CLI and long enough to survive a legitimately slow first token — the same reasoning already recorded for the hung-stdin remainder in docs/ISSUES.md.

Before the phantom-hold shipped, this same race appeared 12× in the store as a silent success: both work-log steps checkmarked, no output, no error — the issue exactly as filed.

Second silent path (found by audit, covered by test)

onExit finalized on sawResult || gotResult. gotResult is claude.js's per-process flag for any parsed result line — including a phantom the runner deliberately did not finalize on. So phantom → real content → CLI crash checkmarked both steps with no message, no status change and no notification: the reported symptom, reachable by a second route.

What changed

  • electron/runner.js: a held phantom becomes a failure only when the process exits — the one piece of evidence that the turn is really over. The grace timer, PHANTOM_RESULT_GRACE_MS and CODER_PHANTOM_RESULT_GRACE_MS are deleted.
  • electron/runner.js: onExit finalizes on sawResult alone, so a resultless death always surfaces Run error (exit N) instead of silently checkmarking the work log.
  • docs/ISSUES.md: symptom → evidence → cause → fix → tradeoff entry.

Tests (both new ones verified red before the fix)

  • keeps waiting when the real turn is slower than any fixed grace window — the fake CLI emits a phantom, waits 400ms, then the real turn; with the old 80ms grace the thread lands failed instead of done.
  • reports the exit when the CLI dies after a discarded leftover result — times out waiting for failed against the old gotResult branch.
  • fails a turn that only ever emits an empty leftover result, then exits — reworked to key off process exit instead of the timer.

npm test: 1574 tests, 0 failures (38 core / 718 renderer / 699 electron / 119 memory).

Tradeoff

A CLI that answers a phantom and then never speaks or exits now spins on "Agent working…" (step unchecked, Stop available) instead of failing after 30s. That is the honest state, it is the same gap as the documented hung-stdin remainder, and it is strictly better than fabricating a failure while discarding a turn that is still running.

🤖 Generated with Claude Code

  • PR created by the Claude Code agent

…ng (#17)

A resumed or kept-alive Claude CLI settles a queued task-notification as
its own turn first and answers it with an empty success result. The runner
holds that phantom, but a 30s grace timer then failed the run outright —
and the real turn's first token can land much later (48s of thinking on a
large resumed session, per the session transcript for the one occurrence
in the wild). Everything the still-running CLI produced afterwards was
dropped by the runId guard: both work-log steps checkmarked, no output,
no error.

A held phantom now becomes a failure only when the process exits, the one
piece of evidence that the turn is really over. Same class of bug in
onExit: it finalized on `sawResult || gotResult`, but claude.js sets
gotResult for any result line including a held phantom, so a phantom
discarded by real content followed by a CLI crash checkmarked both steps
with no message, no status and no notification.

Co-Authored-By: Claude Opus 5 <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@currentbits
currentbits merged commit d8bd41f into main Aug 15, 2026
1 check passed
@currentbits
currentbits deleted the coder/agent-task-shows-starting-agent-and-agen-8165b0 branch October 3, 2026 16:07
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.

Agent task shows 'Starting agent' and 'Agent working' checkmarks but nothing happens

1 participant