Skip to content

fix(control-ui): measure context usage against the effective token budget - #138666

Merged
steipete merged 7 commits into
openclaw:mainfrom
DasX:fix/context-usage-effective-budget
Sep 7, 2026
Merged

steipete merged 7 commits into
openclaw:mainfrom
DasX:fix/context-usage-effective-budget

Conversation

@DasX

@DasX DasX commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Closes #138590

What Problem This Solves

Fixes an issue where the Control UI context meter can show comfortable remaining capacity while a local model is close to its effective prompt budget. The composer, sessions meter, session detail, and /usage used the context window rather than the reserve-adjusted budget recorded by the last run.

Why This Change Was Made

Gateway now publishes a saved prompt budget only when its session, canonical model/provider, and effective context cap still match. Changing a context-window selection clears derived cap and budget telemetry; live session events carry an explicit null when the saved budget is no longer applicable.

The four UI displays share a small resolver that uses the validated last-run prompt budget and otherwise falls back to current context capacity. The label says “Prompt budget (last run)”: exceeding it can trigger tool-result truncation or compaction, so it is not an exact promise of when compaction runs. The browser does not reconstruct runtime reserve policy.

User Impact

All four displays use the same denominator, and changing a model or context limit cannot leave an old prompt budget presented as current. A valid narrower runtime budget remains usable. Approximate token totals retain their existing non-warning presentation. Older or unbound snapshots fall back to context capacity until a matching run refreshes them.

Evidence

  • 584 focused tests passed across Gateway provenance/mutations/events and the four UI consumers. The context-budget patch remains identical after integrating main repairs test(ui): wait for the lazy native menu before asserting its trigger #141533 and fix(qa): restore Gateway credential scenario selection #141555. CI covers the subsequent generator-syntax correction and main integration; remote formatting and static whitespace checks pass.
  • Independent review is complete; no accepted/actionable findings remain.
  • The isolated full changed-code gate could not finish because its proof checkout had incomplete Git objects and stalled lazy hydration. Final required validation passed in exact-head CI; this is not a local gate-pass claim. A previously documented abort-fixture temporary-directory cleanup failure required one unchanged-job rerun, which passed; the original failure remains visible in the run history.
  • The original UI fails the new denominator assertions. With matching runtime provenance established, the original context-window owner also fails the 32K→128K regression: the row remains at 32K. The candidate passes both widening and narrowing.
  • Real Chromium 151.0.7922.34 with a synthetic mocked Gateway on sanitized direct AWS: composer and sessions displays change from 160k/200k (80%) to 160k/180k (89%). Live sessions.changed clears the old budget and shows the changed cap without a manual refresh.
  • These are browser/Gateway boundary tests, not local-model inference or native desktop tests. The provider runtime itself is unchanged.
Surface Before After
Composer Before composer After composer
Sessions Before sessions After sessions

Maintainer completion of @DasX’s existing PR; thanks to Peik S. for the original report-driven implementation and coverage. The contributor history is preserved.

Compatibility

The persisted session schema and context settings are unchanged. Saved diagnostics that lack matching provenance remain stored but are not presented as current; the UI falls back to context capacity until the next run. Context-window changes clear existing derived telemetry through the mutation owner, matching model-switch invalidation. The existing session-event contract permits these fields, and the existing reconciliation path removes explicit null tombstones. No database migration, configuration option, or protocol version change is required.

@clawsweeper

clawsweeper Bot commented Sep 4, 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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 4, 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-09-04T22:21:23.505989Z be5399f PR opened
🔒 Security Review ✅ Completed 2026-09-04T22:23:04.066102Z be5399f PR opened
ℹ️ 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: be5399ff39

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread ui/src/lib/sessions/context-budget.ts Resolved
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 4, 2026
@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 7, 2026, 5:19 PM ET / 21:19 UTC.

ClawSweeper review

What this changes

The Control UI measures context usage against a validated last-run prompt budget and clears obsolete budget estimates when session selections change.

Merge readiness

✅ Ready for maintainer review

This remains a useful fix for the linked issue. The earlier denominator, stale-budget, and labeling findings are addressed; no blocking defect was found in the current patch.

