fix(claude): subagent usage no longer fills the context meter #6586
main fromrefs/pull/6586/head·opened View on GitHubClaude's subagent progress reports cumulative token totals across child work. T3 Code treated those totals as active parent-conversation context, so enough subagent work could make the context meter look full even when the parent chat still had room.
Subagent usage now stays on the task progress and completion rows. The context meter only changes when Claude reports usage that represents the active parent turn.
How it works:
task_progressandtask_notificationkeep their typed token, tool, and duration data on the task event without emitting a parentthread.token-usage.updatedevent.- Parent input/output tokens and iteration snapshots continue to update the context meter normally.
- A result containing only cumulative
total_tokensupdates total processed usage without turning that total into active context usage. - When a total-only result follows a real parent usage snapshot, the last known active context is preserved instead of being replaced by the child-inclusive total.
Focused Claude adapter tests cover task progress, task completion, oversized subagent totals, and total-only results.
Note
Medium Risk Changes token accounting in the Claude adapter (context meter UX), but behavior is scoped to usage interpretation with focused test coverage.
Overview
Fixes the parent context meter incorrectly showing full when Claude subagents report large cumulative total_tokens.
task_progress / task_notification no longer emit thread.token-usage.updated. Child usage stays on task.progress and task.completed via typedUsage only. The helper that promoted task totals into parent active context was removed.
Turn result usage only updates the parent meter when usage reflects active context (input/output tokens or an iteration snapshot). Results with only total_tokens no longer drive usedTokens; when a prior parent snapshot exists, that active context is kept instead of treating the cumulative total as the window fill.
Adapter tests were updated to assert no parent usage events for task progress, total-only results, and subagent-heavy flows, while real input/output result usage still updates the meter.
Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 35fab5c3e8919fc7081a16341a6acfe81b588006. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).Note
Fix subagent usage filling the parent context meter in Claude adapter#
- Subagent token usage from
task_progressandtask_notificationevents no longer emitsthread.token-usage.updated; usage is instead attached astypedUsageontask.progressandtask.completedevents respectively. - Result events that only contain
total_tokens(cumulative subagent work) are treated as non-active context and no longer produce a thread token-usage snapshot. normalizeClaudeTaskProgressTokenUsageis removed from ClaudeAdapter.ts as no callers remain.- Behavioral Change: previously, subagent totals would update the parent thread's context meter; they now only appear on task-scoped events.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
Approvability#
Verdict: Approved 35fab5c
Straightforward bug fix that removes code incorrectly promoting subagent token usage to the parent context meter. The change is a net code deletion with comprehensive test coverage verifying the corrected behavior.
You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).Note
🤖 GPT-6 Astra (preview) responding on behalf of Theo
This was closed as part of an automated cleanup pass. If you believe it was closed in error, reply here and we will get it reopened.
Closing in favor of #8453. That patch keeps cumulative usage separate from the parent context meter and uses the parent model's context window. Review continues there. The total-only result cases from this branch are recorded on the retained PR, so the result fallback does not mistake cumulative work for active context.
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
73cf75df-39bb-4b03-9572-d8876bd87eafYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share