Repository navigation
fix(ai): keep provider checkpoints across model switches - #200208
Conversation
The replay fence compared the model id, so a session that changed models (fallbacks, per-turn overrides, astra/sol alternation) discarded its own server compaction checkpoints and encrypted reasoning, resent the full history and fell back to client summarization. OpenAI compaction items and encrypted reasoning, and Anthropic compaction blocks, are accepted across models of the same provider. The fence is now provider API, endpoint and session. An item the provider cannot use is still rejected server-side and handled by the existing replay recovery. Co-authored-by: obviyus <[email protected]>
OpenClaw-Publication: 062db4a7-d3c5-4845-a8d2-101d13f1edce
|
🦞👀 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. |
Co-authored-by: obviyus <[email protected]>
|
Codex review: needs maintainer review before merge. What this changesThis PR preserves provider compaction checkpoints when a session switches models within the same provider API and endpoint. Example: A session compacts three turns with openai/gpt-5.4-mini, then continues with openai/gpt-5.4.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR addresses a demonstrated checkpoint-continuity bug with a focused shared-owner fix and recorded real-model proof; no introduced defect was found, and the failed UI assertion also fails on the base. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe shared AI replay matcher selects checkpoints from saved conversation history for provider request conversion, history projection, and context accounting. flowchart LR
A[Saved conversation] --> C[Shared replay matcher]
B[Selected provider route and session] --> C
C --> D[Checkpoint and remaining history]
D --> E[Provider request]
E --> F[Provider response]
F --> A
Technical reviewBest possible solution: Keep the shared matcher repair and focused checkpoint regression while preserving the existing route/session boundaries and rejection recovery. Do we have a high-confidence way to reproduce the issue? Current main directly rejects matching-session checkpoints when model IDs differ, and the supplied real-model comparison demonstrates the resulting request expansion; no target code was executed during this review. Is this the best way to solve the issue? Removing the comparison at the existing shared owner is the smallest complete repair for checkpoint continuity, with no added state, wrapper, or competing policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against aa4d490a848b. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -1, Tests +13. Total +12 across 5 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel 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 Reviewed November 16, 2026, 1:51 PM ET / 18:51 UTC. |
|
Landed in 7cb238a.
|
Backport canonical 7cb238a for the 2026.11.5 release, as requested by Dallin. Applies without adaptation on top of #200063. Preserve provider API, endpoint, and session boundaries; the provider owns checkpoint compatibility. Proof: new checkpoint replay regression fails on the original owner; all 102 focused replay tests pass with the patch. Prefix stability 14/14 and formatting/diff checks pass. Live provider proof is retained in the canonical PR, not rerun locally. Full release qualification remains pending. (cherry picked from commit 7cb238a) Co-authored-by: RomneyDa <[email protected]>
Backport #200063, #200208, #200247, #200260 and #190065 to 2026.10.33. Preserve canonical source credit and maintenance-branch contracts. All selected exact-head checks passed except the inherited Docker plugin API mismatch; aggregate ci-gate reports that same cause. Landing authorized with this attributed pre-existing failure. Co-authored-by: Ayaan Zaidi <[email protected]> Co-authored-by: miguelbranco80 <[email protected]> Co-authored-by: Shakker <[email protected]> Co-authored-by: RomneyDa <[email protected]>
…0208) ## Problem A session that changes models drops its own server compaction checkpoint, resends the full raw history, and falls back to client summarization. Model changes happen through fallbacks, per-turn overrides and model alternation within one session. The provider replay check compared the model id. After openclaw#200063 removed the credential-path check, the model check was the other common cause. On the host that reported the original incident, model changes accounted for 357 of 800 dropped-checkpoint turns, mostly a session alternating between `gpt-6-astra` and `gpt-6.1-sol`. ## Fix - The replay check is now provider API, endpoint and session. The model id stays in the stored record but is no longer compared. - Providers accept their own replay items across models. I checked this with raw API calls before changing anything: - **OpenAI compaction items:** `gpt-6-astra` ↔ `gpt-6.1-sol` and `gpt-5.4-mini` → `gpt-5.4` are accepted, and the model recalls a fact that is only in the compacted history. - **OpenAI encrypted reasoning:** the same pairs are accepted. - **Anthropic compaction blocks:** `claude-sonnet-4-6` → `claude-opus-4-8` is accepted and recalls the compacted fact. These blocks are plaintext summaries. - An item a provider cannot use is still rejected server-side (`invalid_encrypted_content` / `item_conflict`), and the existing replay recovery handles it. The production change is one comparison removed. The tests that asserted the model check are replaced with positive cases. ## Evidence **Regression test:** `openai-responses-compaction-replay.test.ts` › "replays a checkpoint written by another model in the same session". It fails on the old check and passes with the fix. **Real-model E2E** (isolated state; each arm built from its own source): - Three seed turns on `openai/gpt-5.4-mini` with server compaction, then a final turn on `openai/gpt-5.4` in the same session with the same key. - Request shapes come from `OPENCLAW_DEBUG_MODEL_PAYLOAD=summary`. | arm | final-turn request | items | text chars | answer | | --- | --- | --- | --- | --- | | base | messages only; `compactionItems=0` | 11 | 113,090 | correct | | fix | `compaction, message:user, message:developer`; `compactionItems=1` | 3 | 656 | correct | **Checks:** - The touched replay suites pass (100 tests). - `check:changed` passes except the dead-export scan. That scan reports unused exports in files this PR does not touch, which come from the current `main` tree. ## Scope Encrypted reasoning from a different model is still dropped on a model switch. The generic cross-model history transforms (`transcript-transform.ts`, `transport-message-transform.ts`) and `dropStaleOpenAIReasoning` strip it before the replay check runs. That costs one turn of reasoning context, not the session's history, so it is left for a separate change. ## Follow-up The context meter still estimates from the full transcript when a checkpoint is present. That fix is a separate PR. <!-- openclaw-publication:062db4a7-d3c5-4845-a8d2-101d13f1edce --> Co-authored-by: Ayaan Zaidi <[email protected]>
Problem
A session that changes models drops its own server compaction checkpoint, resends the full raw history, and falls back to client summarization. Model changes happen through fallbacks, per-turn overrides and model alternation within one session.
The provider replay check compared the model id. After #200063 removed the credential-path check, the model check was the other common cause. On the host that reported the original incident, model changes accounted for 357 of 800 dropped-checkpoint turns, mostly a session alternating between
gpt-6-astraandgpt-6.1-sol.Fix
gpt-6-astra↔gpt-6.1-solandgpt-5.4-mini→gpt-5.4are accepted, and the model recalls a fact that is only in the compacted history.claude-sonnet-4-6→claude-opus-4-8is accepted and recalls the compacted fact. These blocks are plaintext summaries.invalid_encrypted_content/item_conflict), and the existing replay recovery handles it.The production change is one comparison removed. The tests that asserted the model check are replaced with positive cases.
Evidence
Regression test:
openai-responses-compaction-replay.test.ts› "replays a checkpoint written by another model in the same session". It fails on the old check and passes with the fix.Real-model E2E (isolated state; each arm built from its own source):
openai/gpt-5.4-miniwith server compaction, then a final turn onopenai/gpt-5.4in the same session with the same key.OPENCLAW_DEBUG_MODEL_PAYLOAD=summary.compactionItems=0compaction, message:user, message:developer;compactionItems=1Checks:
check:changedpasses except the dead-export scan. That scan reports unused exports in files this PR does not touch, which come from the currentmaintree.Scope
Encrypted reasoning from a different model is still dropped on a model switch. The generic cross-model history transforms (
transcript-transform.ts,transport-message-transform.ts) anddropStaleOpenAIReasoningstrip it before the replay check runs. That costs one turn of reasoning context, not the session's history, so it is left for a separate change.Follow-up
The context meter still estimates from the full transcript when a checkpoint is present. That fix is a separate PR.