Skip to content

fix(agents): compact long tool turns and refresh context totals - #190017

Merged
steipete merged 5 commits into
mainfrom
steipete/perf-micro-auto-compaction-not-triggering-stale-total-tokens-20260919
Nov 1, 2026
Merged

steipete merged 5 commits into
mainfrom
steipete/perf-micro-auto-compaction-not-triggering-stale-total-tokens-20260919

Conversation

@steipete

@steipete steipete commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Long embedded tool loops could fill a 1M context window before auto-compaction, while sessions.list continued showing the previous turn's token count. The threshold was 980,000 tokens, fresh usage stayed in memory until the whole run settled, and the mid-turn admission check was disabled by default.

User Impact

Built-in client maintenance now starts by 75% of the active window. Provider-owned compaction and native runtime policies retain ownership. Every prepared embedded request is checked against the hard window, including the first request. Context totals refresh during tool loops from the request owner's measured context plus pending content, and final settlement supersedes its own intermediate observations.

Older prompt-only snapshots become unknown until refreshed. No configuration option, SQLite schema change, or new cache is introduced.

Why This Change Was Made

The provider boundary makes and publishes one pressure decision through the existing keyed writer. Downstream transcript rescans and mixed-counter repairs are removed. Ordinary tool text no longer receives a blanket two-characters-per-token penalty; encoded data, numeric groups, and JSON delimiters retain content-sensitive sizing. Hard admission and context-engine assembly use nominal occupancy, while compaction planning retains its safety margin. Summary fitting and request admission share the same lexical estimator, so fitted summaries retain metadata without exceeding the final request budget.

This repairs the false positives behind the reverted default guard: the existing 32k prompt-cache fixture remains unchanged. Synthetic host budgets too small to reach their intended tool boundary now match their existing model windows, with behavioral assertions preserved. The cold native-auth fixture also awaits its existing preparation owner; its setup failure reproduces on the exact parent and was introduced by #169580.

Related: #189810, #189891, #189888, #164551. Thanks @amittell for the ordered final-context snapshot precedent and @vincentkoc for the realistic lifecycle fixture budget. This change covers the accounting overlap with #164551 together with admission and threshold ownership.

Evidence

  • The production-path 1M HTTP regression fails on the exact parent and passes with the fix: persisted growth during a long tool turn, one compaction before 80%, no over-window request, and a successful next turn. Boundary/guard checks pass 33/33; threshold/consumer checks 116/116; provider-compaction ownership checks 23/23.
  • The final local replay passes all 49 affected cases across the 12 files representing the eight reverted CI jobs, plus five nested reload scenarios. All four 32k prompt-cache cases pass unchanged. The first PR head's ten failed node jobs were treated as PR-caused: nominal-unit assembly and context labels were completed, prompt-only expectations and conflicting fixture mocks corrected, and the affected local replays pass (107 accounting cases, 174 additional consumers, and eight selected repair cases).
  • Shared-fixture replays pass 245/245 across four suites and 319/319 across the cron harness consumers and real fallback suite. All six selected native ownership cases pass. Codex review of the complete change and final repair completed with no actionable P0–P2 findings.
  • Live OpenAI production transport completed a tool continuation. Independent counts cover prose, code, dense hex, CJK, short-key JSON, and the complete prompt-cache request. JSON exposed an undercount (26,806 actual versus 16,389 projected); the regression now projects 30,605 and blocks a 20k window. The full prompt-cache control counts 13,974 versus 28,620 projected. This is bounded calibration, not a universal tokenizer guarantee or a live 1M compaction test. Anthropic validation was unavailable because the test account had insufficient credits.
  • Five alternating pressure-owner benchmark pairs on 720 history messages plus 65k pending text: prose CPU 1.544→1.017 ms/op and sampled allocation 970,218→2,953 B/op; JSON CPU 1.214→0.978 ms/op and allocation 964,401→687,222 B/op. A/A median CPU drift was −0.54% (range −1.83% to +0.54%). These compare the existing estimator; enabling default admission adds approximately 1 ms of estimator CPU per request on this fixture. On a clean synthetic 40.286 GiB database with 5,000 session rows and 62,000 workspace files, publication performs exactly one keyed patch per request: median p50 1.983 ms, main-thread CPU 1.078 ms, sampled main-thread allocation 358,624 B/write. Session count and activity are preserved. Worker allocation was not measured; APFS does not prove btrfs behavior. The fixture has 227,312 events across 1,311 populated transcripts.
  • The next CI head exposed four stale request-budget prices and two compaction failures caused by the summary fitter still using prose-only pricing. The shared-owner repair adds no production lines, preserves fixture windows, and passes all 49 affected cases across request budgets, small-context compaction, prepared prompts, and prompt-cache behavior. Core/normalization/safeguard tests pass 65/65; the 33 boundary checks pass again. Codex review, targeted lint, and types are green. Full changed-file checks pass for this repair. Exact-head PR CI remains the broad landing gate.

