Skip to content

Fix inflated live turn counter in hackbot Reporter#6276

Draft
msujaws wants to merge 1 commit into
mozilla:masterfrom
msujaws:fix-reporter-turn-count
Draft

Fix inflated live turn counter in hackbot Reporter#6276
msujaws wants to merge 1 commit into
mozilla:masterfrom
msujaws:fix-reporter-turn-count

Conversation

@msujaws

@msujaws msujaws commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

The live --- turn N --- markers counted every streamed main-agent AssistantMessage, but the CLI streams one model response as several messages (thinking / text / tool_use), inflating the count ~2x versus the authoritative ResultMessage.num_turns shown in [done] turns=.

Count a turn only when the main-agent message_id changes so the live marker tracks real turns (falls back to per-message counting when message_id is unavailable). Also show --- turn N/max --- when max_turns is set, and thread max_turns into the Reporter at all four agent call sites.

Cost and max_turns enforcement are unaffected; both come straight from the SDK/CLI and never depended on this counter.

Attached is a log file that shows the miscounted turns: log.txt

The live `--- turn N ---` markers counted every streamed main-agent AssistantMessage, but the CLI streams one model response as several messages (thinking / text / tool_use), inflating the count ~2x versus the authoritative ResultMessage.num_turns shown in `[done] turns=`.

Count a turn only when the main-agent message_id changes so the live marker tracks real turns (falls back to per-message counting when message_id is unavailable). Also show `--- turn N/max ---` when max_turns is set, and thread max_turns into the Reporter at all four agent call sites.

Cost and max_turns enforcement are unaffected; both come straight from the SDK/CLI and never depended on this counter.
@msujaws msujaws marked this pull request as draft July 2, 2026 14:54
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