Skip to content

Tell GOA of a worker's turn in one line, with its real last message - #35

Merged
enowdev merged 1 commit into
mainfrom
fix/goa-one-line-per-turn
Nov 4, 2026
Merged

enowdev merged 1 commit into
mainfrom
fix/goa-one-line-per-turn

Conversation

@enowdev

@enowdev enowdev commented Nov 4, 2026

Copy link
Copy Markdown
Owner

GOA got a worker's goa report line, then a "finished a turn" line with an older message, sometimes from mid-turn.

Cause

Your reading was right, with one correction: the old message and the two lines are separate causes.

  1. Two lines: goaReportSeen (daemon/goa_tasks.go:400) tells at once. goa report is a tool call made while the turn still runs, so goaWorkerChanged (:289) tells again when the turn ends. Nothing joins them. The no-task path has the same split (daemon/goa_told.go:188,195), where the check for "that was its turn's end" only holds when both arrive in one update.
  2. Old message: goaResult (:456) took the transcript's last assistant message at that moment, with no check that the transcript had reached the turn's end.

Measured on real Claude Code 2.1.318: in a turn that said INTERIM-ONE, ran a command and said FINAL-TWO, the Stop hook received last_assistant_message: "FINAL-TWO", while its transcript had no readable rows at that moment or 1.5 seconds later. So the transcript does lag. That was one first-turn run.

The session you named: 37a8b7c577f1 is on the Mac. I read its recent chat through the app and it no longer shows that turn, so I couldn't confirm this on that exact case. The waiting queue only delays lines; it doesn't cause them.

Case 5 of #30: not touched there. This is that fix.

Fix

  • Real text: the turn-end hook's last_assistant_message is kept as SessionInfo.TurnText and travels with session updates, so GOA on another host gets it too.
  • Fallback: otherwise the transcript is re-read until its last entry is a message, up to 6 seconds, then the line says the message isn't recorded yet rather than give an old one.
  • One line: a report made while the agent works waits up to 30 seconds for its turn's end to join it. A turn's end still queued takes a later report. Past that, it goes alone and the end gets its own line, so two lines are still possible on a long tail.
  • Never lost or merged: questions, failures and corrections stay separate, and they release what was held so order holds. Each real turn keeps its own line. Lines of one session don't pass what it holds; other sessions aren't held up.

Older daemons on another host send no TurnText, and the fallback covers them. Codex's hook field isn't verified, as it isn't installed here; the fallback covers it too.

A worker that ends a turn waiting on a background command: that message really is its last, so it stays, marked "may be mid-work" as before.

Tests

Report then end, end then report, transcript written late, queued while GOA is busy, two real turns, no task, a held report not lost, per-session hold. On enowxlabs: daemon and core/session.

Not run: a real GOA with a real worker; Codex.

Merge order: this conflicts with #30 in goaSeen and rpc_goa.go, both small: #30 moves the same lines into goaWorkerSeen, where the goaTurnStarted call then belongs.

Touches no go.mod, version/ or cloud/, so merging doesn't deploy the cloud.

🤖 Generated with Claude Code

A turn reached GOA twice, by routes that knew nothing of each other: its goa report,
a tool call made before the turn ends, and its end, whose text was the transcript's
last assistant message at that moment. Claude Code's transcript lags its Stop hook, so
that could be an older message, even one from mid-turn.

The text now comes from the agent's turn-end hook where it says it, and else from a
transcript that holds the turn's end. A report made at work waits briefly for its
turn's end to join it. Another turn keeps its own line, and a question or a failure is
never merged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@enowdev
enowdev merged commit fdf6602 into main Nov 4, 2026
1 of 4 checks passed
@enowdev

enowdev commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

Its commits are in main through the 0.7.0 release merge (#40, e306b3b).

@enowdev
enowdev deleted the fix/goa-one-line-per-turn branch November 5, 2026 04:58
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.

1 participant