Runtime delta: +38 lines; regression/test-support delta: +425; reusable benchmark tooling: +412. Runtime growth supplies durable request-boundary publication and ordered settlement after deleting downstream repair machinery. All benchmark data is synthetic.

CI on the merged-main context also exposed an inherited browser import regression from #189973 (31866655fd60): media-facts.ts imports the Node-only transcript clone used by browser attachment/history views. All three UI-job signatures reproduce on exact CI main parent c2a39e4c5a8166d1f5ea6703d1dfaa7d7c45de79, including the nested mock error. The same failure was independently requalified on the next actual CI main parent c32d920dab6bcb2eb55251bc71665816bb04f809. This is a main regression requiring follow-up, not a passing check. The six failed UI E2E shards reproduce the same handled Navigation/app-start failure on that exact parent, including routes without console errors; modal details name node:util/types.isProxy. The final node-consumer repairs pass 41 gateway/announcement tests and all eleven message-buffer scenarios. The latter fixture now declares 32k after its request owner projected 22,180 against 16k, preserving output budget and behavioral assertions. Announcement fixtures also use their own temporary database instead of shared /tmp state; no shared database was modified. Final exact-head run 41275996117 is complete on 5a98db434bd1aef415a53ea1863da891a767afd3: 120 jobs passed, 21 skipped, and 11 failed (nine inherited UI jobs, the inherited Goal fixture, and the aggregate). All PostgreSQL shards, security-fast, and repaired fixture/ratchet jobs passed. A final fixture-only repair joins archive maintenance before raw seeding (17/17 tests pass) and waits for the existing steering admission receipt before releasing the provider (6/6 pass). The original CI assertions did not reproduce locally; source inspection and diagnostic probes confirmed the unjoined asynchronous work. No production change or weakened assertion was added. Fresh Codex review is scoped-clean, and full pnpm check:changed --base 76fb0e371acd4e7e5d12a05e4b3f235c5a5a40ec passed. The native landing evidence retains the failed checks and exact-main attribution.

Exact-head qualification now uses actual CI main parent 9009dbdae33cf32eebfb3418793518018d9932f0; browser import and real-app failures reproduce there too. A newly observed Goal authority test failure is also inherited from #183706 (9e86c84aada4): its final silence assertion contradicts documented own-session read access after a fresh read-only connection. The unchanged case passes locally on both heads; on exact main, test-only real reconnect/role/history synchronization reproduces the original assertion with a new admin-injected message. Revoked-run cancellation, tool fencing, and history assertions pass. This is a main fixture defect requiring follow-up, not a production permission regression. No production authority change is included. Every failed job is accounted for against the actual tested main parent. Landing uses the authorized native inherited-failure exception; failed CI is not claimed green.

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]>
@clawsweeper

clawsweeper Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts commands Command implementations agents Agent runtime and tooling size: XL labels Nov 1, 2026
@steipete
steipete marked this pull request as ready for review November 1, 2026 03:08
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T05:15:21.844439Z 5a98db4 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 1, 2026
@clawsweeper

clawsweeper Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

Starts client compaction earlier, checks every embedded request against its context window, and publishes current context totals during tool loops.

Example: An embedded tool loop uses a 1,000,000-token context window with a 20,000-token reserve.

  • Before: Client maintenance starts near 980,000 tokens, while session totals can remain unchanged throughout the turn.
  • After: Client maintenance starts at 750,000 tokens, and prepared requests publish updated context occupancy.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The product repair and production-path regression are useful, but confirmed consumer failures and unverified upgrade compatibility prevent readiness.
