Repository navigation
perf(agents): reduce repeated tool-result budgeting - #139156
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 5, 2026, 10:56 AM ET / 14:56 UTC. ClawSweeper reviewWhat this changesThe PR reuses tool-output size measurements during prompt preparation and compaction planning, reducing repeated text scans. Merge readiness✅ Ready for maintainer review Keep open: this is a useful optimization not present on inspected main. No actionable correctness or security findings were found. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw budgets tool outputs before sending conversation history to a model and when deciding whether truncation can avoid compaction. This planner produces bounded messages and estimates how much context can be recovered. flowchart TD
A[Conversation history] --> B[Measure tool outputs]
B --> C[Apply per-result limits]
C --> D[Apply aggregate budget]
D --> E[Bounded model history]
D --> F[Recovery estimates]
F --> G[Truncate or compact]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +33. Total +33 across 1 file. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep measurement ownership inside the synchronous planner while preserving message shapes, frozen projections, spill references, and recovery accounting. Do we have a high-confidence way to reproduce the issue? Yes, for the performance premise: current main visibly repeats text budgeting, and the supplied body specifies a concrete CJK benchmark fixture; no benchmark was executed during this review. Is this the best way to solve the issue? Yes. The shared planner is the appropriate owner; the neighboring context estimator counts different content, and cross-call caching would introduce unnecessary mutation invalidation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 951074675a44. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
What Problem This Solves
Tool-heavy histories spend unnecessary synchronous work preparing prompts and estimating whether tool-result truncation can avoid compaction. Even when every result fits, the same text is measured twice during projection and three times during reduction estimation.
Why This Change Was Made
The replacement planner now measures each input once and carries that fact through its oversized and aggregate phases. Producers measure replacement messages once; application consumes those measurements. The reduction estimator reuses the planner's original totals.
Measurements are private to one synchronous plan. Returned messages, replacement descriptors, projection state, truncation policies and persisted data retain their existing shapes and behavior. This avoids a cache attached to mutable messages or shared across calls. Production delta: +94/-61 (net +33), for the explicit measurement ownership and boundary conversion; tests are unchanged.
User Impact
Less CPU work during tool-result projection and recovery planning, particularly for CJK-heavy results. Truncation output, frozen prompt prefixes, trailing-result protection, spill references and recovery counters are preserved.
Evidence
"漢字カナ한글".repeat(1500), with 64,000 per-result and 2,000,000 aggregate budgets. These are local synthetic measurements of the uninstrumented owner with explicit dormant-import adapters, not production latency. Peak process RSS across the runs was 114,352 → 113,936 KiB.git diff --checkpass. The complete required changed check passes on the isolated Linux source bundle (12m57s), and exact-head CI 33972991872 is green. Native preparation also passes.No permanent private-helper spy or wall-clock assertion was added; the retained failing diagnostic and before/after benchmark prove the performance premise, while existing public-boundary suites protect behavior.
The completed ClawSweeper review was read in full: no findings, no pre-merge requirements, and no Rank-up moves to apply.