Skip to content

fix(agents): strip store param from payload when supportsStore is false#39219

Closed
ademczuk wants to merge 2 commits intoopenclaw:mainfrom
ademczuk:fix/strip-store-false-compat
Closed

fix(agents): strip store param from payload when supportsStore is false#39219
ademczuk wants to merge 2 commits intoopenclaw:mainfrom
ademczuk:fix/strip-store-false-compat

Conversation

@ademczuk
Copy link
Copy Markdown
Contributor

@ademczuk ademczuk commented Mar 7, 2026

Summary

Fixes bug #1 from #39086: when a model declares compat: { supportsStore: false }, the store: false field that pi-ai upstream hardcodes for Responses API payloads is now stripped before the request reaches the provider.

Previously, createOpenAIResponsesContextManagementWrapper() early-exited without installing an onPayload hook when neither forceStore nor useServerCompaction applied. This left the upstream-injected store: false in the payload, which strict OpenAI-compatible endpoints (e.g. Gemini via Cloudflare AI Gateway) reject as an unknown field with HTTP 400.

Changes

  • extra-params.ts: added stripStore condition that prevents the early exit and deletes store from the payload via onPayload when supportsStore === false
  • Updated existing test to verify store is absent (not just not forced to true)
  • Added new test for non-OpenAI provider (Gemini via Cloudflare) with supportsStore: false

Scope

This PR addresses only bug #1 (store parameter). Bug #2 (custom headers dropped) from #39086 is a separate concern and intentionally excluded to keep the change small.

Test plan

  • Existing test updated: strips store from payload for models that declare supportsStore=false
  • New test added: strips store from payload for non-OpenAI responses providers with supportsStore=false
  • All 57 tests in pi-embedded-runner-extraparams.test.ts pass
  • CI green

Fixes #39086 (partial: bug #1 only)

@openclaw-barnacle openclaw-barnacle bot added agents Agent runtime and tooling size: XS labels Mar 7, 2026
@ademczuk
Copy link
Copy Markdown
Contributor Author

ademczuk commented Mar 7, 2026

@Takhoffman Would appreciate your review on this one - small targeted fix for the store parameter issue reported in #39086.

The core problem: createOpenAIResponsesContextManagementWrapper() early-exits at line 308 when neither forceStore nor useServerCompaction apply. This skips the onPayload hook entirely, so the store: false that pi-ai upstream hardcodes for Responses API stays in the payload. Strict OpenAI-compatible endpoints (Gemini via Cloudflare AI Gateway) reject it as an unknown field.

Fix adds a stripStore path that installs the hook and deletes store from the payload when compat.supportsStore === false. Two files changed, 34 lines added.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 7, 2026

Greptile Summary

This PR fixes a targeted bug where the upstream pi-ai library hardcodes store: false in Responses API payloads, causing strict OpenAI-compatible endpoints (e.g. Gemini via Cloudflare AI Gateway) to reject requests with HTTP 400 when the model declares compat: { supportsStore: false }. The fix adds a stripStore condition that prevents the early-exit path and installs an onPayload hook to delete the store field before the request reaches the provider.

  • extra-params.ts: Adds a stripStore boolean computed from !forceStore && OPENAI_RESPONSES_APIS.has(model.api) && model.compat?.supportsStore === false, and uses it to both prevent the early-return and delete payloadObj.store in the hook. The forceStore and stripStore branches are mutually exclusive by construction (since shouldForceResponsesStore already returns false when supportsStore === false), so the ordering of the two if blocks is safe.
  • Test updates: The existing Azure OpenAI test assertion is correctly tightened from toBe(false) to not.toHaveProperty("store"), and a new test covers a non-OPENAI_RESPONSES_PROVIDERS custom provider (Gemini via Cloudflare), validating that provider membership in OPENAI_RESPONSES_PROVIDERS is not required for stripping to occur.

Confidence Score: 5/5

  • This PR is safe to merge — it is a narrow, well-tested fix with no risk of regressions to existing behaviour.
  • The change is minimal and surgical: one new boolean (stripStore) and one delete in an already-isolated onPayload hook. The conditions are mutually exclusive with the existing forceStore path by design, so the fix cannot interfere with direct OpenAI or Azure Responses store-forcing behaviour. Two new/updated test cases directly verify the affected code path for both an Azure and a custom provider scenario.
  • No files require special attention.

Last reviewed commit: 608e201

@steipete
Copy link
Copy Markdown
Contributor

steipete commented Mar 7, 2026

Landed on main in 3a761fbcf.

What we changed while landing:

  • kept your core compatibility fix: remove store from Responses payloads when compat.supportsStore === false
  • kept provider coverage for non-OpenAI OpenAI-compatible Responses providers
  • kept the TS-safe compat access refinement
  • retained/expanded regression coverage in pi-embedded-runner-extraparams.test.ts for both direct and non-OpenAI provider paths
  • added changelog entry under 2026.3.7 fixes

Source commits reviewed:

Thanks @ademczuk.

@steipete steipete closed this Mar 7, 2026
@ademczuk
Copy link
Copy Markdown
Contributor Author

ademczuk commented Mar 7, 2026

Cheers for landing this. Good catch tightening the type narrowing on the cast.

@ademczuk
Copy link
Copy Markdown
Contributor Author

ademczuk commented Mar 7, 2026

@Takhoffman - would appreciate your review when you have a moment. This is a small fix (2 files, +23/-1) for #39086 where strict OpenAI-compatible endpoints reject the store field that pi-ai hardcodes.

Rebased onto latest main, all CI green, 58 tests passing.

vincentkoc pushed a commit to BryanTegomoh/openclaw-fork that referenced this pull request Mar 8, 2026
ziomancer pushed a commit to ziomancer/openclaw that referenced this pull request Mar 8, 2026
openperf pushed a commit to openperf/moltbot that referenced this pull request Mar 8, 2026
mcaxtr pushed a commit to mcaxtr/openclaw that referenced this pull request Mar 8, 2026
Saitop pushed a commit to NomiciAI/openclaw that referenced this pull request Mar 8, 2026
GordonSH-oss pushed a commit to GordonSH-oss/openclaw that referenced this pull request Mar 9, 2026
jenawant pushed a commit to jenawant/openclaw that referenced this pull request Mar 10, 2026
dhoman pushed a commit to dhoman/chrono-claw that referenced this pull request Mar 11, 2026
senw-developers pushed a commit to senw-developers/va-openclaw that referenced this pull request Mar 17, 2026
V-Gutierrez pushed a commit to V-Gutierrez/openclaw-vendor that referenced this pull request Mar 17, 2026
alexey-pelykh pushed a commit to remoteclaw/remoteclaw that referenced this pull request Mar 21, 2026
alexey-pelykh added a commit to remoteclaw/remoteclaw that referenced this pull request Mar 21, 2026
…, thanks @ademczuk) (#1764)

(cherry picked from commit 3a761fb)

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: store: false is still sent in embedded agent runs despite compat.supportsStore: false, and custom headers are dropped

2 participants