Priority: P2
Reviewed head: 47f32b96c63734e53fdd091bf58e3277c90a0f76

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with meaningful regression coverage, sufficient browser evidence, and no remaining actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Supplied Chromium observations exercise the changed UI consumers and sessions.changed invalidation with a synthetic Gateway, showing 80% becoming 89% and obsolete budgets clearing live. Focused Gateway regressions supplement this evidence; independent image retrieval was unavailable, as addressed in the later inspection comment.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): Supplied Chromium observations exercise the changed UI consumers and sessions.changed invalidation with a synthetic Gateway, showing 80% becoming 89% and obsolete budgets clearing live. Focused Gateway regressions supplement this evidence; independent image retrieval was unavailable, as addressed in the later inspection comment.
Evidence reviewed 8 items Still necessary on main and latest release: Both fetched main and the supplied latest-release commit still divide composer usage by contextTokens without consulting the reserve-adjusted prompt budget.
Prior provenance findings resolved: Gateway rejects saved budgets with mismatched provider, model, session identity, effective cap, or pending model switches. Context-window mutations clear derived telemetry, and the shared UI resolver uses the validated prompt budget.
Runtime owns the denominator: OpenClaw's pre-prompt implementation derives promptBudgetBeforeReserve by subtracting the effective reserve and records that value in session telemetry. Overflow can select tool-result reduction or compaction, supporting the revised last-run estimate wording. This contract is owned by OpenClaw source; no Codex dependency signal applies.
Findings None None.
Security None None.

How this fits together

The agent runtime records prompt-budget estimates in session telemetry. Gateway validates that telemetry before sending it to the Control UI, which uses it for context meters, session details, and usage output.

flowchart LR
  A[Runtime budget estimate] --> C[Gateway session projection]
  B[Current model and context cap] --> C
  C --> D{Estimate still matches?}
  D -->|Yes| E[Last-run prompt budget]
  D -->|No| F[Current context capacity]
  E --> G[Control UI usage displays]
  F --> G
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +85, Tests +320, Docs +8. Total +413 across 22 files.

View PR surface stats
Area Files Added Removed Net
Source 11 107 22 +85
Tests 10 323 3 +320
Docs 1 8 0 +8
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 22 438 25 +413

Review metrics

Metric Value Why it matters
Production versus regression coverage production +85 net lines; tests and support +320 Production growth provides shared budget selection and lifecycle validation; regression coverage checks cap changes, invalidation, and all four consumers.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #138590
Summary: This PR is the explicit implementation candidate for the reported context-meter denominator defect.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep budget validation in Gateway and share its last-run estimate across UI displays, preserving capacity fallback and approximate-usage behavior.

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

Yes, source establishes the denominator mismatch: a 160k session with 200k capacity and a 180k prompt budget displays 80% on main instead of 89%; supplied browser observations exercise that case.

Is this the best way to solve the issue?

Yes. Validating telemetry at its Gateway owner and sharing one UI resolver avoids reconstructing runtime reserve policy in the browser.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 9c962dab44a3.

Labels

Label justifications:

  • P2: Corrects misleading context-pressure indicators without changing inference or compaction policy.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): Supplied Chromium observations exercise the changed UI consumers and sessions.changed invalidation with a synthetic Gateway, showing 80% becoming 89% and obsolete budgets clearing live. Focused Gateway regressions supplement this evidence; independent image retrieval was unavailable, as addressed in the later inspection comment.
  • proof: sufficient: Contributor real behavior proof is sufficient. Supplied Chromium observations exercise the changed UI consumers and sessions.changed invalidation with a synthetic Gateway, showing 80% becoming 89% and obsolete budgets clearing live. Focused Gateway regressions supplement this evidence; independent image retrieval was unavailable, as addressed in the later inspection comment.

Evidence

