Repository navigation
fix(agent): fold large unchanged subtrees in the full-screen fallback - #1797
Varshith-Kali wants to merge 12 commits into
Conversation
There was a problem hiding this comment.
All reported issues were addressed across 4 files
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
View guided diff | Re-trigger cubic
There was a problem hiding this comment.
0 issues found across 1 file (changes from recent commits).
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
Requires human review: Auto-approval blocked by 1 unresolved issue from previous reviews.
View guided diff | Re-trigger cubic
There was a problem hiding this comment.
0 issues found across 6 files (changes from recent commits).
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
View guided diff | Re-trigger cubic
There was a problem hiding this comment.
0 issues found across 1 file (changes from recent commits).
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
View guided diff | Re-trigger cubic
okwasniewski
left a comment
There was a problem hiding this comment.
Thanks! The sidebar folding works well in the new tests, and keeping the folded subtree tied to the screen that last listed it in full is a nice touch. A few things before this can land:
Must-fix
- A fold can point at a screen the agent no longer has. A truncated full screen records nothing and folds nothing, so the old record survives it while the screen it names gets elided. Repro with the presenter plus
compactScreenHistory: b1 opening screen, b2 folds the sidebar against b1, b3 is a truncated full screen (b1 and b2 get elided at the default budget), b4 is a normal fallback. b4 prints#n2 navigation "Sidebar" (12 nodes inside, unchanged since revision b1)while b1 already reads[earlier screen elided ...]. The agent'sobserveonly returns changes, so it can't get the subtree back. Suggested fix: after each full render, keep only the records that render listed or folded and drop the rest (a truncated render clears them all). Each fold then depends on exactly one screen, and the transitive lookup incompactScreenHistorycan go. skills/e2e/references/agent.md(and the plugin copy) says "observestill returns the complete tree". For the built-in agent that page describes,observereturns what changed. Only the MCPobservereturns the whole tree. Please fix the wording and wrap the line.- The changeset describes internals (which revision a fold names, transcript elision). One user-facing sentence is enough, e.g. "When an action changes most of the screen, large subtrees that did not change are shown as one line instead of being repeated."
Nits
transcript-compaction.tsparses the fold line with its own regex. Exporting the pattern fromscreen-update.ts, likeFULL_SCREEN_PATTERN, would keep the two in sync.hasFocusrepeats the state-bracket regex fromwithoutFocus.- These checks can be removed without any test failing: the comparison with the previous screen in
subtreeUnchanged/previousSubtreeIds, the truncated listing recording nothing, pruning records for removed nodes,entry.indent > 0, and the early return for screenshot results whose screens are all kept. Either add tests or drop the code (the digest already covers ids and lines). - A digest is computed for every node on every full render. Only subtrees with 10 or more nodes can fold, so only those need one.
Heads-up: whether folding should apply to the built-in agent at all, or only to MCP (what #1788 asks for), is still a maintainer call. MCP-only would drop the transcript-compaction.ts changes and the first must-fix entirely, so hold off on bigger rework until that's settled.
Automated review by Claude Code on behalf of the maintainers.
|
Thanks for the careful review. All three must-fix items are addressed in 6a17583, plus the nits below. Must-fix 1, the dangling fold: you were right, and it reproduced against the current head even after 81a99b6. The gap 81a99b6 left is the cross-pass case: b3 carries no fold, so nothing preserves b1 when b3 is compacted, and b4 then folds against a revision that is already elided. I wrote that exact b1/b2/b3/b4 sequence as a regression test first and watched it fail, then implemented your suggested fix: a full render now replaces the fold record with exactly what it listed in full or folded, so a truncated render clears it entirely and b4 lists the sidebar in full again. The new test covers the presenter plus One place I did not follow the suggestion literally: I kept the transitive lookup in Must-fix 2: the skill page now says Must-fix 3: the changeset is now your one sentence, nothing else. Nits: the fold-line pattern is exported from On the dead checks: I dropped the previous-screen comparison in No change on the heads-up: Verified: focused suites 45/45 green, full e2e unit suite 3667 passed (6 skipped), oxlint and tsc clean, |
There was a problem hiding this comment.
All reported issues were addressed across 7 files (changes from recent commits).
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
View guided diff | Re-trigger cubic
There was a problem hiding this comment.
0 issues found across 1 file (changes from recent commits).
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
View guided diff | Re-trigger cubic
|
[claude-opus-5-5] automated review on behalf of @okwasniewski Re-reviewed at One more case to fix before this goes to human review:
Nits:
|
There was a problem hiding this comment.
0 issues found across 9 files (changes from recent commits).
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
View guided diff | Re-trigger cubic
|
All four items in this review are addressed in a4d54ff, pushed. Focused suites 56/56 green; full unit 3670 passed with 1 pre-existing failure (a doctor CLI timing test that fails identically on the clean head).
Nits: dead index check dropped; the screen-revision pattern is exported from screen-update.ts and shared; FOLD_DEPENDENCY_PATTERN is exported without /g (foldDependencies builds its own global copy for matchAll); agent.md now says subtrees fold when unchanged since the screen that last listed them in full, in both copies. The built-in vs MCP-only scope call is untouched, as before. |
okwasniewski
left a comment
There was a problem hiding this comment.
[claude-opus-5-5] automated review on behalf of @okwasniewski
Re-reviewed at a4d54ff50. The built-in agent is fixed: the records clear inside the overflow retry before the retried request goes out, the clear is per step, and the new test fails without the fix. The plain-text keep check now has a test too. 3676 unit tests pass, and typecheck and lint are clean. I broke the fix 8 ways and a test failed for 6 of them. The 2 that got through are harmless.
One case is left:
-
A custom loop built from the public pieces still folds against cut text.
createGrammarToolswithout ascreenoption makes its own presenter (primitives.ts:915,options.screen ?? new ScreenPresenter()), and onlydefault-agent.tspassesonOverflowShrink.createToolLoopExecutorpluscreateGrammarToolsfrom@e2e-dev/e2e/agentis the documented way to build a custom brain (docs/executors.mdx). Repro at this head, with yourfoldingBigScreen: the first observe lists the sidebar at b2, the overflow retry cuts b2, and the next observe still printsnavigation "Sidebar" (12 nodes inside, unchanged since revision b2.ScreenPresenterisn't exported, so those users can't use the hook either.This also adds
onOverflowShrinkto the exportedToolLoopExecutorOptionsas an undocumented public option that exists only for internal plumbing. Suggested fix: drop the callback. Keep a per-context presenter registry thatprimitives.tscan reach (the waypresenterForworks indefault-agent.ts), make it thecreateGrammarToolsdefault, and havetool-loop.tsforget the folds itself when it shrinks. That covers both paths and adds no public API. Add a custom-loop +createGrammarToolscase next to the new test intool-loop-overflow.test.ts.
Optional, and older than this PR: the clip notice says "observe again for what is missing", but observe returns a diff, so on an unchanged screen the model can't get the cut part back. If you reset the whole presenter on shrink (shown as well as the fold records), the next look renders in full, and that fixes this case and the fold case together. That call is up to the maintainer, so it doesn't block this PR.
|
Fixed in 66e5682, as you suggested: the callback is gone. The presenter registry moved next to Added a custom-loop case next to the built-in fold test in tool-loop-overflow.test.ts: a Left the optional whole-presenter reset alone, as you said that is the maintainer call. |
There was a problem hiding this comment.
All reported issues were addressed across 5 files (changes from recent commits).
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
View guided diff | Re-trigger cubic
There was a problem hiding this comment.
0 issues found across 1 file (changes from recent commits).
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
View guided diff | Re-trigger cubic
okwasniewski
left a comment
There was a problem hiding this comment.
[claude-opus-5-5] automated review on behalf of @okwasniewski
Re-reviewed at c1db818b7. Last round's asks are done. onOverflowShrink is gone, the registry lives next to ScreenPresenter, createGrammarTools defaults to the step presenter, and the tool loop clears folds on shrink. The public API is unchanged vs main. The WeakMap is keyed by the per-step context, so nothing leaks. The full unit suite passes (3677), and lint and typecheck are clean. Reverting the clear or the shared default fails the new tests.
One regression is left:
- Two custom loops that share one context now see a screen they were never shown (
primitives.ts:917,screen-update.ts:330-342).- Repro: a custom
runStepthat callsloopA.runStep(ctx)and thenloopB.runStep(ctx), each withtools: (c) => createGrammarTools(c). - This PR: loop B's first
observereturnsScreen unchanged since revision b2 ..., a screen loop B's model never saw. - Main: loop B gets the full
Current screen (revision b4, ...). - The same thing happens with any custom executor that reruns a loop inside one step. Presenter state has to match one transcript, and a loop run owns the transcript, not the step context.
- Fix: have
LoopRunbind a fresh presenter for its context at the start ofrun(), beforetools()andbuildPrompt, and clear it on shrink through its own reference.presenterForstays as the fallback for tools used outside a loop. Add the two-loop case as a test.
- Repro: a custom
Nits:
default-agent.ts:146passesscreen: presenterFor(context), which is now the default. Removing it changes nothing, so drop it, along with the line about it in the registry doc atscreen-update.ts:327.- The comment at
tool-loop.ts:568-572repeats theclearPresenterFoldsJSDoc. Cut it to one line or remove it.
|
Fixed the two-loop regression and both nits at b816f35. LoopRun now binds a fresh presenter for its context at the start of run(), before tools() and buildPrompt, through a new bindPresenter in screen-update.ts, and clears its folds on overflow shrink through its own reference. presenterFor stays as the fallback for tools used outside a loop. The two-loop case is covered by a new test in tool-loop-overflow.test.ts: one custom runStep runs two createGrammarTools loops against the same step context on an unchanged screen. It failed before the fix, with loop B's first observe returning "Screen unchanged since revision b4 (re-observed as revision b6)", and passes now, with loop B getting the full Current screen listing and the sidebar in full. Nits: dropped the redundant screen option from default-agent.ts and the line about it from the registry doc, and cut the tool-loop.ts overflow comment to one line. The now unused clearPresenterFolds helper is removed. Verified: focused agent and tool-loop files 146 tests pass, full unit suite 3673 passed with 6 skipped and 0 failed (baseline at c1db818 was 3672 passed, so the delta is the one new test), typecheck and lint clean, dead-code check clean. |
There was a problem hiding this comment.
0 issues found across 4 files (changes from recent commits).
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
View guided diff | Re-trigger cubic
okwasniewski
left a comment
There was a problem hiding this comment.
Note
Automated review.
Re-reviewed at b816f354b. The per-run binding works: tool-loop.ts:314 binds before tools()/buildPrompt, and :575 clears folds through the run's own reference. The two-loop test fails without the bind. Nested loops are fine. The registry is a WeakMap with no new public exports, the folding/compaction chain is correct as far as I traced, and 13 of 16 key-line mutants are killed.
Must-fix: grammar tools used outside a loop now share screen state. That use is documented (docs/executors.mdx:101, the public.ts header). Nothing undoes bindPresenter (screen-update.ts:351), and the presenterFor fallback (primitives.ts:917) creates and stores one shared presenter for every toolset built from the context. Repro, PR vs merge-base:
- A custom
runStepbuildscreateGrammarTools(ctx)twice, once per model call, and callsobserveon each. On the PR the second call getsScreen unchanged since revision b2 (re-observed as revision b4), a screen its model never saw. On main it gets the fullCurrent screen (revision b4, ...). loop.runStep(ctx)followed bycreateGrammarTools(ctx).observein the same step shows the same "unchanged since b2" output. Main shows the full screen.
Suggested fix:
- In
run(), save the previous binding and restore it (or delete the entry) infinally. - In
verbKit, useoptions.screen ?? boundPresenter(context) ?? new ScreenPresenter(), whereboundPresenteronly reads. - Keep the creating
presenterForfor the opening prompt inside a run. - Add tests for both cases above.
Nits:
tool-loop.ts:310-313: the comment repeats thebindPresenterJSDoc. Cut it to one line.primitives.ts:915-916and thescreenJSDoc at:230-232("the step's shared presenter") will be wrong after the fix. Reword them.- Untested: a marker line inside a subtree that closes a span (
screen-update.ts:452). Add a test so a fold can't swallow lines past it.
Still a maintainer call: whether folding should apply to every agent or only to MCP.
…e2e-inc#1788) When an action changes most of the screen, the presenter sends the whole tree again, repeating subtrees the model already holds. A persistent sidebar can repeat hundreds of unchanged nodes on every page transition. The fallback now folds a subtree of 10 or more nodes to its root line with the node count and the revision it was last seen at, when every node in it reads as before with the same node ids. The first screen still goes out whole, observe is untouched, and a truncated listing never folds. A subtree holding the focused node stays listed.
Signed-off-by: Varshith Puli <pulivarshit@gmail.com>
…ugh elision A folded subtree used to name the last observation's revision, but that observation may have been rendered as a diff that never listed the subtree, or may itself have folded it. The presenter now remembers, per subtree root, the revision that last listed it in full and a digest of what it read then. A fold line names that revision, and only when the subtree still reads the same: a subtree that changed in between is listed in full again, which puts it on record at the new revision. compactScreenHistory preserves every screen a surviving folded screen's fold lines depend on, following the dependency transitively, so the elision notice stays true. The stale-bytes budget now counts only the screens that may be elided. Signed-off-by: Varshith Puli <pulivarshit@gmail.com>
The fold-line change updated skills/e2e/references/agent.md but the generated plugins/e2e copy was not re-synced, so pnpm plugins:check failed on the PR. Regenerated with pnpm plugins:sync. Signed-off-by: Varshith Puli <pulivarshit@gmail.com>
…ndant previous-screen check A truncated full screen recorded nothing and folded nothing, so the old fold record survived it while the screen it named could already be elided from the transcript: the next fallback then folded against a revision the model no longer holds. A full render now replaces the record with exactly what it listed in full or folded, so a truncated render clears it entirely and a later fold can never name a screen that render did not show. The comparison with the previous screen in the fold check is gone: the digest already covers the subtree node ids and lines, and the check could suppress a valid fold when an intervening change was undone. The focused node guard stays, as its own check. Digests are now computed only for subtrees large enough to fold, the fold-line pattern is exported from screen-update.ts for the transcript elision to share, and hasFocus shares the state-bracket parse with withoutFocus. The skill reference now says observe returns what changed for the built-in agent, with the whole tree only for the MCP observe, and the changeset is one user-facing sentence. Signed-off-by: Varshith Puli <pulivarshit@gmail.com>
The screenshot-result test claimed the kept b1 and b4 screens spend none of the elision budget, but with keepStaleBytes 0 any elidable screen triggers elision, so counting the kept screens in the budget produced the same output. Pass a budget that exactly covers the elidable b2 and b3 screens instead: the transcript stays untouched only when the kept screens spend none of it. The keepStaleBytes 0 pass still pins the screenshot result returning untouched while the elidable screens go. Signed-off-by: Varshith Puli <pulivarshit@gmail.com>
…result keep The overflow retry clips every screen to its head, including one a surviving fold line names, so the next screen kept folding against text the model no longer holds. The loop now tells the act executor when it shrinks, and the executor drops the step presenter's fold records, so the next full render lists everything in full. Clearing the records instead of leaving depended-on screens uncut keeps the retry able to shrink: a single huge screen would otherwise leave it nothing to cut. The same change adds the missing test for a depended-on screen that arrived as a plain-text tool result, drops the dead index check in the fold, shares the screen-revision pattern instead of duplicating its regex, exports the fold pattern without /g so later .test() calls stay stateless, and fixes the agent.md fold wording. Signed-off-by: Varshith Puli <pulivarshit@gmail.com>
…on overflow shrink A custom loop built from createGrammarTools made its own presenter, so the overflow retry that cut the screens its folds named never cleared them: the next observe still folded the sidebar against a cut revision. The presenter registry now lives beside ScreenPresenter, createGrammarTools defaults to the step's shared presenter, and the loop forgets the folds itself when it shrinks, which covers the built-in agent and a custom loop alike and drops the onOverflowShrink callback from the public options. A custom-loop case next to the built-in fold test fails before this change and passes after it. Signed-off-by: Varshith Puli <pulivarshit@gmail.com>
The GrammarToolSetup screen doc still said a tool set without screen gets a fresh presenter per step. Since the shared-presenter change, the default is presenterFor(context), the step's shared presenter, the same one the opening prompt uses. The old wording also implied the first look returns the whole screen, which no longer holds once the opening prompt has shown it. Signed-off-by: Varshith Puli <pulivarshit@gmail.com>
Two custom loops sharing one step context shared one presenter, so the second loop's first observe reported the first loop's screen unchanged, a screen its model never saw. A loop run now binds a fresh presenter for its context at the start of run, before tools and buildPrompt, and clears its folds on overflow shrink through its own reference. presenterFor stays as the fallback for tools used outside a loop. Adds the two-loop case to the overflow tests, and drops the now redundant screen option in the built-in agent. Signed-off-by: Varshith Puli <pulivarshit@gmail.com>
Grammar tools used outside a loop shared the presenter's state: bindPresenter was never undone, and presenterFor created and stored one shared presenter for every toolset built from the context. A second toolset's first observe reported the first toolset's screen unchanged, a screen its model never saw, and the same happened for tools built after a loop run. A loop run now saves the previous binding and restores it in finally, and verbKit reads the bound presenter without creating one, falling back to a fresh presenter of its own per toolset. presenterFor stays as the fallback for the opening prompt inside a run. Adds both repro cases to the overflow tests, plus a fold test proving a marker line inside a subtree keeps the lines past it listed in full. Also cuts the bindPresenter comment in run to one line and rewords the screen option docs, which named a shared presenter that no longer exists. Signed-off-by: Varshith Puli <pulivarshit@gmail.com>
b816f35 to
7a72306
Compare
|
Fixed the shared-presenter regression and the three nits, and rebased onto current main. The must-fix: a loop run now saves the previous presenter binding and restores it in a finally block in run(), so tools built outside a loop never inherit a run's presenter. verbKit reads the bound presenter without creating one (boundPresenter), and falls back to a fresh presenter per toolset when no run is in progress. presenterFor stays as the fallback for the opening prompt inside a run. Both repro cases from the review are now tests in tool-loop-overflow.test.ts: two toolsets built outside a loop each get their own first screen, and tools built after a loop run get theirs too. Both failed on the old head with the exact unchanged-since-b2 output from the review, and pass now. Nits: the bind comment in run() is one line; the screen option doc and the verbKit comment no longer call it the step's shared presenter; and the marker-line fold case has a test in agent-screen-update.test.ts, where a fold over the eleven links before the marker leaves the marker line and the twelfth link listed in full. Also rebased onto current main, including the core move to @e2e-dev/core: the fix commits are unchanged in content, only the import paths moved. Full unit suite: 3708 passed, 6 skipped; typecheck and lint clean on core and e2e. The scope question on folding for every agent vs MCP only is untouched, still yours to call. |
okwasniewski
left a comment
There was a problem hiding this comment.
Note
Automated review.
Thanks, re-reviewed at 7a72306a7. All earlier asks are done: reverting each fix (fresh fallback in verbKit, restore in finally, marker pop in spanEnds, clearFoldRecords) makes its new test fail. The rebase onto core is clean, public API unchanged, CI green.
One remaining issue:
Concurrent runs on one context leave a stale binding (tool-loop.ts:311-317, restorePresenter). Each run restores the binding it saw at start, so when two runs overlap, the last one to end puts back a presenter whose run is over:
- A starts (saves nothing, binds pA), B starts (saves pA, binds pB), A ends (deletes), B ends (re-binds pA).
Repro: a custom runStep doing Promise.all([loopA.runStep(ctx), loopB.runStep(ctx)]) (both on createGrammarTools), then createGrammarTools(ctx).observe returns Screen unchanged since revision ... instead of the full screen. On main that toolset always got a fresh presenter. Relatedly, default-agent.ts:164 reads presenterFor(context) after await context.observe(), so an overlapping run's opening prompt can use the other run's presenter.
Suggested fix: a per-context stack (bind pushes, finally removes this run's own presenter by identity, boundPresenter reads the top), and read the bound presenter in the built-in buildPrompt before the first await. Please add tests for Promise.all of two runs and for a loop nested inside another loop's tool on the same context (today no test fails if a run reuses an outer binding instead of binding fresh).
Nits:
primitives.ts:230: thescreenJSDoc still says the built-in agent shares it with the opening prompt; onlye2e mcppasses it now.primitives.ts:901andscreen-update.ts:336say "the step's presenter"; it is the loop run's presenter now.
Still a maintainer call: fold for every agent vs MCP only.
…eave no stale binding A loop run restored the single binding it saw at start, so when two runs overlapped the last one to end put back a presenter whose run was over, and tools built afterwards read that run's screen as unchanged. The per-context binding is now a stack: bind pushes a fresh presenter, the run removes its own presenter by identity when it ends, and boundPresenter reads the top. A run that ends while another run is still bound leaves that run's presenter in place, and a run that ends after an overlapping run never puts back a presenter whose run is over. The built-in agent also reads its run's presenter in buildPrompt before the first await, so an overlapping run's opening prompt cannot pick up the other run's presenter. The screen option doc now says only e2e mcp passes a presenter, and the stale step's presenter wording is corrected to the loop run's presenter. Tests: a Promise.all of two loop runs followed by an observe on tools built afterwards, and a loop nested inside another loop's tool on the same context. The concurrent test fails on the old code (the later observe returns Screen unchanged since revision b2); the nested test fails if a run reuses the outer binding instead of binding fresh. Signed-off-by: Varshith Puli <pulivarshit@gmail.com>
|
Fixed, thanks for the catch. The per-context binding is now a stack (screen-update.ts): bind pushes a fresh presenter, the run removes its own presenter by identity in finally, and boundPresenter reads the top. A run that ends while another run is still bound leaves that run's presenter in place, and a run that ends after an overlapping run never puts back a presenter whose run is over, so tools built after both runs find no binding and get a fresh presenter. presenterFor now returns the bound top or a fresh unstored presenter. The built-in agent reads its run's presenter in buildPrompt before the first await in both the act and assertion loops (default-agent.ts), so an overlapping run's opening prompt cannot pick up the other run's presenter. openingPrompt takes the presenter as a parameter now. Tests (tool-loop-overflow.test.ts): a Promise.all of two loop runs on one context followed by an observe on tools built afterwards, and a loop nested inside another loop's tool on the same context. The concurrent test fails on the old code (the later observe returns 'Screen unchanged since revision b2'); the nested test fails if a run reuses the outer binding instead of binding fresh. Both pass with the fix. Nits: the screen option doc in primitives.ts now says only e2e mcp passes a presenter, and the 'step's presenter' wording in primitives.ts and screen-update.ts now says the loop run's presenter. The fold-scope question (every agent vs MCP only) is still yours to call, so I left that untouched. Verified: full e2e unit suite passes (221 files, 3710 tests, 6 skipped), core and e2e typecheck clean, oxlint clean on the changed files. New head: eb3d233. |
There was a problem hiding this comment.
1 issue found across 5 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/core/src/agent/default-agent.ts">
<violation number="1" location="packages/core/src/agent/default-agent.ts:85">
P2: The reordering that keeps an overlapping run's opening prompt on its own presenter has no regression test. The concurrent-run test uses custom `buildPrompt` functions, so the built-in act loop's `buildPrompt` is never exercised with two overlapping runs. Add a test with two `createBuiltInAgent` runs on one context whose `observe` resolves at different times, and check each opening prompt.</violation>
</file>
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
Requires human review: Auto-approval skipped because cubic reviewed only this push, not the earlier force-push. Comment @cubic review to review the whole pull request.
View guided diff | Re-trigger cubic
| // this context may bind its own presenter while this one waits on | ||
| // observe, and the opening prompt must read this run's, not the other | ||
| // run's. | ||
| const presenter = boundPresenter(context) ?? presenterFor(context); |
There was a problem hiding this comment.
P2: The reordering that keeps an overlapping run's opening prompt on its own presenter has no regression test. The concurrent-run test uses custom buildPrompt functions, so the built-in act loop's buildPrompt is never exercised with two overlapping runs. Add a test with two createBuiltInAgent runs on one context whose observe resolves at different times, and check each opening prompt.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/core/src/agent/default-agent.ts, line 85:
<comment>The reordering that keeps an overlapping run's opening prompt on its own presenter has no regression test. The concurrent-run test uses custom `buildPrompt` functions, so the built-in act loop's `buildPrompt` is never exercised with two overlapping runs. Add a test with two `createBuiltInAgent` runs on one context whose `observe` resolves at different times, and check each opening prompt.</comment>
<file context>
@@ -78,6 +78,11 @@ function createActLoop(options: BuiltInAgentOptions): StepExecutor {
+ // this context may bind its own presenter while this one waits on
+ // observe, and the opening prompt must read this run's, not the other
+ // run's.
+ const presenter = boundPresenter(context) ?? presenterFor(context);
// The opening look is tree-only, unless no listed interactive node
// exists at all: then the opening prompt carries a screenshot, because the tree describes a canvas, a game,
</file context>
|
CI note on head eb3d233: the only failing test job is test (24.8.0), and its single failure is unrelated to this change. It is tests/executor.test.ts, acp, preserves cancellation while waiting for the previous turn to stop, failing in the test's own temp-dir cleanup with ENOTEMPTY on /tmp/e2e-acp-test-L4wBzp (rmSync in the test cleanup at executor.test.ts:25). This PR touches only the agent loop presenter files, not packages/acp, and the same job passes on the other Node versions. The spec gate failure follows from that one job. Looks like a flaky cleanup race on the runner; a re-run should clear it. |
observeis untouched, and a truncated listing never folds.Folded line, from the new test:
Issue
Fixes #1788
Verified
Ran it locally: yes
packages/e2eunit tests for the presenter, the full unit suite, and the MCPrun_codeintegration suite withE2E_CHROMIUM_SANDBOX=0