Repository navigation
fix(tools): release terminal summaries after nested calls settle - #135398
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed September 1, 2026, 7:37 PM ET / 23:37 UTC. ClawSweeper reviewWhat this changesThe branch separates terminal-summary formatting from retained Tool Search state so nested calls publish their final accepted result, failures clear stale summaries, and cancelled late completions do not retain observers. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessKeep open. This maintainer-authored PR repairs a source-confirmed tool-lifecycle defect with focused owner-boundary coverage; it is not merged or subsumed by the fetched main commit, while exact-head CI is still incomplete. Priority: P2 Review scores
Verification
How this fits togetherAgent tools emit raw outcome observations while executing, and Tool Search may accept, replace, or reject those results before presenting the settled outcome. This change keeps terminal summaries aligned with that final acceptance boundary and releases retained per-call state. flowchart LR
A[Agent tool call] --> B[Before-call wrapper]
B --> C[Raw outcome observation]
C --> D[Tool Search result acceptance]
D --> E[Terminal-summary finalizer]
E --> F[Observer presentation]
D --> G[Cancelled or failed cleanup]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +13, Tests +255. Total +268 across 5 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the focused lifecycle repair after the exact-head required checks pass, keeping final summary publication solely at Tool Search result acceptance. Do we have a high-confidence way to reproduce the issue? Yes—source establishes that the base path unconditionally clones observed plain-tool execution parameters after successful execution; the added integration case supplies the private callback shape that makes this fail. Is this the best way to solve the issue? Yes. Deferring only the presentation projection and storing it at the Tool Search acceptance owner fixes success, replacement, failure, and cancellation without changing tool, configuration, protocol, or persistence contracts. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 50f7f06d8ba3. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
6a8b45b to
71f61fe
Compare
Prepare isolated formatter inputs only for tools that use them. Plain tools retain only the observer metadata needed to clear older terminal summaries, so private uncloneable execution parameters cannot fail completed calls. Consume nested Tool Search presentations after final result acceptance and prevent late publication after cancellation. Preserve raw outcome recording, result middleware, formatter bounds and model-call ordinal ordering.
71f61fe to
b9f7069
Compare
|
Fresh retained-memory proof for the unchanged implementation on this head: the probe loads 29 hashed production modules and exercises 256 calls with distinct 128-KiB payloads. The compared owner code is from
These are the matched snapshot-instrumented pair. Two further pairs without snapshots are recorded separately and show the same release behavior. The snapshots trace 256 payload strings through the real pending-presentation map before the repair and zero afterward: 33,558,528 bytes of aggregate string self-size, not dominator retained size. Explicit baseline cleanup releases those strings too, confirming the lifetime owner. Unnecessary terminal argument clones fall from 256 to zero; all 256 required replay clones remain. Four lifecycle controls fail before and pass after: accepted-result replacement, rejection after raw success, late completion after abort, and private uncloneable plain-tool arguments. All 12 successful probe children exit and their private state is removed. A separate reviewer checked the raw measurements, snapshot nodes, representative retainer edges, source/compiled hashes, paired outcomes and cleanup. The initial probe setup failure is retained and excluded. This deliberately amplified synthetic owner workload uses explicit fixtures at unrelated boundaries. It does not measure ordinary per-session memory, whole-Gateway RSS or vendor execution. The earlier real embedded/native OpenAI web/read evidence remains separate. The ClawSweeper rank-up request is satisfied: exact-head CI passed for |
|
Merged via squash.
|
…nclaw#135398) * fix(agents): release terminal presentation state with tool calls Prepare isolated formatter inputs only for tools that use them. Plain tools retain only the observer metadata needed to clear older terminal summaries, so private uncloneable execution parameters cannot fail completed calls. Consume nested Tool Search presentations after final result acceptance and prevent late publication after cancellation. Preserve raw outcome recording, result middleware, formatter bounds and model-call ordinal ordering. * fix(agents): complete rejected tool cleanup result * test: use complete catalog tool execution signature
What Problem This Solves
Fixes an issue where a completed tool could fail while recording its terminal summary when private execution arguments could not be cloned. Completed nested Tool Search calls also retained their terminal observer, keeping run state reachable after settlement. Cancellation could finish cleanup before a slow tool returned and registered more retained state.
Why This Change Was Made
Prepare terminal formatting once, snapshot arguments only when a formatter needs them, and retain only the observer metadata required to clear an older summary for plain tools. Publish after raw observation succeeds; consume the record at Tool Search's final result-acceptance boundary; prevent late publication after abort. Raw outcome recording, middleware results, redaction, text bounds and model-call ordering remain intact.
User Impact
Plain tools complete successfully with private uncloneable arguments, and completed or cancelled nested calls release terminal presentation state. Later plain or failed calls clear older summaries without an out-of-order completion restoring stale text.
Evidence
DataCloneErrorafter tool execution. The candidate passes all 75 before-tool-call integration cases.openai/gpt-5.6-luna: the embedded runtime executed an HTTP-200web_fetchfollowed by a successful filereadwithin one Code Mode call; native Codex executed the same two tools directly. Durable history verifies the selected runtime, paired results, execution order and final response marker. Both Gateways exited cleanly. An earlier probe supplied an ambiguous test-file location and failed; it is excluded, and the successful probes specify the exact synthetic path.Production: +93/-80, net +13 lines. Tests: +265/-18, net +247. The additional production lines establish the missing success/error/cancellation cleanup boundary; the obsolete unconditional snapshot and executable-tool retention paths are removed. No public protocol, configuration, dependency or persistence surface changes.
CI follow-up: hosted typechecking caught a missing required
detailsfield on the empty error-cleanup result. The field is now explicit; core typechecking and all 148 Tool Search tests pass after the correction. It is ignored on the error branch and does not change terminal behavior. Fresh exact-head CI is required.