Repository navigation
fix: prevent context overflow during long tool turns - #189810
Merged
Merged
Conversation
Enforce hard window admission through existing provider-bound precheck recovery while retaining replay-safety gates. Co-authored-by: steipete <[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. |
roboclaw-bot
marked this pull request as ready for review
October 31, 2026 22:15
Collaborator
Author
|
Merged via squash auto-merge.
|
roboclaw-bot
added a commit
that referenced
this pull request
Nov 1, 2026
Revert e44b8f4 (#189810), which introduced unconditional provider-bound pressure checks and overflow copy changes across eight failed jobs in scheduled full CI 41252475393. Restore the previous opt-in behavior, fixtures, recovery copy and docs as one clean inverse. Real Gateway child-result tests fail before rollback, as does the runner prompt-cache integration. Accepted rollback risk: long tool turns can again overflow with the optional precheck disabled. Co-authored-by: steipete <[email protected]>
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Nov 1, 2026
* fix: prevent context overflow during long tool turns Enforce hard window admission through existing provider-bound precheck recovery while retaining replay-safety gates. Co-authored-by: steipete <[email protected]> * test: align tool fixtures with hard context admission * test: fit prefix fixture within context admission --------- Co-authored-by: steipete <[email protected]>
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Nov 1, 2026
Revert fe5a903 (openclaw#189810), which introduced unconditional provider-bound pressure checks and overflow copy changes across eight failed jobs in scheduled full CI 41252475393. Restore the previous opt-in behavior, fixtures, recovery copy and docs as one clean inverse. Real Gateway child-result tests fail before rollback, as does the runner prompt-cache integration. Accepted rollback risk: long tool turns can again overflow with the optional precheck disabled. Co-authored-by: steipete <[email protected]>
steipete
added a commit
that referenced
this pull request
Nov 1, 2026
) * fix(agents): compact long tool turns and publish current context totals Start client maintenance at 75% of the active context window while preserving provider and native compaction ownership. Check every prepared request against the hard window using nominal occupancy, calibrated tool-result estimates, and provider-measured context plus pending additions. Publish current context through the existing guarded session writer and let final ordered accounting supersede intermediate snapshots. Retire downstream mixed-counter repairs; invalidate old prompt-only freshness stamps without a schema change or new configuration. Preserve the working 32k prompt-cache fixture and repair impossible lifecycle fixture windows from the reverted admission rollout. Include red-on-parent long-turn/accounting regressions and repair the cold native-auth test setup. Related: #189810, #189891, #189888, #164551. Co-authored-by: Alex Mittell <[email protected]> Co-authored-by: Vincent Koc <[email protected]> * fix(agents): complete nominal context admission and accounting cutover * fix(agents): share lexical pricing with compaction summary fitting * test(agents): align context consumers and isolate announce state * test: await archive and steering fixture handoffs Join the database lifecycle before raw archive fixture seeding, and wait for runtime steering admission before releasing the held document request. Preserve the existing behavior assertions and allocate exact regression lines. Archive admission passes 17/17; steering passes 6/6. The CI assertions did not reproduce locally, but diagnostic probes exposed the asynchronous fixture handoffs. Fresh Codex review found no actionable findings. --------- Co-authored-by: Alex Mittell <[email protected]> Co-authored-by: Vincent Koc <[email protected]>
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Nov 2, 2026
…claw#190017) * fix(agents): compact long tool turns and publish current context totals Start client maintenance at 75% of the active context window while preserving provider and native compaction ownership. Check every prepared request against the hard window using nominal occupancy, calibrated tool-result estimates, and provider-measured context plus pending additions. Publish current context through the existing guarded session writer and let final ordered accounting supersede intermediate snapshots. Retire downstream mixed-counter repairs; invalidate old prompt-only freshness stamps without a schema change or new configuration. Preserve the working 32k prompt-cache fixture and repair impossible lifecycle fixture windows from the reverted admission rollout. Include red-on-parent long-turn/accounting regressions and repair the cold native-auth test setup. Related: openclaw#189810, openclaw#189891, openclaw#189888, openclaw#164551. Co-authored-by: Alex Mittell <[email protected]> Co-authored-by: Vincent Koc <[email protected]> * fix(agents): complete nominal context admission and accounting cutover * fix(agents): share lexical pricing with compaction summary fitting * test(agents): align context consumers and isolate announce state * test: await archive and steering fixture handoffs Join the database lifecycle before raw archive fixture seeding, and wait for runtime steering admission before releasing the held document request. Preserve the existing behavior assertions and allocate exact regression lines. Archive admission passes 17/17; steering passes 6/6. The CI assertions did not reproduce locally, but diagnostic probes exposed the asynchronous fixture handoffs. Fresh Codex review found no actionable findings. --------- Co-authored-by: Alex Mittell <[email protected]> Co-authored-by: Vincent Koc <[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.
What Problem This Solves
Long tool-heavy turns can exceed the model window before turn-end maintenance runs. In the Contributor PRs cron incident on 2026-10-31 20:28–20:30Z, request 7 reached 1,000,188 tokens against a 1,000,000-token window. The surfaced “Auto-compaction failed” label did not establish that compaction had run.
User Impact
Hard context-window admission now runs by default at provider request boundaries, using conservative projected context and the existing 20,000-token reserve floor (capped for small windows). The optional soft threshold retains its disabled default and configured reserve. Unsafe replay or unsettled tools still prevent recovery compaction; surfaced overflow messages now identify a mid-turn window overflow. Manual compaction is unchanged.
Why This Change Was Made
Lead policy decision: a request already projected beyond the model window guarantees a 400 and cannot advance the turn. Reuse the existing provider-bound estimator, boundary signal, and compaction/retry owner instead of sending that request. The recovery safety gate remains authoritative, including parked Code Mode handling.
No new compactor, configuration option, state owner, or test-line allocation. Simplification consolidated duplicated retry fixtures and removed redundant fixture casts/identity overrides. Whole-PR production delta: +4 lines; tests and case fixtures: −13 lines (ratchet-scoped tests: 0).
Evidence
75d8b08f450d: the real Responses reply/session/attempt flow sent an over-window request to the deterministic local provider (HTTP 400).git diff --checkpassed.Focused validation timings
Cold source preparation is included where reported; CI-repair rows show Vitest time (wrapper totals: 13.17s, 40.32s, 43.92s, 14.82s, 17.63s). Exact-head CI completed successfully; see the run below.
75d8b08f450d: scoped-clean, complete, no P0–P2 findings. The full review of8b534ce48ceaand a fresh scoped-clean follow-up on the final one-line prefix-fixture repair cover the published changes; reviewed inputs matched the task checkout byte for byte. The reviewer assessed unchanged estimator internals through the supplied caller contract and boundary tests; canonical generation/check independently verified the generated hash.4c776fadc9dfde8b1f0d5c846fe4a1f2be848215— CI run 41249411930.Requested by @steipete
Work sessions
Discussion, implementation and verification
Co-authored-by: steipete [email protected]