Repository navigation
fix(sessions): track context window provenance - #124303
fuller-stack-dev merged 58 commits into
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 18, 2026, 6:50 AM ET / 10:50 UTC. ClawSweeper reviewWhat this changesThis PR adds provenance to persisted session context windows and applies one projection rule to Gateway, CLI, interactive status, JSON status, and cron finalization. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessThe shared resolver removes current main’s unqualified same-model persisted-window path. Keep this protected PR open for maintainer review because the required direct inspection of the pinned Codex source could not be completed in this environment. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherAgent runs persist a context-window value with its producing provider, model, and harness. Session readers combine those facts with the current selection to present the active budget. flowchart LR
A[Agent runtime] --> B[Persisted session metadata]
C[Current provider and model] --> D[Provenance resolver]
B --> D
D --> E[Gateway session list]
D --> F[CLI sessions]
D --> G[Status output]
D --> H[Cron finalization]
Decision needed
Why: Repository policy requires direct sibling-Codex source inspection for this dependency-backed behavior, but that checkout was unavailable here. Before merge
Agent review detailsSecurityNone. PR surfaceSource +381, Tests +1592. Total +1973 across 67 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one typed provenance rule at the session boundary, verify the pinned Codex notification contract directly, then merge after exact-head validation. Do we have a high-confidence way to reproduce the issue? Yes—source-reproducible: current main accepts a same-provider/model persisted context window without checking its producing harness; the PR’s focused status test encodes that transition. Is this the best way to solve the issue? Unclear—the shared resolver is the appropriate owner boundary, but the dependency-backed Codex behavior cannot receive a final best-fix verdict without direct source inspection. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 2d5334fb42b6. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (22 earlier review cycles; latest 8 shown)
|
|
Exact head
The PR body now states accurately that source-blind run 31911834408 concluded cancelled; only its independently captured raw results are claimed. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Exact-head refresh after the canonical branch advanced:
Hosted CI is restarting on this exact head. @clawsweeper re-review |
|
Canonical moved once more while CI was starting. Updated without rebasing or rewriting:
Hosted CI is restarting on this head. @clawsweeper re-review |
|
Latest canonical refresh completed without rewriting:
Hosted CI is restarting on this exact head. @clawsweeper re-review |
|
@clawsweeper re-review Exact head |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Exact head |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
Summary
/status, and CLI/Gateway JSON statusRoot cause
SessionEntry.contextTokenswas an unqualified last-run cache. After a same-provider/model OpenClaw-to-Codex transition, the current runtime could resolve to Codex while the prior OpenClaw 272k window still won. Fresh/upgraded entries without producing-harness provenance had the same problem, and transcript/budget fallback or status readers could reintroduce the stale value after the Gateway row itself was corrected.The producer already has typed provider/model/harness and context-window facts. This change records those facts where they occur, clears them at lifecycle ownership changes, and consumes them only when the persisted producer tuple still matches the current selection. It does not infer provenance from UI state, tool text, or provider-specific strings.
Observable behavior
/status, and JSON status/new, reset, message-cut rotation, model/runtime/harness changes, and repair paths clear associated provenance atomicallyThe effective Codex window remains 1M while the catalog-native maximum remains 1.05M. The configured 700k native auto-compaction threshold is unchanged, and the configured runtime remains Codex.
Verification
sessions.listretained 272k (run 31906395919).fb372b0: Gateway projected Codex1M/native1.05M, but CLI status, JSON status, and intercepted/statusrendered stale272k (run 32086317535).ee59e7b: after an exact Gateway restart, all three status surfaces rendered Codex1M; nested272k telemetry stayed historical; no700k appeared (run 32087923413).No live Codex credential was available for source-blind proof, so the Codex transition used public config/session/Gateway surfaces rather than claiming a credentialed Codex turn.
Dependency contract
OpenClaw pins
@openai/codex0.147.0. Direct inspection of sibling Codex tagrust-v0.147.0(be6e8eac029b183056b7e4402879f15d2c85f61b) confirmed:codex-rs/app-server-protocol/src/protocol/v2/thread.rs:1579-1614defines the optionalmodel_context_windownotification fieldcodex-rs/app-server/src/bespoke_event_handling.rs:1576-1591emits the live valuecodex-rs/models-manager/src/model_info.rs:25-34applies the authored window clampOpenClaw forwards the authored cap to Codex and records observed notification provenance without parsing text.
Scope
Related: #124207, #118678.