What I checked:

  • Still necessary on main and latest release: Both fetched main and the supplied latest-release commit still divide composer usage by contextTokens without consulting the reserve-adjusted prompt budget. (ui/src/pages/chat/components/chat-composer-context.ts:134, 9c962dab44a3)
  • Prior provenance findings resolved: Gateway rejects saved budgets with mismatched provider, model, session identity, effective cap, or pending model switches. Context-window mutations clear derived telemetry, and the shared UI resolver uses the validated prompt budget. (src/config/sessions/context-token-provenance.ts:125, 47f32b96c637)
  • Runtime owns the denominator: OpenClaw's pre-prompt implementation derives promptBudgetBeforeReserve by subtracting the effective reserve and records that value in session telemetry. Overflow can select tool-result reduction or compaction, supporting the revised last-run estimate wording. This contract is owned by OpenClaw source; no Codex dependency signal applies. (src/agents/embedded-agent-runner/run/preemptive-compaction.ts:245, 47f32b96c637)
  • Live invalidation uses the existing event contract: The added event field emits null for unavailable budgets. Existing UI reconciliation deletes null tombstones, and session rows permit additional properties; no protocol version or persisted schema change is introduced. (src/gateway/session-event-payload.ts:119, 47f32b96c637)
  • Browser proof and review continuity: The captured PR body reports Chromium 151 on sanitized AWS with a synthetic Gateway: composer and sessions change from 160k/200k (80%) to 160k/180k (89%), and sessions.changed clears obsolete budgets without refresh. The later inspection comment confirms all four complete images were inspected and sanitized: fix(control-ui): measure context usage against the effective token budget #138666 (comment). This review's attachment retrieval returned cache misses, so independent image inspection was unavailable; that reviewer limitation does not invalidate the supplied browser observations.
  • Changed behavior preserved since the previous review: The targeted comparison against the previous reviewed head returned no differences in the budget projection, mutation, event, documentation, or UI consumer paths. The captured body reports 584 focused tests and explicitly does not claim the incomplete full changed-code gate passed. No tests were executed during this read-only review. (ui/src/lib/sessions/context-budget.ts:4, 47f32b96c637)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Jason (Json): Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (6 earlier review cycles)
  • reviewed 2026-09-04T22:40:14.233Z sha be5399ff39ac47d935cefb0f436290e172ddec2c :: needs real behavior proof before merge. :: [P1] Measure pressure against the compaction threshold
  • reviewed 2026-09-04T23:58:23.719Z sha 88efa74b1555d2e1374da72a3ce137c93c30c7da :: needs real behavior proof before merge. :: [P2] Invalidate budget snapshots when the effective cap changes
  • reviewed 2026-09-05T00:14:10.769Z sha 88efa74b1555d2e1374da72a3ce137c93c30c7da :: needs real behavior proof before merge. :: [P2] Invalidate budget snapshots when the effective cap changes
  • reviewed 2026-09-05T04:05:14.866Z sha cb21f30230f4382a4e714d105be183b7da33fc48 :: needs real behavior proof before merge. :: [P2] Invalidate stale budgets when configured capacity increases | [P3] Label the diagnostic value as a prompt budget
  • reviewed 2026-09-06T19:49:12.575Z sha 4dce925 :: blocked before merge. :: [P2] Invalidate stale budgets when configured capacity increases | [P3] Label the diagnostic value as a prompt budget
  • reviewed 2026-09-07T20:36:39.714Z sha f9426ec :: blocked before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot added size: M scripts Repository scripts and removed size: S labels Sep 4, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Sep 4, 2026
@DasX

DasX commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

The last review covered be5399ff. The head is now 88efa74b, two commits further on. Answering the open items one by one.

[P1] Measure pressure against the compaction threshold. Done. resolveEffectiveContextLimit() (ui/src/lib/sessions/context-budget.ts) now prefers contextBudgetStatus.promptBudgetBeforeReserve, the value preemptive-compaction.ts:433 derives as contextTokenBudget - effectiveReserveTokens. contextTokenBudget survives only as an intermediate step for snapshots that carry no prompt budget, and the catalog window only as the last fallback.

Label it accurately. The resolver returns reserveAdjusted next to the number, and the popover heading follows the divisor: "Before compaction" for the prompt budget, "Context window" when the fallback is in use. The finding noted the heading could not stay fixed while the denominator changed, so it does not.

[P1] Resolve merge risk. The added surface now carries the reserve-adjusted boundary, which was the condition attached to it.

