Repository navigation
fix(ai): keep provider checkpoints across credential sources - #200063
Conversation
The compaction and reasoning replay fence included the auth profile hash. The same OpenAI key can reach a session through an auth profile or through models.providers.<id>.apiKey; runs that alternate between the two rejected the session's own server checkpoints, resent the full history and fell back to client summarization. Identity is now session plus model route. A checkpoint from a different org is still rejected by the server (invalid_encrypted_content / item_conflict) and handled by the existing recovery path. Checkpoints stored with a legacy authProfileHash keep replaying. Co-authored-by: obviyus <[email protected]>
OpenClaw-Publication: 4ab5fa4d-c2cc-4079-99d9-55f7c6a888a9
|
🦞👀 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 changes before merge. What this changesThis PR preserves provider compaction and encrypted reasoning checkpoints when a session changes credential sources. Example: An openai/gpt-5.4-mini session switches from an auth profile to the same API key in provider config.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains This PR addresses a demonstrated checkpoint-continuity bug, but two existing conversion tests still enforce the removed auth-profile fence and fail in CI. Priority: P1 Before merge
Findings
Agent review detailsHow this fits togetherThe shared AI replay owner matches persisted provider checkpoints against the current session and model route, then prepares the checkpoint and remaining history for provider requests and context accounting. flowchart LR
A[Session transcript] --> B[Shared replay identity]
C[Selected model route] --> B
B --> D[Checkpoint and suffix]
D --> E[Provider transport]
F[Selected credential] --> E
E --> G[Provider response]
G --> A
Technical reviewBest possible solution: Keep the shared replay-owner fix and update the remaining conversion tests to preserve ciphertext across credential-source changes while retaining session, model, and endpoint mismatch coverage. Do we have a high-confidence way to reproduce the issue? Current main compares auth-profile hashes despite an unchanged session and model route, and the supplied base-versus-fix real-model trace demonstrates checkpoint loss across the same-key source switch; no target code was executed during this review. Is this the best way to solve the issue? The production diff is a focused repair in the existing shared owner, with consistent caller updates and no added machinery; the remaining defect is incomplete migration of the existing conversion tests. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 96ad377596ca. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource -22, Tests -9. Total -31 across 25 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: 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 Reviewed November 16, 2026, 5:23 AM ET / 10:23 UTC. |
Co-authored-by: obviyus <[email protected]>
|
Maintainer override: the red jobs on head 1815abb are not caused by this change.
Exact head: local review ready (no findings), and real-model E2E before/after is in the PR body. |
|
Landed in 225d22f.
|
Backport requested by Dallin for 2026.11.5. Preserve provider, model, endpoint and session fencing while removing credential lookup-path identity. Backport of commit 225d22f. The release lacks the newer prepared-input cache; its single auth-identity condition deletion is inapplicable, so that module remains unchanged. Validation: replay boundaries 42/42; touched suites 147/148; prompt-prefix stability 14/14; formatting and diff checks pass. The sole WebSocket disconnect assertion fails identically on unchanged base and patched code. Original canonical real-provider evidence was reviewed, not rerun locally. Co-authored-by: RomneyDa <[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-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]>
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]>
Complete the #200063 caller cutover: stop passing the removed authProfileId replay option. The exact-candidate package declaration build exposed TS2353 at this remaining caller; replay params and compaction suites pass 21 tests. The converter no longer consumes this value. 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]>
…w#200063) ## Problem Long OpenAI Responses sessions lost their server compaction checkpoint and fell back to client summarization, even though the provider had compacted the session. The replay identity fence for compaction and encrypted reasoning items included the auth profile hash. One OpenAI key can reach a session two ways: through an auth profile (`openai:*`) or through `models.providers.openai.apiKey`. When runs alternate between those two sources, the fence rejects the session's own checkpoints. The next request then resends the full raw history (about 1M tokens on the affected host) and client summarization runs. In the reported incident, that summarization was refused, which left the session with no summary. This was observed in production on one host where both sources hold the same key; four sessions were affected. The fence was added in openclaw#120457 and moved in openclaw#135727. ## Fix - The replay identity is now session plus model route only. `authProfileHash` and `authProfileId` are removed from the replay context, the compaction and reasoning replay builders, the context-usage meter, and every provider, transport and agent call site. - A checkpoint from a different org is still rejected by the server (`invalid_encrypted_content` / `item_conflict`). The existing recovery in `openai-responses-replay-internal.ts` already handles that. - Checkpoints saved with a legacy `authProfileHash` still replay. No migration is needed. Net change: 32 files, +42 −77 (tests that asserted the credential-source fence are removed). ## Evidence **Regression test:** `provider-compaction-replay.test.ts` › "counts the returned prefix once after restart, including checkpoints with a legacy auth hash". It fails on base and passes with the fix. **Real-model E2E** (isolated state, `openai/gpt-5.4-mini`, server compaction threshold 12k): - Setup: three seed turns run through an auth profile only. The final turn runs with the config `apiKey` present, which takes precedence. It is the same key, so only the credential source changes. - Request shapes come from `OPENCLAW_DEBUG_MODEL_PAYLOAD=summary`. | arm | final-turn request | items | text chars | answer | | --- | --- | --- | --- | --- | | base `e263be2` | `message×N, reasoning…`; `compactionItems=0` | 12 | 113,498 | correct | | fix | `compaction, message:user, message:developer`; `compactionItems=1` | 3 | 758 | correct | Base drops the checkpoint and the encrypted reasoning items and resends the full transcript. With the fix, the same checkpoint replays across the credential switch. At production scale, the same flip on a copy of a real session measured 331k tokens with a matching identity versus 900k with only the auth profile changed. **Checks:** - `pnpm check:changed` is green. - Every replay test file that used the credential-source fence is updated. The changed test files pass (153/154; the remaining case needs `--expose-gc`). - The full `packages/ai/src/transports` run shows 7 failures. The same 7 fail on base under the same invocation. They are the GC retention fixtures that need `--expose-gc`, plus two order-dependent tests that pass when run alone. ## Follow-up The meter still estimates from the full transcript when a checkpoint is present. That fix is a separate PR. <!-- openclaw-publication:4ab5fa4d-c2cc-4079-99d9-55f7c6a888a9 --> Co-authored-by: Ayaan Zaidi <[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
Long OpenAI Responses sessions lost their server compaction checkpoint and fell back to client summarization, even though the provider had compacted the session.
The replay identity fence for compaction and encrypted reasoning items included the auth profile hash. One OpenAI key can reach a session two ways: through an auth profile (
openai:*) or throughmodels.providers.openai.apiKey. When runs alternate between those two sources, the fence rejects the session's own checkpoints. The next request then resends the full raw history (about 1M tokens on the affected host) and client summarization runs. In the reported incident, that summarization was refused, which left the session with no summary.This was observed in production on one host where both sources hold the same key; four sessions were affected. The fence was added in #120457 and moved in #135727.
Fix
authProfileHashandauthProfileIdare removed from the replay context, the compaction and reasoning replay builders, the context-usage meter, and every provider, transport and agent call site.invalid_encrypted_content/item_conflict). The existing recovery inopenai-responses-replay-internal.tsalready handles that.authProfileHashstill replay. No migration is needed.Net change: 25 files, +28 −59.
Evidence
Regression test:
provider-compaction-replay.test.ts› "counts the returned prefix once after restart, including checkpoints with a legacy auth hash". It fails on base and passes with the fix.Real-model E2E (isolated state,
openai/gpt-5.4-mini, server compaction threshold 12k):apiKeypresent, which takes precedence. It is the same key, so only the credential source changes.OPENCLAW_DEBUG_MODEL_PAYLOAD=summary.7f234bdmessage×N, reasoning…;compactionItems=0compaction, message:user, message:developer;compactionItems=1Base drops the checkpoint and the encrypted reasoning items and resends the full transcript. With the fix, the same checkpoint replays across the credential switch. At production scale, the same flip on a copy of a real session measured 331k tokens with a matching identity versus 900k with only the auth profile changed.
Checks:
pnpm check:changedis green.packages/ai/src/transportsrun shows 7 failures. The same 7 fail on base under the same invocation. They are the GC retention fixtures that need--expose-gc, plus two order-dependent tests that pass when run alone.Follow-up
The meter still estimates from the full transcript when a checkpoint is present. That fix is a separate PR.