Repository navigation
fix(agents): keep the settled-turn finalizer within its budget bound - #204028
Merged
Merged
Conversation
#203536 gave every operation the fixed 16 MiB history guard, so the settled-tool finalizer stopped omitting screenshot bodies and sent 780,415 B where its 64k-window bound is 524,288 B. The finalizer answers for its turn under its own cache key, so it again stays within eight bytes per budget token and omits result bodies first. Normal attempts keep the fixed guard. Co-authored-by: obviyus <[email protected]>
Contributor
|
🦞👀 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. |
Collaborator
Author
|
Landed as 6963e4f. Bug: #203536 gave the settled-turn finalizer the fixed 16 MiB history guard, so it stopped omitting screenshot bodies (780,415 B against a 524,288 B bound). Fix: the finalizer alone again uses min(16 MiB, budget x 8) with tool-result omission; normal attempts keep the fixed guard. Proof: settled-turn-finalization.incomplete is green on 6198f78^, red on 6198f78 and main, and green here (472,487 B). The prefix journey passes on all 5 transports. |
tideclaw-bot
pushed a commit
that referenced
this pull request
Nov 24, 2026
…1766) (cherry picked from commit 9156690) Release adaptation: Keep the stable full-prefix test. Exercise in-budget and omitted tool results using stable’s 16 MiB cap; stable no longer sizes this context from contextTokenBudget. Companion audit: #204028, #203901, #202306 and #203536 are separate finalizer-budget, custody, project-transfer and context-window changes; not dependencies of the timestamp guard. Co-authored-by: RomneyDa <[email protected]>
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Nov 24, 2026
…penclaw#204028) Result: the settled-turn finalizer again builds its summary request within eight bytes per context token, so a screenshot-heavy cut-off turn sends a bounded request with the user's request in view. Scheduled `main` CI has been red on `settled-turn-finalization.incomplete.test.ts` since openclaw#203536, and this change fixes it. Normal attempts keep the openclaw#203536 behavior: all history since the latest compaction, with no per-attempt slide. ## What Problem This Solves openclaw#203536 changed `resolveEmbeddedSessionContextLimits` to a fixed 16 MiB guard for every operation. The settled-tool finalizer (openclaw#178300, openclaw#184704) also takes its bound from that owner. It answers for its turn alone under its own cache key, and it relied on the old `contextTokenBudget × 8` bound to replace screenshot bodies with short notices before it dropped the turn's request. At 16 MiB the omission never fired, so the finalizer sent every screenshot body. Measured in the failing test (10 screenshots, 64k context window, bound 524,288 B): | Build | Finalizer request | Tool-result bodies | |---|---|---| | `d67eac7f^` | 472,487 B | 4 of 10 replaced by notices (77,339 B → 429 B each) | | `d67eac7f` (openclaw#203536) | **780,415 B** | all 10 kept, 77,339 B each | | this head | 472,487 B | 4 of 10 replaced by notices | ## Why This Change Was Made - The fix is in the existing owner, `resolveEmbeddedSessionContextLimits`, which already special-cased the finalizer. For `operation: "settled-tool-finalization"`, it returns `min(16 MiB, max(1 KiB, contextTokenBudget × 8))` with `toolResultOverflow: "omit"`. Every other operation keeps the fixed 16 MiB guard. - The finalizer's cut cannot break an append-only prefix, because it is a separately keyed side request. Normal attempts, recovery and compaction reads are unchanged. - The 512 KiB test limit is unchanged. - The `attempt-history-prepare.test.ts` budget case that openclaw#203536 deleted is restored. It covers the finalizer omitting a body under a small budget. - Docs: `docs/concepts/compaction.md` names the finalizer as the one exception to the history guard. ## Evidence - `settled-turn-finalization.incomplete.test.ts`: passes on `d67eac7f^`, fails on `d67eac7f` (`expected 780415 to be less than 524288`) and fails on `main`. It passes on this head. The request sizes in the table came from a temporary per-message size log in scratch copies; the log is not committed. - openclaw#203536's prefix-journey step (screenshot chat) passes on all 5 transports on this head. - The targeted tests pass: every test file that imports `session-context-limits` or one of its callers. `pnpm check:changed` and oxfmt/oxlint pass on the changed files. ## Merge danger Two-way door. The change touches only the finalizer's bound. A revert restores the oversized finalizer request. Co-authored-by: Ayaan Zaidi <[email protected]>
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.
Result: the settled-turn finalizer again builds its summary request within eight bytes per context token, so a screenshot-heavy cut-off turn sends a bounded request with the user's request in view. Scheduled
mainCI has been red onsettled-turn-finalization.incomplete.test.tssince #203536, and this change fixes it. Normal attempts keep the #203536 behavior: all history since the latest compaction, with no per-attempt slide.What Problem This Solves
#203536 changed
resolveEmbeddedSessionContextLimitsto a fixed 16 MiB guard for every operation. The settled-tool finalizer (#178300, #184704) also takes its bound from that owner. It answers for its turn alone under its own cache key, and it relied on the oldcontextTokenBudget × 8bound to replace screenshot bodies with short notices before it dropped the turn's request. At 16 MiB the omission never fired, so the finalizer sent every screenshot body.Measured in the failing test (10 screenshots, 64k context window, bound 524,288 B):
6198f78b^6198f78b(#203536)Why This Change Was Made
resolveEmbeddedSessionContextLimits, which already special-cased the finalizer. Foroperation: "settled-tool-finalization", it returnsmin(16 MiB, max(1 KiB, contextTokenBudget × 8))withtoolResultOverflow: "omit". Every other operation keeps the fixed 16 MiB guard.attempt-history-prepare.test.tsbudget case that fix(agents): move the model-context history window only at compaction #203536 deleted is restored. It covers the finalizer omitting a body under a small budget.docs/concepts/compaction.mdnames the finalizer as the one exception to the history guard.Evidence
settled-turn-finalization.incomplete.test.ts: passes on6198f78b^, fails on6198f78b(expected 780415 to be less than 524288) and fails onmain. It passes on this head. The request sizes in the table came from a temporary per-message size log in scratch copies; the log is not committed.session-context-limitsor one of its callers.pnpm check:changedand oxfmt/oxlint pass on the changed files.Merge danger
Two-way door. The change touches only the finalizer's bound. A revert restores the oversized finalizer request.