Replace the impossible fixture. Gone. ui/src/test-helpers/context-budget-status-fixture.ts mirrors buildPrePromptContextBudgetStatus(): it calls the real resolveEffectiveCompactionReserveTokens() from src/agents/agent-compaction-constants.ts and derives promptBudgetBeforeReserve, overflowTokens, route and shouldCompact from the estimate. A snapshot that claims a pre-reserve prompt budget equal to its budget while also carrying a reserve can no longer be expressed through this helper.

Focused coverage across the affected displays. All four consumers now assert against that one helper: composer ring (including the warning-threshold crossing and the over-boundary case), sessions view meter and token cell, /usage, and formatSessionTokens(). Fallback assertions pin the catalog path for sessions with no snapshot.

Real behavior proof. Added to the PR body. Captured from the repo's mocked-Gateway Control UI (pnpm dev:ui:mock) driven with Playwright/Chromium, per .agents/skills/control-ui-e2e, before and after on identical fixture data:

Surface Before After
Composer ring aria-label Session context usage: 160k of 200k (80%) Session context usage: 160k of 180k (89%)
Composer ring class context-ring context-ring context-ring--warning
Popover heading Context window Before compaction
Sessions meter aria-label 80% of context used (160,000 / 200,000 tokens) 89% of context used (160,000 / 180,000 tokens)
Sessions meter class session-context-meter--warn session-context-meter--danger

Worth being explicit about what that fixture isolates: its catalog window and contextTokenBudget are both 200,000, so the "before" column is what current main and be5399ff would both render. It is therefore direct evidence for the finding itself, that dividing by contextTokenBudget leaves the meter below its own 85% warning threshold while the runtime is already past the compaction boundary.

Not measured, stated as such: oxfmt --check could not be run at the pinned version here. This checkout resolves [email protected] against a branch pinning 0.65.0, and 0.60.0 reports the same issues on the unmodified base-commit copies of those two files, so its output is a version artifact rather than a finding. oxlint is clean on all 13 changed files. The repo-wide typecheck was not run locally; CI covers it.

@DasX

DasX commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 5, 2026
@clawsweeper clawsweeper Bot added status: needs maintainer proof decision A ClawSweeper-authored PR needs a maintainer proof capture or override decision. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 5, 2026
@DasX

DasX commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

The failing shard checks-node-compact-small-51 does not come from this PR. Three points:

  1. Where the failures are. All failing cases live in src/cli/update-cli/update-command-service.integration.test.ts.

  2. What this PR touches. Only files under ui/, plus one development script. There is no import path from ui/src to update-cli, so this change cannot reach that test.

  3. Local run at this PR's head (cb21f30230f4382a4e714d105be183b7da33fc48), same file:

Test Files  1 passed (1)
Tests       94 passed (94)
Duration    31.13s

94 of 94 green. openclaw/ci-gate is only the aggregate of the shard above, so there is exactly one real failure among the checks, and it is unrelated.

Happy to rebase or re-run the shard if that helps.

DasX and others added 4 commits September 6, 2026 21:16
…dget

The context usage meter divided the session total by the model's catalog
context window, so a long session could be compacting while the ring
still read a comfortable percentage.

Measure against contextBudgetStatus.contextTokenBudget instead: that is
the ceiling the runtime enforces once reserves are subtracted. The
catalog value stays as the fallback for sessions that have not produced
a budget snapshot yet.

The same denominator drove the sessions-page meter and the /usage slash
command, so both move to one shared resolver.

Co-Authored-By: Claude Opus 5 <[email protected]>
The shared resolver divided by contextBudgetStatus.contextTokenBudget, but
the runtime compacts once the prompt passes promptBudgetBeforeReserve, that
budget minus the effective reserve. With the default 20k reserve on a 200k
budget the meter still read 80% at the moment compaction started, below the
composer's unchanged 85% warning threshold, so the reported "comfortable
while compacting" outcome survived in a narrower band.

Resolve promptBudgetBeforeReserve first, so 100% is the point where the
runtime compacts, and label the composer popover "Context before compaction"
while that value is in use. The heading stays "Context window" on the catalog
fallback, where it remains true.

Replace the impossible fixture, which carried equal contextTokenBudget and
promptBudgetBeforeReserve next to a 32,768-token reserve, with a builder that
derives every field the way buildPrePromptContextBudgetStatus does, including
the reserve cap from resolveEffectiveCompactionReserveTokens. Cover the
composer ring, the sessions meter, the sessions detail row and /usage with
that one snapshot.

