Repository navigation
fix(agents): retain actionable text in bounded tool results - #131827
Conversation
Refs #131824. Expected-RED diagnostic baseline only; runtime behavior is unchanged.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 28, 2026, 3:10 PM ET / 19:10 UTC. ClawSweeper reviewWhat this changesThe PR routes oversized embedded-agent tool-result arrays through the shared bounded allocator so fitting diagnostic tails and later text blocks reach the next model request within the existing cap. Merge readinessKeep open for human landing: the maintainer-authored, maintainer-labeled PR fixes a current source-proven projection gap, and no blocking patch defect was found. Priority: P2 Review scores
Verification
How this fits togetherEmbedded agents turn tool output into context for the next model request. The guard bounds that transient provider-facing projection while leaving the raw in-memory tool result available to the session. flowchart LR
A[Tool output] --> B[Embedded agent guard]
B --> C[Bounded block allocator]
C --> D[Provider context]
D --> E[Next model response]
B --> F[Raw session result]
Decision needed
Why: The PR is protected by its maintainer label and author association, so this workflow must not auto-close or auto-land it. Before merge
Agent review detailsSecurityNone. PR surfaceSource -5, Tests +208. Total +203 across 4 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Land the canonical shared-allocator repair through the normal maintainer merge gates so bounded model context retains fitting actionable tool output without changing limits or stored session data. Do we have a high-confidence way to reproduce the issue? Yes for a high-confidence source-level reproduction: current main still disables important-tail preservation in the final text-only guard, and the supplied expected-red baseline targets that route. This read-only review did not execute the test suite. Is this the best way to solve the issue? Yes. Reusing the existing bounded block allocator removes the divergent flattened path instead of adding a special-case tail workaround. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against adf5c6738216. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
|
Final proof for The repair removes the parallel flattened projection path and uses the existing bounded block allocator throughout, preserving the hard cap and fitting diagnostic/short text blocks (production net−5). Independent review verified the complete before/after logs and 31 named executed source/venue identities. The Agent-loop tests use real production execution and an injected model transport/fixture tool; they do not claim a live provider, Gateway or persistent-transcript run. The latest ClawSweeper's CI/rank-up and current-main/release-comparison gaps are addressed in the updated body. Its generic storage classification is inapplicable to the actual diff: no schema, migration or store-write path changes, and raw in-memory results remain unchanged. Normal native prepare/merge gates remain; related #131824 stays open until the repair is verified on main. |
|
Merged via squash.
|
…#131827) * test(agents): reproduce diagnostic loss in context guard Refs openclaw#131824. Expected-RED diagnostic baseline only; runtime behavior is unchanged. * test(agents): extend tool-result diagnostic baseline * fix(agents): unify bounded tool-result projection * docs(agents): explain bounded content array invariant
What Problem This Solves
Related #131824. Retains actionable diagnostic tails and short later text blocks when oversized tool results are projected into the next model request. The existing capacity is unchanged; raw captured output is not rewritten.
The original guard had two projection policies. Image-bearing results used the shared bounded block allocator, while text-only results were flattened and explicitly opted out of diagnostic-tail selection. The latter could remove the information the model needed next even when it fit the existing limit.
Why This Change Was Made
Text arrays and image-bearing results now use the same canonical block allocator, including the fallback that omits non-text content too large to fit. Existing weighted cost is carried consistently through allocation, while the established semantic small-block threshold remains separate from that cost. The flattened parallel path, proportional retry loop and sole tail-preservation opt-out are removed.
This repairs longstanding divergent behavior. Stable v2026.7.1-2 already had shared diagnostic-tail preservation alongside a prefix-only guard. #117149 carried that behavior forward, not a proven introduction. The newer multi-block allocator came from #114755; it is not claimed to be that same allocator in the stable tag.
User Impact
The next model request can retain a fitting error or retry instruction without increasing context limits. Existing privacy/detail stripping, raw-result immutability, image ordering and bounded prefixes, UTF-16 handling and ordinary pass-through behavior remain covered. There are no new settings, dependencies, SDK/protocol changes or persistence semantics.
Evidence
Before repair, CI run 33188808868 / job 98909068896 executed exact merge
3062103eee28688e94d7619e1de5ee861799e4aaof diagnosticf65427029c72e99e6d65a26faba5287d473b1b01intofa68ddb2ec9e54c257ece2556c51c9c794f01851. It reported nine intended missing-text failures and 1,264 passing tests, across 68 files. All nine image controls, including the added 2,000-character description, passed. The complete 796,736-byte log has SHA256a773bdd58a829a037220512e25374050961f332407d072dd47d4f8e94528e668; independent review verified all failures and 31 exact executed source/venue identities.After repair, CI run 33195783997 / job 98933464357 executed merge
7a43b1c8795ab01342e32bd84ac6f80c652a33daofc71556cc1b301c10b33ef9226ccbbd274c07f467into267b0799b63c178e5be80122bb33d711f79e57e9. All 1,273 tests across 68 files passed, including the same nine regressions and all nine image controls. The same job also passed 16 overflow-compaction tests in two files. Its complete 505,781-byte log has SHA256288daecd8d7d572bbc62e155ed27f1771282107ff6cca324829b7a0f37d94f6f. Thirty of the 31 named executed source/venue files match the repair commit exactly; the remaining prerequisite-table change only registers an unrelated Gateway test.The cases cover ASCII, CJK, UTF-16, separate diagnostic/non-keyword text blocks, bounded/oversized non-text content, and two real Agent-loop cases. The latter execute a fixture tool through the production Agent, guard and canonical conversion, capture the second model request and inspect raw in-memory state. They use an injected model transport, not a live provider, Gateway, native tool implementation or persistent transcript. Passing complete cases now reaches the final-reply/idle/error and post-hint metadata assertions that were not reached on RED.
The earlier test-type error was corrected by carrying the same explicit 8,192 constant into fixture, guard and assertion; the repair commit's type and lint jobs passed. Its required assertion-safety ratchet did fail: one new array assertion lacked its invariant explanation. The follow-up adds only a brief comment documenting that the shared allocator preserves or maps the supplied array. It changes no executable code, type, test or baseline. The check is not weakened or bypassed.
Final head
3efc8cacaac55b90552f446dcb683013d4bbf03anow passes CI run 33198773591 / behavior job 98942972048, executed at exact mergee4ee71fa1b7c0cd7df66b53f2328a3544038c6e4into9219c92065ede2aa4cf65e38c3e87df135fdda52. The same nine regressions and all nine image controls pass: 1,273 tests in 68 files, plus the 16 overflow tests in two files. The complete 505,689-byte log has SHA2568c18f15f46bb665ecc32713beeb5ee4afa1ce3fd42ce37c050393c9b848f1644. The assertion-safety ratchet also passes. The exact-head rollup is 190 successes, 55 skips, one neutral result and two routine dispatch/labeler cancellations, with no pending or failing checks; requiredopenclaw/ci-gateis successful. Independent review bound the complete logs to 31 named executed source/venue files: 30 match the reviewed head, and the remaining prerequisite registration is the same unrelated Gateway-test entry previously examined.No local product import, build, test or install ran under the campaign resource limit. The existing secretless hosted lane is used without new jobs, environment overrides or production test seams. Fresh structured review of the complete four-file candidate found no actionable P0–P2 issues; independent review verified the exact source, complete review inputs and final before/after evidence. Normal repository-native prepare/merge gates still apply.
The latest ClawSweeper review reviewed this exact head at 18:26 UTC. Its requested exact-head checks and rank-up are now complete. Its current-main/release comparison gap was independently covered: direct comparison of the 31 named owners and venue files from the PR base to main
c8ddecdbfaae065fc0bce844d996b2a962776324found only the unrelated Gateway prerequisite entry; the stable-tag distinction is recorded above. Its generic persistent-cache-schema annotation does not describe this diff: there is no schema/version/table/migration/store-write change. The changed production paths allocate bounded in-memory model projections; context-engine ingestion/assembly hooks and persistence eligibility are untouched, and raw in-memory Agent state remains unchanged in the passing tests. No migration is introduced or needed. This PR retains ownership of the repair; no duplicate fix was dispatched.Production LOC:
+85/-90(net−5, including the invariant comment). Tests:+212/-4across two existing modules, no new line-count suppression. Release-note context: preserve fitting actionable text when final tool-result context projection truncates large output.