-
Notifications
You must be signed in to change notification settings - Fork 788
fix(server): default store:false on /v1/responses inbound when omitted #1743
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Wibias
merged 4 commits into
lidge-jun:dev
from
SOSANA:fix/responses-inbound-default-store-false
Aug 15, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d792cee
fix(server): default store:false on /v1/responses inbound when omitted
noreply 9ba153f
fix(server): scope store:false default to the canonical forward Codex…
SOSANA 621b14d
test(responses): pin forward-route explicit store:false preservation
SOSANA 068ff1e
fix(server): gate store:false default on the canonical Codex forward …
SOSANA File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| /** | ||
| * Generic Responses-API clients (AI-SDK apps such as ZCode) omit `store`, but the | ||
| * canonical forward Codex backend rejects a native request without an explicit | ||
| * store:false ("Store must be set to false"). The default is applied only after | ||
| * routing settles and only on the canonical Codex forward backend | ||
| * (isCanonicalOpenAiForwardProvider: adapter + forward auth + the canonical base | ||
| * URL). Every other Responses upstream — key-auth providers and custom forward | ||
| * gateways alike — intentionally keeps the omitted-store server-side default so a | ||
| * later turn can continue through an unexpanded previous_response_id. These tests | ||
| * pin the scoped default (forward positive cases), the key-auth and custom-gateway | ||
| * negatives, and explicit-value survival on both sides. | ||
| * | ||
| * End-to-end cases assert the captured upstream request body — the externally | ||
| * observable payload. Pattern mirrors tests/responses-compaction-routing.test.ts | ||
| * and tests/github-copilot-wire-defaults.test.ts. | ||
| */ | ||
| import { afterEach, describe, expect, test } from "bun:test"; | ||
| import { CODEX_FORWARD_BASE_URL } from "../src/providers/openai-tiers"; | ||
| import { handleResponses } from "../src/server/responses"; | ||
| import type { OcxConfig, OcxProviderConfig } from "../src/types"; | ||
|
|
||
| function providerConfig(overrides: Partial<OcxProviderConfig> = {}): OcxConfig { | ||
| return { | ||
| defaultProvider: "gw", | ||
| providers: { | ||
| gw: { | ||
| adapter: "openai-responses", | ||
| baseUrl: CODEX_FORWARD_BASE_URL, | ||
| authMode: "key", | ||
| apiKey: "test-key", | ||
| ...overrides, | ||
| }, | ||
| }, | ||
| } as unknown as OcxConfig; | ||
| } | ||
|
|
||
| describe("/v1/responses defaults store:false only for the canonical forward Codex backend", () => { | ||
| const originalFetch = globalThis.fetch; | ||
| afterEach(() => { globalThis.fetch = originalFetch; }); | ||
|
|
||
| function captureUpstream(): { urls: string[]; bodies: string[] } { | ||
| const urls: string[] = []; | ||
| const bodies: string[] = []; | ||
| globalThis.fetch = (async (input: RequestInfo | URL, init?: RequestInit) => { | ||
| urls.push(String(input)); | ||
| const body = | ||
| input instanceof Request ? await input.clone().text() | ||
| : typeof init?.body === "string" ? init.body | ||
| : ""; | ||
| bodies.push(body); | ||
| return new Response("data: [DONE]\n\n", { | ||
| status: 200, | ||
| headers: { "content-type": "text/event-stream" }, | ||
| }); | ||
| }) as typeof fetch; | ||
| return { urls, bodies }; | ||
| } | ||
|
|
||
| async function drive( | ||
| config: OcxConfig, | ||
| store: unknown, | ||
| ): Promise<{ url: string; body: Record<string, unknown> | null }> { | ||
| const { urls, bodies } = captureUpstream(); | ||
| await handleResponses( | ||
| new Request("http://localhost/v1/responses", { | ||
| method: "POST", | ||
| headers: { "content-type": "application/json" }, | ||
| body: JSON.stringify({ | ||
| model: "gw/some-model", | ||
| input: [{ type: "message", role: "user", content: [{ type: "input_text", text: "ping" }] }], | ||
| stream: true, | ||
| ...(store === undefined ? {} : { store }), | ||
| }), | ||
| }), | ||
| config, | ||
| { model: "", provider: "" }, | ||
| ); | ||
| let parsed: Record<string, unknown> | null = null; | ||
| try { parsed = bodies[0] ? (JSON.parse(bodies[0]) as Record<string, unknown>) : null; } catch { parsed = null; } | ||
| return { url: urls[0] ?? "", body: parsed }; | ||
| } | ||
|
|
||
| test("forward route: omitted store reaches the upstream Responses request as false", async () => { | ||
| const { url, body } = await drive(providerConfig({ authMode: "forward" }), undefined); | ||
| expect(url).toContain("/responses"); | ||
| expect(body).not.toBeNull(); | ||
| expect((body as Record<string, unknown>).store).toBe(false); | ||
| }); | ||
|
|
||
| test("key-auth route: omitted store is NOT injected (stateful upstream keeps its default)", async () => { | ||
| const { body } = await drive(providerConfig(), undefined); | ||
| expect(body).not.toBeNull(); | ||
| expect(!("store" in (body as Record<string, unknown>))).toBe(true); | ||
| }); | ||
|
|
||
| test("custom forward gateway: omitted store is NOT injected (non-canonical base URL keeps its default)", async () => { | ||
| const { body } = await drive( | ||
| providerConfig({ authMode: "forward", baseUrl: "https://gateway.example/v1" }), | ||
| undefined, | ||
| ); | ||
| expect(body).not.toBeNull(); | ||
| expect(!("store" in (body as Record<string, unknown>))).toBe(true); | ||
| }); | ||
|
|
||
| test("forward route: explicit store:true is preserved", async () => { | ||
| const { body } = await drive(providerConfig({ authMode: "forward" }), true); | ||
| expect(body).not.toBeNull(); | ||
| expect((body as Record<string, unknown>).store).toBe(true); | ||
| }); | ||
|
|
||
| test("forward route: explicit store:false is preserved", async () => { | ||
| const { body } = await drive(providerConfig({ authMode: "forward" }), false); | ||
| expect(body).not.toBeNull(); | ||
| expect((body as Record<string, unknown>).store).toBe(false); | ||
| }); | ||
|
|
||
| test("key-auth route: explicit store:false is preserved", async () => { | ||
| const { body } = await drive(providerConfig(), false); | ||
| expect(body).not.toBeNull(); | ||
| expect((body as Record<string, unknown>).store).toBe(false); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.