Proof confidence 🦐 gold shrimp (3/6) The maintainer-authored ordinary proof exemption applies; the inspected HTTP regression exercises the production request, recovery, and persistence owners, but the persisted freshness-version and default changes still require a latest-stable upgrade demonstration.
Patch quality 🦪 silver shellfish (2/6) 4 actionable review findings remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Long tool turns can overflow the model window while session displays continue showing the previous context total.
Reason: The reported failure has a concrete source path and production-path regression, and the maintainer-authored PR records approval of the earlier threshold and default admission direction.

Merge readiness

⛔ Blocked before merge - 5 items remain

Keep this PR open: it addresses a concrete long-turn failure, but the consumer cutover is incomplete and introduces confirmed CI failures.

Priority: P2
Reviewed head: b91ac9cce500753be5ad40e1ea3769323e34396f

Before merge

  • Intercept the runner binding actually consumed by cron fixtures (P2) - The adapter now imports runEmbeddedAgent from agents/embedded-agent.js, while this harness intercepts embedded-agent-runner/run.js. isolated-agent.mocks.ts independently mocks the former module, so session-identity cases bypass runEmbeddedAgentMock and receive the generic result instead. CI job 124735020729 confirms zero expected calls, undefined captured requests, and sessionId 's' replacing the rotated identity. Consolidate the mock at the consumed boundary while keeping the cron accounting adapter real.
  • Migrate remaining accounting consumers to context occupancy (P2) - The helper now includes completion tokens, but several consumer suites still require prompt-only totals. For example, session-transcript-derived-readers.usage.test.ts expects 400 after a response with 400 prompt and 10 output tokens, and status.test.ts expects 36k for a 36k prompt plus 1k output. CI also confirms stale expectations in result-accounting persistence, recovery-cancellation accounting, and embedded-maintenance accounting. Update those consumers to the new independently calculated totals and authoritative-zero contract, preserving their persistence and lifecycle assertions.
  • Complete the context-pressure fixture and budget cutover (P2) - The earlier threshold, nominal admission units, and first-request guard change existing fixture contracts without updating all consumers. Reviewed-head CI reports setup.test.ts receiving 654000 where it expects 852000, six context-advancement budget mismatches, replay pressure of 3000 against the old >3500 assertion, and tight-budget guard assertions that now fit. The tool-search denial and Code Mode continuation cases also stop before completing their intended scenarios. Update budgets and pressure expectations from the changed owners, give lifecycle fixtures sufficient context, and retain explicit rejection, cancellation, tool execution, and full-window boundary assertions.
  • Update announcement stats to label the new context total (P3) - The changed test expects 'tokens 500 context', but buildCompactAnnounceStatsLine still emits 'tokens 500 prompt/cache' and uses the same obsolete label when directional usage exists. Version-2 totals now include completion occupancy, so the announcement mislabels the value while the shared subagent formatter correctly calls it context. Update both announcement branches; CI job 124735020732 reproduces the exact mismatch.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

  • [P2] Intercept the runner binding actually consumed by cron fixtures — src/cron/isolated-agent/run.test-harness.ts:323-325
  • [P2] Migrate remaining accounting consumers to context occupancy — src/agents/usage.ts:453-460
  • [P2] Complete the context-pressure fixture and budget cutover — src/agents/embedded-agent-runner/run/attempt-stream.ts:479-484

Tests

  • Missing end-to-end proof: No latest-stable upgrade is demonstrated with existing configuration, transcripts, Goal state, version-1 totals, and subsequent version-2 refresh intact.
Agent review details

How this fits together

The embedded request boundary receives prepared conversation content and provider usage, decides context pressure, and publishes occupancy through the existing session writer for maintenance and status readers.

flowchart LR
Conversation[Prepared conversation] --> Boundary[Embedded request boundary]
Usage[Provider usage] --> Boundary
Boundary --> Recovery[Existing compaction recovery]
Boundary --> Provider[Provider transport]
Boundary --> Writer[Guarded session writer]
Writer --> Readers[Session and status readers]
Loading

Technical review

Best possible solution:

Complete the existing request-boundary and session-writer cutover, repair affected consumer fixtures without weakening their contracts, and demonstrate the persisted-state upgrade.

Do we have a high-confidence way to reproduce the issue?

Current-main source shows default-disabled mid-turn admission and completion-delayed publication; the supplied production-path regression targets both, but no target code was executed during this read-only review.

Is this the best way to solve the issue?

The existing pressure owner, recovery path, and keyed writer are the right boundaries, and the added publisher and shared threshold are justified; remaining consumers must adopt the changed contracts together.

