Repository navigation
📏 test: Hold a Long Agent Thread to Count Budgets - #18712
Draft
danny-avila wants to merge 2 commits into
Draft
danny-avila wants to merge 2 commits into
danny-avila wants to merge 2 commits into
Conversation
This was referenced Nov 22, 2026
8 tasks done
This branch has not been deployed
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
Nothing in CI notices when a change makes a long conversation heavier. The costs fixed in #18551, #18555, #18571 and #18580 (a toolbar mounted in every row, a whole thread mounted in one commit, every row rendering on each streamed frame, a document listener per tooltip) were all found by hand with a profiler, after they had merged. Timing them in CI is not an option on shared runners: the same build measures two to five times slower when the machine is busy.
This adds two mock-lane scenarios that open a generated 250-row agent conversation and hold what it costs the page to budgets. Every figure is a count taken from the built client, so it comes out the same on a busy runner as on a quiet one, and a change that goes over one fails before it merges.
openedreadsteplistenersdocumentandwindowafter reading every rowframearoundearlierThe conversation the scenarios open is new too.
buildThread(rows)generates a thread with the shape of a real working session of about 250 rows (4,667 parts, 3,152 of them tool calls in the same mix of tools, grouped under activity labels and phases, with reasoning between them and user turns long enough to collapse). The same seed gives the same content on every machine, so two builds are measured against the same thread. It is also what a timing run ondevcan open later, in place of an exported private chat.Two of today's figures are costs the counts turned up, left as they are here and to be fixed separately, each fix lowering its budget:
frameis 74 instead of 59 once the reply's usage control (ℹ️ feat: Add Conversation Info and Message Usage #17968) has mounted: the control renders again on every streamed frame.earlieris entirely the toolbars of the rows near the reader, rendered five or six times per send because they read the whole chat context for two of its fields.How it works
Renders are counted through the hook React reports every commit to, which works on the production bundle: a stand-in installed before the bundle loads sees each component that rendered, and a render is attributed to a row when it is below that row's element.
frameis the count more commits share than any other, since a reply is a few hundred commits and most of them write one frame of its text; a mean or a median moved with how the frames happened to batch.A failing run reports every budget the change went over, not only the first, and every run prints what it measured:
Elements are counted inside the thread, and the scenarios clear the user's other conversations first. The first CI run of this pull request showed why: the sidebar there listed 24 conversations left by earlier specs, which added 445 elements and 72 window listeners (each listed conversation registers
keydown,keyupandbluron the window throughuseShiftKey).The seeded conversation carries the agent id a first turn on the provider saves. Without it the reply sent by the test is the turn that sets it, every row renders again for the conversation it now reads, and
earliermeasures the seed instead of the app.Type of change
Testing
Tested environments/configuration:
Automated tests:
thread-budgets.spec.ts: 17 runs of each scenario locally. The four document counts were identical in every run;aroundwas 31 in every run;framewas 59 or 74 andearlier1,635 or 1,931, all inside their budgets.The budgets fail when they should. Against a build with five deliberate breaks (every toolbar mounted, the mount chunk unbounded, the row and message memos returning false, a
keydownlistener per row) both scenarios failed with:(Taken while elements were still counted over the whole document, hence the larger
openedandreadfigures.)readholds there, as it should: it counts what every row weighs once read, which none of those breaks changed.long-conversation-mount.spec.tsandoffscreen-rows.spec.tsstill pass beside it (16 scenarios in all).On a hosted runner the first CI run read the same step and the same per-frame figures as locally (
frame74,earlier1,635).openeddepends on how many rows fit near the viewport, which follows font metrics, so it has 5% of headroom.Screenshots / recordings
No user-facing change.
Risk / compatibility
Test-only. The two scenarios add about 40 seconds to the mock lane. A budget can fail a pull request for a cost it means to add; the README section says when to raise one and when to lower one.
Checklist