Repository navigation
fix(status): correct stale context limits after model discovery - #165991
Conversation
…models in cold sessions
…models in cold sessions
…models in cold sessions
The exported flush window resolver was reachable only from its own tests, so the bundled cold-budget fallback could regress in production while the suite stayed green. Remove the helper and cover the bundled catalog windows through runMemoryFlushIfNeeded, the actual maintenance boundary that feeds resolveMemoryFlushPlan.
Embedded runs labeled every run-level context window as legacy resolved, which cold session projections intentionally distrust, so sessions list and /context fell back to the 200k default when synchronous catalog lookup could not see the model. Carry the resolution source from run preparation and persist model- or config-resolved windows as resolved-v1; the generic default keeps the legacy marker.
When Copilot /models omits or reports an invalid max_context_window_tokens, the mapper filled in the 128k default as if it were a reported native ceiling. With a real max_prompt_tokens present, that fabricated window became authoritative and could both clamp the prompt limit and grant replacement authority over the synthetic fallback. Mark that default with the same contextWindowSource: "synthetic" provenance used by the unknown-model branch, never let the estimate sit below a real prompt limit, and thread the marker through the provider result copy, persisted catalog schema, model registry and config merge. Authored contextWindow/contextTokens clear the marker. Supersession now requires a reported limit: a real prompt limit, or a non-synthetic native window. A genuinely reported 128k window is unchanged. Reported-by: snotty <[email protected]>
…ted owner An existing session whose persisted telemetry came from the synthetic 128k fallback stayed at 128k after discovery until a later run, because the projector trusted it as runtime telemetry and took min(persisted, resolved). - Embedded runs stamp contextTokensSource: "synthetic" when the prepared budget is exactly a provider unknown-model estimate (no reported prompt limit, authored cap, modelsConfig sizing or narrower caller budget), including failed/cancelled attempt metadata. - Synthetic rows are never trusted telemetry, including locked sessions. - /status and session_status bind the displayed session to its admitted prepared owner (agent + spawned workspace) before choosing capacity. A synthetic row takes that owner's accepted capacity (or an authored cap). An unbound, retired, failed or model-less owner settles as owner-scoped unavailable and renders unknown, never the stale estimate or another owner's process-global cache value. - Genuine (non-synthetic) persisted 128k stays conservative.
Adds a human-run procedure and script that capture /status and session_status context lines from a patched scratch Gateway for a fresh session, existing-session recovery and an account switch. Output is redacted (tokens, IPs, phone numbers, emails, private endpoints, paths, account/session ids) and the script never starts a Gateway, writes config or reads credentials. --self-test exercises the redaction rules.
Authored models config windows and caller budget caps are removable operator config. Persisting them as resolved-v1 let cold session projection keep publishing a cap after the operator removed it.
…window-provenance
A model that declares context-window options sizes its budget from the session's window selection (or the declared default). The cold session reader matches resolved-v1 rows only by provider, model, and harness, so a persisted 200k selection could outlive a later switch to 1m, and the reverse. Keep those budgets on the legacy resolved marker.
…window-provenance
embedded-agent-runner.e2e.test.ts is over the line cap, and the line-cap ratchet rejects any growth there. The provenance cases only need the fast-run mocks, so they live in their own e2e file.
|
🦞👀 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 real behavior proof before merge. What this changesThis PR makes context reports use current, runtime-specific model capacity and show unknown capacity explicitly. Example: Select discovered Ollama qwen3:4b before another turn.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains Keep this useful, maintainer-engaged repair open: current main retains the reporting defect, and the previous code findings are resolved. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherStatus and session readers combine scoped model catalogs, configured limits, runtime selection, and verified session budgets to produce CLI, Gateway, and channel reports. flowchart TD
A[Scoped model catalog] --> D[Runtime capacity selection]
B[Configured limits] --> E[Context projection]
C[Verified session budget] --> E
D --> E
E --> F[CLI and Gateway reports]
E --> G[Channel status and context replies]
Technical reviewBest possible solution: Land the reporting repair through the existing catalog and provenance owners after the required proof is supplied or explicitly waived. Do we have a high-confidence way to reproduce the issue? Current-main source exposes stale-cache clamping and generic denominator fallback, supported by recorded base-failing regressions and real discovery results; no target code was executed during this review. Is this the best way to solve the issue? The reporting-specific cache bypass and scoped catalog reads address the demonstrated defect while retaining configured limits, verified provenance, and existing execution resolution. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 9607478c76a4. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +230, Tests +431, Docs +12, Other -1. Total +672 across 28 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (13 earlier review cycles; latest 8 shown)
Reviewed October 11, 2026, 3:45 PM ET / 19:45 UTC (Revision 14). |
|
@clawsweeper re-review Added revision-bound running-Gateway before/after proof and inspected captures to the PR body for unchanged head This is isolated local Gateway proof, not Telegram Test Server transport. The repository test-broker prerequisites are unavailable here; that separate gate is explicitly left unfulfilled rather than borrowing production credentials. Please assess the added runtime evidence and route any remaining real-Telegram proof to an environment with the leased broker access. No product-source update, production restart, or merge was performed. |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Keep additional Gateway runtime capacities in CLI catalog conversion. Resolve summary defaults only through an available agent owner, and keep namespaced transcript model IDs bound to their current provider catalog. Update neighboring regression fixtures to supply admitted metadata or expect unknown capacity.
Narrow regression-only follow-upPublished commit The real resolver reproduces four assertion failures with 12 passing controls when only its two production owners are reverted to base The consuming agents-root type graph, touched-file lint, format, whitespace/patch checks and independent static review pass. Context-suite cost: 8.42s wall, including cold transform/setup; Hosted product-test CI/cost is not yet verified for this commit. Proof and patch: https://gist.github.com/snotty/5030d0d5ca970b0ade000e3a9d7b4c64 . Budget controls for the unchanged #138087 head are recorded separately. This is source-only evidence; it does not clear the existing hosted CI, security, live-transport or maintainer gates, and no merge or runtime deployment is claimed. |
Merge current main into the contributor branch, preserving its history. Keep the reporting-only cache bypass in the refactored resolver and retain main’s removal of superseded status tests.
Co-authored-by: Mike <[email protected]>
|
Merged via squash.
|
What Problem This Solves
Local model discovery, refresh, or a model/runtime switch can leave status and session reports showing an older context limit, another runtime's limit, or a generic denominator.
User Impact
Reports use the selected model/runtime's admitted capacity, configured caps, or a matching verified run budget. Unknown capacity stays
?(nullin session-list JSON), without an invented percentage. Spawned workspaces retain their own catalog/budget scope. Execution and compaction budgeting are preserved.Why This Change Was Made
This preserves @snotty's original reporting repair and consumes the existing model catalog and context-provenance owners. CLI sessions passively reads the inspected local Gateway's prepared catalog; explicit-store and other-workspace rows use scoped saved facts. Failed Gateway reads warn once and retain the offline path. Runtime choices remain tagged so one runtime cannot supply another's capacity.
The branch is independent of Copilot #156636 and retains work already landed in #159731 and #168309. Main
61722c8ecbd27cdb960e7a6f9055f17ad3ae8a04was merged without rebasing or rewriting contributor history, including @snotty's latest regression commitfbfa840f2b49. The conflict resolution keeps main's configured/fixed-context consolidation and its intentional retirement of redundant status tests. The contributor's captured-cache tests remain.Evidence
Prior live proof used isolated state and real OpenClaw CLI/Gateway entry points on main
c6d71fae0ed1and repaired head3366edb5ae30:qwen3:8banswered a real turn. After selecting discoveredqwen3:4b, main CLI sessions reported 200000; repaired CLI reported 32768 before another turn, and the next Qwen turn admitted 32768.models.listrefresh, main CLI sessions remained 16384; repaired CLI/Gateway rows and/context jsonreported 32768, and another real turn completed. Main/statusalready handled this known-capacity refresh correctly./statusreported?/200kand CLI 200000. Repaired/statusreported?/?and CLInull. The repaired head also completed another real Qwen3:4b turn at 32768.Main-failing status regressions establish stale-cache and other-runtime errors. A spawned-workspace CLI regression failed before its repair when the parent catalog's 131072 replaced a matching saved 16384 budget; the repaired path preserves workspace ownership.
Main-merged head
01083e250da949544106f0bfebcc520de5c6e185passes 213 focused tests: nine primary files / 180 cases in 795.55s wall, context/status adapters / 31 cases in 293.68s, and Gateway health scheduling / 2 cases in 224.94s, all with one worker. Cold worker preparation dominates these busy-host wall times; no sleeps, retries or worker pins were added. Core types, all 28 consuming test-type graphs, touched lint/formatting, assertion safety, max-lines, line-cap, timeout-race, mock-export, config-doc and plugin-inventory checks pass. Gateway worktree preparation/build passes. Fresh Codex autoreview is scoped-clean through P2. The reporting change introduces no prompt text/token delta.Incoming main directly repairs the earlier Bun observer failure in
952c102dde987: invalidate exact row facts after installing the reader observer, while retaining bounded-key, sibling, SQL and reuse assertions. Correction to the previous diagnosis: the recovery case's expected-zero failure was the shared Gateway-work drain assertion, not a membership authorization assertion. The exact-head CI run 38164531708 passed all 62 executed jobs, includingopenclaw/ci-gate. Blacksmith Testbox verified that source/tree and passed the original nine-file Linux Bun group 101/101 in 86.01s wall, including the observer and both recovery cases. The initial Testbox attempt lacked Bun; its prerequisite was repaired using the repository's checksum-pinned installer, and the successful lease was stopped. No remaining red CI job required a main-base comparison.ClawSweeper's accepted P2 is fixed in final candidate
1cf9a6c53b953987f503d81814b378c0d4f66337: corrupt, unreadable or unverifiable optional Gateway locks now warn once and fall back to saved/configured capacity without contacting an unverified owner. The CLI boundary regression failed before repair and all 24 session cases passed in 186.23s wall afterward. The real command entry point protects the inspection/transport/offline boundary that smaller resolver tests cannot cover. Core/command-test types, lint, formatting and required ratchets pass again; final-head Codex autoreview is scoped-clean through P2. The Gateway/storage paths from the Linux proof are unchanged. Final-head CI run 38167012438 passed all 62 executed jobs, includingopenclaw/ci-gate(25 skipped). ClawSweeper reviewed exact head1cf9a6c53b95and lists no code findings; its remaining requests are proof-only and covered by the campaign lead’s explicit override. No inherited-CI exception is needed.Telegram, live spawned-workspace, and real-CLI unverifiable-lock captures remain outside the maintainer-directed proof scope; the campaign lead overrides these proof-only holds. No code finding is waived.
The current diff versus merged main is production +456/-226, tests/support +515/-84, docs +13/-1, and one obsolete mock-baseline entry removed. The net 230 production lines implement passive catalog transport and explicit owner/runtime binding; superseded fallbacks were removed without adding a second capacity owner. No configuration, schema, dependency or protocol change is introduced by this repair.