fix(coding-agent): coalesce child usage attribution - #1061
Closed
Lauritz-Timm wants to merge 1 commit into
Closed
Conversation
Lauritz-Timm
marked this pull request as ready for review
August 9, 2026 08:59
avion23
pushed a commit
to avion23/prime-agent
that referenced
this pull request
Aug 9, 2026
… child usage attribution
Contributor
|
Thank you for the report and proposed work. This root cause is now covered by maintainer-owned stacked PR #1162, authored independently from We did not inspect or reuse this PR's diff, branch, commits, implementation code, or tests; its public description/comments were used only as a bug report. To keep one review surface, this PR is superseded by #1162 and is being closed. The complete review stack is #1158–#1165. It is being left unmerged for human review after CI and review-bot findings are cleared. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
child_usage_attributedentry atagent_endinstead of one per assistant messageRoot cause
Every child
message_endimmediately appended a usage-attribution entry to the parent transcript. Tool-heavy RLM children therefore caused a sustained stream of transcript writes and leaf mutations on the same worker event loop that serves attach and heartbeat requests. Under load, the worker consumed several gigabytes of memory and stopped answering daemon control requests.The in-memory parent usage total still updates for every assistant message. Only persistence is coalesced to the child turn boundary, preserving billing totals and reload behavior while removing the write flood.
User impact
Long-running RLM sessions remain responsive while subagents execute dense tool loops, and parent transcripts no longer accumulate hundreds of bookkeeping entries for one child turn.
Validation
test/suite/regressions/1054-child-usage-attribution-flood.test.ts: 1 passedtest/agent-session-recursion.test.ts: 96 passednpm run check: passedFixes #1054
Note
Fix child usage attribution flood by coalescing entries per child turn
child_usage_attributedentry on the parent session, flooding the parent transcript.AgentSession.runRlmChildnow accumulates usage into apendingChildUsagebuffer and flushes a single aggregated entry per child turn, splitting only when the attribution origin changes mid-turn.child_usage_attributedentry.Macroscope summarized c2dacb0.