Repository navigation
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 12, 2026, 12:05 PM ET / 16:05 UTC. ClawSweeper reviewWhat this changesAdds session-scoped continuation for native OpenAI Responses HTTP/SSE turns, with suffix-only follow-ups and full-history retry when an upstream response ID is unavailable. Merge readinessKeep open. No blocking patch defect was found: the existing OpenAI provider wrapper supplies the final stored-request policy, while this PR owns only native SSE continuation and same-turn recovery. Rebase and rerun exact-head validation before merge because the branch is behind and the dependency source was unavailable locally. Priority: P2 Review scores
Verification
How this fits togetherThe OpenAI provider prepares a stored Responses request, then the AI transport streams it to the official API and produces agent output. This PR adds short-lived session state between those stages so an unchanged next turn can reference the prior provider response instead of resending history. flowchart LR
A[Agent history] --> B[OpenAI provider policy]
B --> C[Stored native SSE request]
C --> D[Session continuation owner]
D --> E[Delta request with prior response]
E --> F{Provider accepts prior state}
F -- yes --> G[Commit completed response]
F -- missing state --> H[Retry full history]
H --> G
Before merge
Agent review detailsSecurityNone. PR surfaceSource +174, Tests +549. Total +723 across 11 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Keep provider policy as the sole owner of Do we have a high-confidence way to reproduce the issue? Not applicable as an issue reproduction: this is a transport capability PR, and the body supplies an authenticated after-fix OpenAI run as behavior evidence. Is this the best way to solve the issue? Yes. The shared continuation owner keeps provider storage policy outside the transport, reuses the repaired WebSocket comparison logic, and preserves a full-history fallback for missing upstream state. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 28a5889e9bd0. LabelsLabel 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 (7 earlier review cycles)
|
f85371b to
2e241e1
Compare
steipete
left a comment
There was a problem hiding this comment.
This addresses a real payload-growth problem, but the current head does not deliver the advertised native path and is not safe to merge. I am requesting changes.
Production LOC: +414/-112 (net +302) | Tests: +650/-0 | Docs: +341/-0 | Generated baselines: +98/-98 (net 0)
The four newly verified blockers are attached inline: the normal direct-OpenAI path is excluded by the current transport: "sse" default; the HTTP identity is both unstable across turns and unsafe across header-auth rotation; the extracted comparator reintroduces the bug fixed by #122483; and a missing/expired previous response fails the current turn instead of retrying its full request.
I also independently confirmed the latest ClawSweeper findings that remain actionable:
- cache write-back records the checkpoint request rather than the effective successful full-history retry;
compat.supportsResponsesContinuationis absent from the canonical strictModelCompatSchema, so the advertisedopenclaw.jsonopt-in is rejected;- the capability is undocumented and has no real endpoint/fallback proof.
Storage nuance: the normal embedded direct-OpenAI wrapper already applies provider-managed store: true, so this is not a blanket retention change for that one wrapped path. The shared transport itself deliberately defaults to no-store, however, and this patch unconditionally changes an effective request to store: true. Continuation must engage only when the final egress request is already stateful; the cache must never turn storage on or override an explicit store: false.
Best-fix verdict: too broad and stale against current main, not merge-ready. HTTP/SSE continuation can be useful for an explicitly stateful native OpenAI request, especially where WebSocket is unavailable, but it is not transparent on no-store routes. Start from #122483's JSON-wire comparator, consume/claim cache entries, key HTTP state from stable effective authentication, return the effective successful request from retry handling, and retry previous_response_not_found with the full request in the same turn. Ship native OpenAI first. Add custom endpoints later through a provider-owned capability and canonical documented configuration only if the extra surface is still justified.
Alternatives considered: keep full-history SSE (safe, current behavior); add a distinct explicit stateful/cached SSE mode (clearest consent, but a new public surface); use durable Conversations API state (much larger persistence/product contract).
Code/contracts read: full PR head and current main transport/config/test surfaces; OpenAI provider hooks and turn-state headers; installed OpenAI SDK 6.49.0 request/auth/WebSocket sources; OpenAI conversation-state and data-retention docs; sibling Codex typed continuation, HTTP fallback, missing-response recovery, and WebSocket request construction.
Remaining uncertainty: contributor code was not executed locally. Exact-head CI is red only on an unrelated bash-tools.test.ts backgrounding flake, but the PR still has no authenticated HTTP continuation/fallback trace from a real endpoint.
2e241e1 to
7b6043a
Compare
7b6043a to
8c40736
Compare
8c40736 to
3b6ae95
Compare
|
Thanks for the detailed review — all four P1s addressed, plus the storage-nuance point, and one more found by a fresh autoreview pass along the way:
Storage nuance: agreed, and this is now the core design fix. Continuation only ever engages once Scope: narrowed to native OpenAI only per your best-fix verdict. The Real behavior proof: stood up a real OmniRoute instance with a genuine 292 tests passing across every |
|
No reply yet here (possibly because the PR is closed/merged and out of the usual review-notification path) — opened #123215 with the same follow-up question and full context, in case that's easier to pick up. Still happy to continue the conversation right here too. |
openclaw#122194 shipped the HTTP continuation cache (client-side delta + previous_response_id) for native api.openai.com connections only. #1 proposed a custom-endpoint opt-in but was built against a payload-policy design that never actually shipped when openclaw#122194 landed, so this reimplements the same intent against the real gating: supportsNativeOpenAIResponsesEndpoint in openai-responses-client.ts and the store-promotion path in openai-responses-payload-policy.ts. An operator can now set compat.supportsResponsesContinuation: true on a custom/proxy OpenAI-Responses-compatible model (e.g. a self-hosted OmniRoute deployment) once they've verified it correctly resolves previous_response_id and persists store: true turns. The endpoint itself carries no trust signal, so this explicit per-model opt-in is the only path to eligibility for a custom endpoint; native OpenAI behavior is unchanged. Fixes openclaw#123215. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vk2cBRQdErwRtPea8VuhG6
src/agents/openai-responses-payload-policy.test.ts asserted the pre-fix contract directly: "disable" mode forcing store:false even for a native, otherwise store-eligible OpenAI connection. That assertion predates the HTTP continuation feature (openclaw#122194), which never touched this file or the "disable" branch it covers, so it encoded the exact gap the continuation-store-policy fix closes rather than a deliberately preserved separate invariant. Updated the two reasoning-payload tests' expected store value to match the corrected policy, and split the mixed provider-policy/disable test into two: one confirming both modes now agree (true) for an eligible native connection, and a new one explicitly covering that disable mode still forces store off for a non-eligible (proxy) connection -- previously only implicit via a sibling reasoning-stripping test.
…ult 90m The 5-minute in-memory idle TTL for the OpenAI Responses HTTP continuation cache (previous_response_id reuse) has been unchanged since it was first introduced in openclaw#122194 -- git blame shows zero revisions to the line, and review only ever flagged the in-memory/process-local design generally, never the specific value. Five minutes is far shorter than the gap between two separate messages in an ordinary chat conversation (commonly minutes to hours apart), so the cache is almost always cold by the time the next turn's model call happens -- continuation only ever engaged within one multi-round tool-calling turn (seconds between rounds), never across separate incoming messages, even though sessionId and connection identity are both stable across turns (confirmed by tracing the full call chain). Bumps the default to 90 minutes and adds compat.responsesContinuationIdleMinutes as a per-model override, resolved through resolveOpenAIResponsesPayloadPolicy alongside the other Responses payload policy knobs.
src/agents/openai-responses-payload-policy.test.ts asserted the pre-fix contract directly: "disable" mode forcing store:false even for a native, otherwise store-eligible OpenAI connection. That assertion predates the HTTP continuation feature (openclaw#122194), which never touched this file or the "disable" branch it covers, so it encoded the exact gap the continuation-store-policy fix closes rather than a deliberately preserved separate invariant. Updated the two reasoning-payload tests' expected store value to match the corrected policy, and split the mixed provider-policy/disable test into two: one confirming both modes now agree (true) for an eligible native connection, and a new one explicitly covering that disable mode still forces store off for a non-eligible (proxy) connection -- previously only implicit via a sibling reasoning-stripping test.
src/agents/openai-responses-payload-policy.test.ts asserted the pre-fix contract directly: "disable" mode forcing store:false even for a native, otherwise store-eligible OpenAI connection. That assertion predates the HTTP continuation feature (openclaw#122194), which never touched this file or the "disable" branch it covers, so it encoded the exact gap the continuation-store-policy fix closes rather than a deliberately preserved separate invariant. Updated the two reasoning-payload tests' expected store value to match the corrected policy, and split the mixed provider-policy/disable test into two: one confirming both modes now agree (true) for an eligible native connection, and a new one explicitly covering that disable mode still forces store off for a non-eligible (proxy) connection -- previously only implicit via a sibling reasoning-stripping test.
…ation (#128633) * fix(ai): make store:true actually reachable for HTTP continuation buildOpenAIResponsesParams (the only shipped request builder for the OpenAI Responses SSE transport) always resolves its payload policy with storeMode: "disable". That mode forced explicitStore to false whenever the model had a store field at all -- which is true for any Responses API model, native api.openai.com included -- with no exception for a continuation-eligible connection. The HTTP continuation claim guard in openai-responses-client.ts requires params.store === true before it will even attempt to reuse previous_response_id, so that guard could never pass: continuation-eligible turns always resent the full input history and never got a previous_response_id, even seconds apart, well inside the continuation cache's idle TTL. "provider-policy" mode already had the correct rule (store:true when capabilities.allowsResponsesStore), it just wasn't applied to "disable" mode, whose whole point is "force store off by default" -- exactly the default that continuation eligibility is supposed to override. Every existing continuation test forced store:true via an onPayload hook, masking the gap; the new test uses an identity onPayload so it exercises the real, unstubbed policy computation. Confirmed the added test fails on pre-fix code (store: false instead of the expected true) and passes after the fix; full openai-responses transport suite (238 tests) still green. * fix(test): update payload-policy disable-mode expectations for store fix src/agents/openai-responses-payload-policy.test.ts asserted the pre-fix contract directly: "disable" mode forcing store:false even for a native, otherwise store-eligible OpenAI connection. That assertion predates the HTTP continuation feature (#122194), which never touched this file or the "disable" branch it covers, so it encoded the exact gap the continuation-store-policy fix closes rather than a deliberately preserved separate invariant. Updated the two reasoning-payload tests' expected store value to match the corrected policy, and split the mixed provider-policy/disable test into two: one confirming both modes now agree (true) for an eligible native connection, and a new one explicitly covering that disable mode still forces store off for a non-eligible (proxy) connection -- previously only implicit via a sibling reasoning-stripping test. * feat(ai): opt custom OpenAI-Responses endpoints into HTTP continuation previous_response_id) for native api.openai.com connections only. hartmark#1 proposed a custom-endpoint opt-in but was built against a payload-policy design that never actually shipped when gating: supportsNativeOpenAIResponsesEndpoint in openai-responses-client.ts and the store-promotion path in openai-responses-payload-policy.ts. An operator can now set compat.supportsResponsesContinuation: true on a custom/proxy OpenAI-Responses-compatible model (e.g. a self-hosted OmniRoute deployment) once they've verified it correctly resolves previous_response_id and persists store: true turns. The endpoint itself carries no trust signal, so this explicit per-model opt-in is the only path to eligibility for a custom endpoint; native OpenAI behavior is unchanged. Fixes #123215. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vk2cBRQdErwRtPea8VuhG6 * test(ai): prove HTTP continuation over a real loopback SSE server and live OpenAI continuation.integration.test.ts: a real loopback HTTP+SSE server (no SDK mocking), asserting the literal wire request carries previous_response_id and trimmed input across 2- and 3-turn chains for both a native OpenAI model and a compat.supportsResponsesContinuation-opted-in custom endpoint. continuation.live.test.ts: gated on OPENCLAW_LIVE_TEST=1 + OPENAI_API_KEY, puts a capturing forward-proxy in front of the real api.openai.com and proves *semantic* continuation -- turn 1 tells the model a secret, turn 2 asks it to recall the secret without the secret ever reappearing in the trimmed wire request, so a passing run is only possible if the real API resolved server-side state through previous_response_id. * fix(ai): scope the continuation opt-in to the custom openai-responses route only isResponsesApi is the broad Responses-API predicate -- it also matches openai-chatgpt-responses and its openclaw-transport alias. Gating explicitContinuationOptIn on that predicate meant an operator who sets compat.supportsResponsesContinuation on a ChatGPT/Codex-routed model could silently flip its deliberate store:false contract to true, since explicitContinuationOptIn is one of the OR branches that forces store on. Scope the opt-in to the specific custom openai-responses (and openclaw-openai-responses-transport) API values instead, matching the route this feature is actually documented and intended for. ChatGPT/Codex now stays store:false regardless of the compat flag, matching its existing allowsResponsesStore exclusion. * test(ai): prove a configured custom-endpoint compat opt-in survives model resolution Reproduces a real operator's live config: a self-hosted OmniRoute deployment configured entirely inline (no bundled plugin catalog backing it), with compat.supportsResponsesContinuation set on the model row. Existing coverage tests the payload-policy calculation directly; this proves the same config value actually reaches the resolved model object first. * fix(model-catalog): propagate supportsResponsesContinuation through catalog normalization Also cleans up a latent test-infra gap in openai-responses-prompt-observer.test.ts: its afterEach never called cleanupSessionResources(), so a stale httpContinuationEntries claim from one it.each iteration could leak into a later, unrelated iteration reusing the same sessionId. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vk2cBRQdErwRtPea8VuhG6 * docs(ai): reconcile contradictory proxy-route store guidance ClawSweeper P2: the new compat.supportsResponsesContinuation opt-in bullet says a compatible proxy persists store: true turns once opted in, while an existing summary bullet further down still said proxy routes never keep store unconditionally. Added the explicit exception to the summary bullet so both are consistent. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vk2cBRQdErwRtPea8VuhG6 * docs(ai): scope HTTP continuation wording to openai-responses, exclude ChatGPT/Codex ClawSweeper P2: line 113 said continuation applies to a 'native api.openai.com/ChatGPT-classed model', but supportsNativeOpenAIResponsesEndpoint() only matches provider=openai, api=openai-responses, base URL exactly https://api.openai.com/v1 -- openai-chatgpt-responses is never eligible and deliberately keeps store:false. Narrow the claim to what the code does. * test(ai): prove store:true comes from the real payload policy, not a forced hook ClawSweeper's finding: the live test's onPayload hook unconditionally forced store:true on every request, so the test passed even without the new compat.supportsResponsesContinuation policy actually deriving it -- it proved continuation worked, but not that the introduced opt-in policy is what enabled the storage that continuation depends on. Removed the store:true override. Added explicit assertions that both captured wire requests carry store:true, coming entirely from the real resolveOpenAIResponsesPayloadPolicy() resolution of the model's compat.supportsResponsesContinuation flag. Verified live against a real forward-proxied api.openai.com session (secret-recall scenario, unchanged): passes identically with the override removed -- confirms the real policy code path, not the test harness, is what makes this work. * fix(ai): restore the missing node:http import after the filename-collision rebase split #134423 landed with the same filename (continuation.integration.test.ts) this branch's own loopback-server compat-endpoint test already used, for an unrelated unsafe-integer/edited-arguments scenario. Rebasing split this branch's version into continuation-store-policy.integration.test.ts to resolve the collision, but the shared node:http import (originally above the diverging content) was dropped in the split -- restored it. * test(ai): align continuation helper with current main Keep one requestModel argument and port the six custom-endpoint calls to it, resolving the helper conflict without changing runtime policy. * chore(docs): regenerate config baseline for the new compat.supportsResponsesContinuation surface The compat opt-in this PR adds grew the core config surface from 2420 to 2421, but the generated baseline count/hash files weren't regenerated to match -- failing config:docs:check (checks-fast-baseline-ratchets and check-docs both ran it). Ran `pnpm config:docs:gen` per the check's own instruction; the growth is exactly the one new field this PR adds (already documented/justified by the PR itself), so no other config surface moved. * test(ai): stop asserting store's value in the output-clamp/retry test The store value here is this model's own explicitStore policy (native OpenAI is continuation-eligible by default), unrelated to what this test is actually about (token clamping and disabling implicit SDK retries) -- and already has dedicated, deterministic coverage in openai-responses-payload-policy.test.ts. Confirmed via repeated full packages/ai suite runs (combined with other in-flight PRs during a meta-PR rebuild) that this assertion resolves differently depending on what other test files ran earlier in the same process -- a real test-isolation leak elsewhere, not something this specific test should be asserting on in the first place. Removing the incidental assertion is the fix; the leak's actual source was not pursued further since it's orthogonal to this test's own contract and doesn't affect production behavior. * fix: keep Codex model attribution fixture focused (cherry picked from commit ca6ec6f) * test(scripts): answer the repository identity lookup in PR wrapper fixtures (cherry picked from commit e1c8eea) * test(scripts): update cleanup fixture repository metadata (cherry picked from commit 96e52e4) * fix(ai): preserve explicit no-store policy for continuation callers * docs(ai): distinguish continuation and instructions capabilities --------- Co-authored-by: Claude Sonnet 5 <[email protected]> Co-authored-by: RoboClaw <[email protected]> Co-authored-by: Patrick Erichsen <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
…ation (openclaw#128633) * fix(ai): make store:true actually reachable for HTTP continuation buildOpenAIResponsesParams (the only shipped request builder for the OpenAI Responses SSE transport) always resolves its payload policy with storeMode: "disable". That mode forced explicitStore to false whenever the model had a store field at all -- which is true for any Responses API model, native api.openai.com included -- with no exception for a continuation-eligible connection. The HTTP continuation claim guard in openai-responses-client.ts requires params.store === true before it will even attempt to reuse previous_response_id, so that guard could never pass: continuation-eligible turns always resent the full input history and never got a previous_response_id, even seconds apart, well inside the continuation cache's idle TTL. "provider-policy" mode already had the correct rule (store:true when capabilities.allowsResponsesStore), it just wasn't applied to "disable" mode, whose whole point is "force store off by default" -- exactly the default that continuation eligibility is supposed to override. Every existing continuation test forced store:true via an onPayload hook, masking the gap; the new test uses an identity onPayload so it exercises the real, unstubbed policy computation. Confirmed the added test fails on pre-fix code (store: false instead of the expected true) and passes after the fix; full openai-responses transport suite (238 tests) still green. * fix(test): update payload-policy disable-mode expectations for store fix src/agents/openai-responses-payload-policy.test.ts asserted the pre-fix contract directly: "disable" mode forcing store:false even for a native, otherwise store-eligible OpenAI connection. That assertion predates the HTTP continuation feature (openclaw#122194), which never touched this file or the "disable" branch it covers, so it encoded the exact gap the continuation-store-policy fix closes rather than a deliberately preserved separate invariant. Updated the two reasoning-payload tests' expected store value to match the corrected policy, and split the mixed provider-policy/disable test into two: one confirming both modes now agree (true) for an eligible native connection, and a new one explicitly covering that disable mode still forces store off for a non-eligible (proxy) connection -- previously only implicit via a sibling reasoning-stripping test. * feat(ai): opt custom OpenAI-Responses endpoints into HTTP continuation previous_response_id) for native api.openai.com connections only. hartmark#1 proposed a custom-endpoint opt-in but was built against a payload-policy design that never actually shipped when gating: supportsNativeOpenAIResponsesEndpoint in openai-responses-client.ts and the store-promotion path in openai-responses-payload-policy.ts. An operator can now set compat.supportsResponsesContinuation: true on a custom/proxy OpenAI-Responses-compatible model (e.g. a self-hosted OmniRoute deployment) once they've verified it correctly resolves previous_response_id and persists store: true turns. The endpoint itself carries no trust signal, so this explicit per-model opt-in is the only path to eligibility for a custom endpoint; native OpenAI behavior is unchanged. Fixes openclaw#123215. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vk2cBRQdErwRtPea8VuhG6 * test(ai): prove HTTP continuation over a real loopback SSE server and live OpenAI continuation.integration.test.ts: a real loopback HTTP+SSE server (no SDK mocking), asserting the literal wire request carries previous_response_id and trimmed input across 2- and 3-turn chains for both a native OpenAI model and a compat.supportsResponsesContinuation-opted-in custom endpoint. continuation.live.test.ts: gated on OPENCLAW_LIVE_TEST=1 + OPENAI_API_KEY, puts a capturing forward-proxy in front of the real api.openai.com and proves *semantic* continuation -- turn 1 tells the model a secret, turn 2 asks it to recall the secret without the secret ever reappearing in the trimmed wire request, so a passing run is only possible if the real API resolved server-side state through previous_response_id. * fix(ai): scope the continuation opt-in to the custom openai-responses route only isResponsesApi is the broad Responses-API predicate -- it also matches openai-chatgpt-responses and its openclaw-transport alias. Gating explicitContinuationOptIn on that predicate meant an operator who sets compat.supportsResponsesContinuation on a ChatGPT/Codex-routed model could silently flip its deliberate store:false contract to true, since explicitContinuationOptIn is one of the OR branches that forces store on. Scope the opt-in to the specific custom openai-responses (and openclaw-openai-responses-transport) API values instead, matching the route this feature is actually documented and intended for. ChatGPT/Codex now stays store:false regardless of the compat flag, matching its existing allowsResponsesStore exclusion. * test(ai): prove a configured custom-endpoint compat opt-in survives model resolution Reproduces a real operator's live config: a self-hosted OmniRoute deployment configured entirely inline (no bundled plugin catalog backing it), with compat.supportsResponsesContinuation set on the model row. Existing coverage tests the payload-policy calculation directly; this proves the same config value actually reaches the resolved model object first. * fix(model-catalog): propagate supportsResponsesContinuation through catalog normalization Also cleans up a latent test-infra gap in openai-responses-prompt-observer.test.ts: its afterEach never called cleanupSessionResources(), so a stale httpContinuationEntries claim from one it.each iteration could leak into a later, unrelated iteration reusing the same sessionId. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vk2cBRQdErwRtPea8VuhG6 * docs(ai): reconcile contradictory proxy-route store guidance ClawSweeper P2: the new compat.supportsResponsesContinuation opt-in bullet says a compatible proxy persists store: true turns once opted in, while an existing summary bullet further down still said proxy routes never keep store unconditionally. Added the explicit exception to the summary bullet so both are consistent. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vk2cBRQdErwRtPea8VuhG6 * docs(ai): scope HTTP continuation wording to openai-responses, exclude ChatGPT/Codex ClawSweeper P2: line 113 said continuation applies to a 'native api.openai.com/ChatGPT-classed model', but supportsNativeOpenAIResponsesEndpoint() only matches provider=openai, api=openai-responses, base URL exactly https://api.openai.com/v1 -- openai-chatgpt-responses is never eligible and deliberately keeps store:false. Narrow the claim to what the code does. * test(ai): prove store:true comes from the real payload policy, not a forced hook ClawSweeper's finding: the live test's onPayload hook unconditionally forced store:true on every request, so the test passed even without the new compat.supportsResponsesContinuation policy actually deriving it -- it proved continuation worked, but not that the introduced opt-in policy is what enabled the storage that continuation depends on. Removed the store:true override. Added explicit assertions that both captured wire requests carry store:true, coming entirely from the real resolveOpenAIResponsesPayloadPolicy() resolution of the model's compat.supportsResponsesContinuation flag. Verified live against a real forward-proxied api.openai.com session (secret-recall scenario, unchanged): passes identically with the override removed -- confirms the real policy code path, not the test harness, is what makes this work. * fix(ai): restore the missing node:http import after the filename-collision rebase split openclaw#134423 landed with the same filename (continuation.integration.test.ts) this branch's own loopback-server compat-endpoint test already used, for an unrelated unsafe-integer/edited-arguments scenario. Rebasing split this branch's version into continuation-store-policy.integration.test.ts to resolve the collision, but the shared node:http import (originally above the diverging content) was dropped in the split -- restored it. * test(ai): align continuation helper with current main Keep one requestModel argument and port the six custom-endpoint calls to it, resolving the helper conflict without changing runtime policy. * chore(docs): regenerate config baseline for the new compat.supportsResponsesContinuation surface The compat opt-in this PR adds grew the core config surface from 2420 to 2421, but the generated baseline count/hash files weren't regenerated to match -- failing config:docs:check (checks-fast-baseline-ratchets and check-docs both ran it). Ran `pnpm config:docs:gen` per the check's own instruction; the growth is exactly the one new field this PR adds (already documented/justified by the PR itself), so no other config surface moved. * test(ai): stop asserting store's value in the output-clamp/retry test The store value here is this model's own explicitStore policy (native OpenAI is continuation-eligible by default), unrelated to what this test is actually about (token clamping and disabling implicit SDK retries) -- and already has dedicated, deterministic coverage in openai-responses-payload-policy.test.ts. Confirmed via repeated full packages/ai suite runs (combined with other in-flight PRs during a meta-PR rebuild) that this assertion resolves differently depending on what other test files ran earlier in the same process -- a real test-isolation leak elsewhere, not something this specific test should be asserting on in the first place. Removing the incidental assertion is the fix; the leak's actual source was not pursued further since it's orthogonal to this test's own contract and doesn't affect production behavior. * fix: keep Codex model attribution fixture focused (cherry picked from commit ca6ec6f) * test(scripts): answer the repository identity lookup in PR wrapper fixtures (cherry picked from commit e1c8eea) * test(scripts): update cleanup fixture repository metadata (cherry picked from commit 96e52e4) * fix(ai): preserve explicit no-store policy for continuation callers * docs(ai): distinguish continuation and instructions capabilities --------- Co-authored-by: Claude Sonnet 5 <[email protected]> Co-authored-by: RoboClaw <[email protected]> Co-authored-by: Patrick Erichsen <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
Direct OpenAI API-key traffic defaults to HTTP/SSE. Those turns already use provider-managed response storage on the normal embedded runtime, but OpenClaw still rebuilt and resent the complete Responses history on every turn instead of using the stored prior response.
Why This Change Was Made
This rewrite adds one native-only HTTP continuation owner. When the final egress request is already
store: true, an officialapi.openai.com/v1SSE turn can claim the prior session response, send only appended input withprevious_response_id, and commit the next baseline after a genuine completed response.It reuses the JSON-wire comparator from #122483, keys state by stable effective authentication, permits one active claim, fences cleanup and late completion, and retries
previous_response_not_foundwith full history inside the same user turn. It never enables storage, never overridesstore: false, and does not add custom-provider, Azure, ChatGPT, config, environment, file, or database surface.The original contributor implementation and investigation established the HTTP/SSE payload-growth problem. This maintainer rewrite preserves that contribution while narrowing the product contract and repairing lifecycle/retry ownership.
Production LOC: +354/-180 (net +174) | Tests: +557/-8 (net +549) | Docs/config/generated: 0
User Impact
Stateful native OpenAI SSE sessions now send only new input after the first turn. Stateless callers and non-native endpoints retain the existing full-history behavior. If upstream state is missing or expired, the current user turn recovers automatically with a full-history request rather than failing or waiting until the next message.
Evidence
previous_response_id.b72e31b902a9d18a13d2ae3279abca2d6c472e95: replay-and-tools 49 tests and continuation suites 14 tests passed; the patch-identical feature commit also passed 10 transport suites / 162 tests before the test-only follow-up.24399fd8615045b000323a9b3f8fdc4777f7d4f3: core and coreTests passed, including typecheck, lint, dead exports, API baseline, boundaries, schema, storage guards, and import cycles.b72e31b902a9d18a13d2ae3279abca2d6c472e95: run 31610191608 attempt 2 passed; the only retry was an unrelated Gateway device-join flake that passed locally and on its single-job rerun.previous_response_idpresent, one input item, HTTP 200;stopReason=stop.AI-assisted: yes. Maintainer rewrite and proof by Peter Steinberger. Original contribution by @hartmark.