Full review comments:

  • [P2] Intercept the runner binding actually consumed by cron fixtures — src/cron/isolated-agent/run.test-harness.ts:323-325
    The adapter now imports runEmbeddedAgent from agents/embedded-agent.js, while this harness intercepts embedded-agent-runner/run.js. isolated-agent.mocks.ts independently mocks the former module, so session-identity cases bypass runEmbeddedAgentMock and receive the generic result instead. CI job 124735020729 confirms zero expected calls, undefined captured requests, and sessionId 's' replacing the rotated identity. Consolidate the mock at the consumed boundary while keeping the cron accounting adapter real.
    Confidence: 0.99
  • [P2] Migrate remaining accounting consumers to context occupancy — src/agents/usage.ts:453-460
    The helper now includes completion tokens, but several consumer suites still require prompt-only totals. For example, session-transcript-derived-readers.usage.test.ts expects 400 after a response with 400 prompt and 10 output tokens, and status.test.ts expects 36k for a 36k prompt plus 1k output. CI also confirms stale expectations in result-accounting persistence, recovery-cancellation accounting, and embedded-maintenance accounting. Update those consumers to the new independently calculated totals and authoritative-zero contract, preserving their persistence and lifecycle assertions.
    Confidence: 0.99
  • [P2] Complete the context-pressure fixture and budget cutover — src/agents/embedded-agent-runner/run/attempt-stream.ts:479-484
    The earlier threshold, nominal admission units, and first-request guard change existing fixture contracts without updating all consumers. Reviewed-head CI reports setup.test.ts receiving 654000 where it expects 852000, six context-advancement budget mismatches, replay pressure of 3000 against the old >3500 assertion, and tight-budget guard assertions that now fit. The tool-search denial and Code Mode continuation cases also stop before completing their intended scenarios. Update budgets and pressure expectations from the changed owners, give lifecycle fixtures sufficient context, and retain explicit rejection, cancellation, tool execution, and full-window boundary assertions.
    Confidence: 0.96
  • [P3] Update announcement stats to label the new context total — src/agents/subagents/announce/subagent-announce-output.test.ts:193-194
    The changed test expects 'tokens 500 context', but buildCompactAnnounceStatsLine still emits 'tokens 500 prompt/cache' and uses the same obsolete label when directional usage exists. Version-2 totals now include completion occupancy, so the announcement mislabels the value while the shared subagent formatter correctly calls it context. Update both announcement branches; CI job 124735020732 reproduces the exact mismatch.
    Confidence: 1

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 0e24b7e5953e.

