Repository navigation
fix: first turn after /new stays below transcript fuse - #124126
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
0e42ad7 to
e61c1c3
Compare
|
Codex review: needs maintainer review before merge. Reviewed August 15, 2026, 5:16 AM ET / 09:16 UTC. ClawSweeper reviewWhat this changesThe PR makes the transcript byte fuse after Merge readinessKeep open. Current main still counts all active SQLite transcript rows through a reset; this PR moves byte statistics to the reset-window owner that matches model-context retention. No concrete patch defect was found; normal maintainer landing review remains appropriate. Priority: P1 Review scores
Verification
How this fits togetherSQLite stores conversation events across resets, while the reset-window projection decides what the next model thread actually receives. The memory guard consumes transcript byte statistics before deciding whether to compact, so this change aligns that guard with model-visible context. flowchart LR
A[Incoming chat turn] --> B[SQLite transcript events]
B --> C[Reset-window projection]
C --> D[Logical byte statistics]
D --> E[Memory compaction guard]
E --> F[Model turn]
C --> F
Before merge
Agent review detailsSecurityNone. PR surfaceSource +44, Tests +175. Total +219 across 4 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one canonical reset-window statistics reader backed by the shared retained-entry selector, then land after exact-head validation completes; no net-neutral alternative can derive the previously unavailable retained paired-result byte facts. Do we have a high-confidence way to reproduce the issue? Yes—source-reproducible. Current main sums the full active projection after a reset, and the linked oversized-history/reset/small-turn scenario directly reaches the byte-fuse decision. Is this the best way to solve the issue? Yes. Moving the calculation to the reset-window owner makes it follow the same retained-entry contract as model context; a consumer-side bypass or session-ID rotation would leave other accounting paths divergent or alter lifecycle semantics. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against fe5fa802fa27. 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
|
|
Maintainer landing review complete for exact head
Current |
|
Merged via squash.
|
Closes #119984
Closes #123334
What Problem This Solves
Fixes an issue where the first turn after
/newcould immediately fail with “Context is too large and auto-compaction could not recover this turn” when discarded SQLite transcript rows from the previous reset generation exceededmaxActiveTranscriptBytes.This also resolves the remaining current-main cause behind #123334. Keeping the OpenClaw channel session ID and durable rows across
/newis intentional; current binding lifecycle tests prove that the retired in-place Codex generation can be reclaimed and rebound to a fresh native thread.Why This Change Was Made
The authoritative transcript statistics reader now uses the same reset-window owner as model context. It counts the exact retained reset prelude—including valid paired tool results—plus post-reset events, while excluding discarded history and orphaned retained results. Cached retained-tail facts are reused across ordinary post-reset appends and invalidated when the reset boundary, branch, compaction, or projection generation changes.
This is a fresh-current-main successor to #120059, whose root-cause direction was correct. Current
mainadded paired tool-result retention after that contributor head, so merging it unchanged would undercount model-visible reset context. Credit to @ayaangazali for identifying the canonical reset-window owner and supplying the original focused repair.The change does not rotate session IDs, change Codex/OpenClaw runtime selection, modify config/default surfaces, alter SQLite schema, or change explicit Codex context-window/native auto-compaction settings.
Production LOC: +76/-32 (net +44), justified by making reset-window projection the shared owner of logical statistics and adding bounded cache invalidation. Tests: +179/-4.
User Impact
After
/new, discarded pre-reset bytes can no longer keep a Codex-backed session stuck above the transcript fuse. A genuinely oversized new generation is still protected, and both fresh and persisted/upgraded OpenAI selections remain on the Codex runtime.Evidence
26ff3c96071726e582a05e720e64829e1749c9f4: logical history was three messages, but the fuse still measured 32,929 bytes from discarded rows. Blacksmith run/newpreservation, persisted Codex migration, 1.05M native rollout window, in-place binding reclaim, and cleared-binding fresh-thread start pass. Blacksmith runopenai/codex@85fc4def358b: unavailable thread IDs returnthread not found;thread/startowns a new native thread;thread/compact/startloads the binding then submitsOp::Compact; nativemodel_context_windowandmodel_auto_compact_token_limitremain independent configuration fields.Real gateway proof is not claimed: the Testbox API-key attempt failed before a model turn because the active runtime snapshot had no resolved OpenAI API key. The staged Codex-auth rerun was stopped without a behavior verdict after the live lane was declared externally blocked. No private Rosita data was used.