Co-Authored-By: Claude Opus 5 <[email protected]>
…ock UI

Rendering the popover in a browser showed "Context before compaction"
wrapping onto two lines where "Context window" takes one, so the heading
becomes "Before compaction".

The mock dev server's main session now carries a budget snapshot, so
`pnpm dev:ui:mock` reproduces the meter state this PR is about: the same
160,000-token session reads 80% and stays quiet against the window, and
89% with the warning tone against the prompt budget.

Co-Authored-By: Claude Opus 5 <[email protected]>
buildGatewaySessionRow() projects the current effective cap into every row's
contextTokens but forwards the stored contextBudgetStatus unchanged, so an
idle session keeps a budget measured against the previous cap until it runs
again. Preferring that snapshot unconditionally reported the old, wider
boundary as current: lowering a model from 1,000,000 to 200,000 tokens left
160,000 tokens reading 16% of a retained 980,000-token prompt budget, under
the composer's warning threshold, for a session the next run compacts at 89%.

Bound every snapshot step by what the current cap allows, re-deriving the
prompt budget with the runtime's own reserve rule so 100% stays on the
compaction point instead of falling back to a plain window.

The clamp is one-directional on purpose. A snapshot narrower than the current
cap is kept, because that is also what a legitimately tighter runtime budget
looks like from the row and the two are indistinguishable there; the PR's own
fixture is that case, with a 262,144-token catalog window over a 200,000-token
enforced budget. Preferring the tighter boundary never reads comfortable while
the runtime is already compacting.
@DasX
DasX force-pushed the fix/context-usage-effective-budget branch from cb21f30 to 4dce925 Compare September 6, 2026 19:42
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: needs maintainer proof decision A ClawSweeper-authored PR needs a maintainer proof capture or override decision. labels Sep 6, 2026
steipete and others added 2 commits September 7, 2026 13:17
…budget

Validate saved budget provenance in Gateway, clear derived telemetry when
context-window selection changes, and publish budget tombstones in session
events. Share the last-run budget across composer, sessions and usage views.

Complete the existing contributor PR while preserving its original history.
Related: openclaw#138590

Co-authored-by: Peik S. <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: M and removed scripts Repository scripts size: L labels Sep 7, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. labels Sep 7, 2026
@steipete

steipete commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

I inspected all four complete before/after images before uploading them: synthetic session data only, with the composer and sessions values changing from 160k/200k (80%) to 160k/180k (89%). The PR body embeds the original files.

All four attachment URLs also passed fresh bounded GET checks: HTTP 206, image/png, with PNG headers matching the inspected originals. HEAD requests returned 403, so those probes do not establish that the images are unavailable. The reviewer’s retrieval limitation does not leave a product or visual-proof gap here. The supplied Chromium and Gateway regression evidence remains unchanged.

The remaining landing blockers are unrelated main CI regressions: the credential QA selector tracked in #141545, and the native-link test already repaired by #141533. Required CI will be rerun with those main repairs before landing.

@steipete
steipete merged commit 1580e46 into openclaw:main Sep 7, 2026
399 of 403 checks passed
@steipete

steipete commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 8, 2026
…dget (openclaw#138666)

Fixes openclaw#138590.

Measure composer, sessions, session-detail, and usage context displays against a validated last-run prompt budget. Gateway checks session, model/provider, and effective-cap provenance; context-window changes invalidate derived telemetry and session events clear obsolete budgets. Preserve current-cap fallback and approximate-token warning behavior.

Retain the original contributor's implementation history and complete the stale-budget repair at its Gateway owners. Label the estimate as a last-run prompt budget rather than promising a specific compaction threshold.

Validation: 584 focused tests and real Chromium/mock-Gateway before/after and live-update proof. Final required CI passed on 47f32b9 after one unchanged-job rerun for a documented unrelated temporary-directory teardown race. Main QA repairs openclaw#141533 and openclaw#141555 are included.

Co-authored-by: Peik S. <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: DasX <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Context usage meter measures against native contextWindow instead of effective budget

2 participants