Provenance checked

  • Default hard context admission changes intended behavior with a stated reason (ffbaf04: The rollback restored working turns after conservative estimates caused eight CI jobs to fail and explicitly deferred overflow prevention to a forward fix.)
  • Context-pressure estimation and output headroom changes intended behavior with a stated reason (66d6c28: Matching provider usage preserves output headroom while unmatched requests retain estimation; this PR explains separating nominal hard admission from maintenance safety margins.)
  • Versioned context freshness keeps the original intent (fix(sessions): require provenance for fresh context-size facts #120497: Versioned provenance prevents cumulative billing counters from becoming trusted context snapshots and triggering premature compaction.)
  • Compaction threshold and request-budget ownership changes intended behavior with a stated reason (60adac1: Compaction budgets include the complete foreground request and preserve native-runtime ownership; this PR retains those owners while explicitly starting client maintenance earlier.)
  • Ordered final accounting keeps the original intent (fa6b02a: Committed compaction facts stay bound to the original session writer; final settlement now supersedes that writer's intermediate occupancy observations.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test src/cron/isolated-agent.session-identity.test.ts src/cron/isolated-agent/run.retry-failure-usage.test.ts src/cron/isolated-agent/run-session-state.test.ts --run --maxWorkers=1
  • pnpm test src/gateway/session-transcript-derived-readers.usage.test.ts src/auto-reply/status.test.ts src/auto-reply/reply/agent-runner-result-accounting.persistence.test.ts src/agents/agent-command.embedded-maintenance.test.ts --run --maxWorkers=1
  • pnpm test src/agents/embedded-agent-runner/run/setup.test.ts src/agents/embedded-agent-runner/run/attempt-context-advancement.test.ts src/agents/embedded-agent-runner/run/preemptive-compaction.replay.test.ts src/agents/embedded-agent-runner/tool-result-context-guard.test.ts --run --maxWorkers=1
  • pnpm test src/agents/embedded-agent-runner/run/attempt.tool-search-catalog-abort.test.ts src/agents/embedded-agent-runner/run/attempt.code-mode-continuation.test.ts src/agents/subagents/announce/subagent-announce-output.test.ts --run --maxWorkers=1
  • pnpm test src/auto-reply/reply/agent-runner-compaction-fallback.test.ts src/agents/agent-tools.prefix-stability.test.ts --run --maxWorkers=1

What I checked:

  • Introduced patch verified: Reviewed the merge-base-to-head changes rather than attributing endpoint drift to this PR; the checkout remained clean. (b91ac9cce500)
  • Current-main failure path: Fetched main still skips the boundary precheck when no context engine owns compaction and midTurnPrecheck is disabled; this PR removes that bypass and checks the first request too. (src/agents/embedded-agent-runner/run/attempt-setup.ts:435, 0e24b7e5953e)
  • Rollback rationale inspected: revert: default hard context admission (#189810) #189891 deliberately restored opt-in checks after conservative admission broke working turns, explicitly leaving long-loop overflow for a forward fix; this PR explains its estimator correction and preserves the 32k prompt-cache control. (ffbaf04726a5)
  • Confirmed consumer failures: The reviewed head's CI reports failures in transcript totals, result-accounting persistence, status fallback, maintenance accounting, cancellation accounting, announcement wording, cron identity tests, context budgets, replay pressure, and tool-loop fixtures. (b91ac9cce500)
  • Cron failure attribution: CI annotations show the shared runner mock receiving zero calls and generic sessionId 's' replacing scenario-specific identities; the new adapter imports embedded-agent.js while the changed harness intercepts the deeper run.js module. (src/cron/isolated-agent/run.test-harness.ts:323, b91ac9cce500)
  • Production-path regression inspected: The long-loop regression uses real reply, session, attempt, HTTP transport, tool execution, and persistence owners against a deterministic local provider; it asserts mid-turn growth, compaction before 80%, no oversized submission, and a successful next turn. (src/auto-reply/reply/agent-runner-compaction-fallback.test.ts:34, b91ac9cce500)

PR surface

PR surface statistics unavailable: the file list is incomplete.

Labels

Label changes:

  • add P2: This repairs context overflow and stale session reporting during long embedded tool turns; the confirmed remaining defects are focused consumer-cutover failures.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: This repairs context overflow and stale session reporting during long embedded tool turns; the confirmed remaining defects are focused consumer-cutover failures.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 31, 2026, 11:27 PM ET / November 1, 2026, 03:27 UTC.

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.
@steipete
steipete merged commit e0ed68c into main Nov 1, 2026
219 of 232 checks passed
@steipete
steipete deleted the steipete/perf-micro-auto-compaction-not-triggering-stale-total-tokens-20260919 branch November 1, 2026 05:44
@steipete

steipete commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

steipete added a commit that referenced this pull request Nov 1, 2026
)

* fix(sessions): bound active accounting without blocking writers

Reuse committed actor totals for incomplete transcript replicas and match carried accounting to the reader's native snapshot. Remove the writer reservation and the whole-history usage retry; missing anchors use bounded runtime context.

Builds on #190161 after #190017. Add real-worker no-rescan and snapshot-coherence regressions plus synthetic accounting/write-latency measurement tooling. Production source is net -10 lines; no schema or config changes.

* test(perf): measure accounting through the input actor

Keep the generic persistence fallback as a separate control. Exercise the Gateway input actor binding and committed postimages for incremental byte accounting, with exact session identity and explicit actor cleanup.
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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 2, 2026
…claw#190182)

* fix(sessions): bound active accounting without blocking writers

Reuse committed actor totals for incomplete transcript replicas and match carried accounting to the reader's native snapshot. Remove the writer reservation and the whole-history usage retry; missing anchors use bounded runtime context.

Builds on openclaw#190161 after openclaw#190017. Add real-worker no-rescan and snapshot-coherence regressions plus synthetic accounting/write-latency measurement tooling. Production source is net -10 lines; no schema or config changes.

* test(perf): measure accounting through the input actor

Keep the generic persistence fallback as a separate control. Exercise the Gateway input actor binding and committed postimages for incremental byte accounting, with exact session identity and explicit actor cleanup.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. scripts Repository scripts size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant