Skip to content

Commit 74437ef

Browse files
committed
fix(responses): drop legacy cache retention for GPT-5.6
1 parent 63bfd14 commit 74437ef

2 files changed

Lines changed: 66 additions & 0 deletions

File tree

‎src/adapters/openai-responses.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,20 @@ function stripUnsupportedReasoningParams(body: unknown): unknown {
185185
return { ...body, reasoning: Object.keys(rest).length > 0 ? rest : undefined };
186186
}
187187

188+
/**
189+
* GPT-5.6 replaced the legacy 24-hour retention field with `prompt_cache_options.ttl`.
190+
* Do not translate `24h` to the new field: GPT-5.6 currently accepts a different TTL contract,
191+
* and implicit caching remains available when the caller did not send the replacement options.
192+
*/
193+
function stripDeprecatedPromptCacheRetention(body: unknown, modelId: unknown): unknown {
194+
if (!isPlainObject(body)) return body;
195+
if (typeof modelId !== "string") return body;
196+
if (modelId !== "gpt-5.6" && !modelId.startsWith("gpt-5.6-")) return body;
197+
if (!Object.hasOwn(body, "prompt_cache_retention")) return body;
198+
const { prompt_cache_retention: _retention, ...rest } = body;
199+
return rest;
200+
}
201+
188202
/**
189203
* A false model capability prevents Codex from emitting summary fields after the catalog refresh.
190204
* Strip them here as well so an already-running client with a stale catalog cannot keep sending an
@@ -1522,6 +1536,7 @@ export function createResponsesPassthroughAdapter(provider: OcxProviderConfig):
15221536
outBody = rewritten.body;
15231537
convertedRoutedCustomToolNames = rewritten.names;
15241538
}
1539+
outBody = stripDeprecatedPromptCacheRetention(outBody, parsed.modelId);
15251540
const sanitizedBody = normalizeToolSchemas(stripSparkCompatibility(stripUnsupportedReasoningParams(stripItemIdsWhenUnstored(stripInvalidItemIds(stripUnsupportedHostedTools(sanitizeReasoningInputContent(scrubOcxCompactionItems(outBody), { preserveRawReasoningContent: provider.preserveResponsesReasoningContent === true })))))));
15261541
const finalBody = stripDisabledReasoningSummaries(
15271542
normalizeConfiguredReasoningSummaryDelivery(sanitizedBody, provider, parsed.modelId),

‎tests/openai-responses-passthrough.test.ts‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,57 @@ describe("OpenAI Responses passthrough sanitization", () => {
822822
expect(body.prompt_cache_retention).toBe("24h");
823823
});
824824

825+
test.each([
826+
"gpt-5.6",
827+
"gpt-5.6-sol",
828+
"gpt-5.6-terra",
829+
"gpt-5.6-luna",
830+
])("drops deprecated prompt_cache_retention for %s without inventing replacement options", modelId => {
831+
const adapter = createResponsesPassthroughAdapter(provider);
832+
const request = adapter.buildRequest({
833+
modelId,
834+
context: { messages: [] },
835+
stream: true,
836+
options: {},
837+
_rawBody: {
838+
model: modelId,
839+
input: "hi",
840+
prompt_cache_retention: "24h",
841+
},
842+
}, { headers: new Headers({ authorization: "Bearer token" }) });
843+
const body = JSON.parse(request.body) as {
844+
prompt_cache_retention?: string;
845+
prompt_cache_options?: unknown;
846+
};
847+
848+
expect(body.prompt_cache_retention).toBeUndefined();
849+
expect(body.prompt_cache_options).toBeUndefined();
850+
});
851+
852+
test("preserves caller prompt_cache_options while dropping GPT-5.6 legacy retention", () => {
853+
const adapter = createResponsesPassthroughAdapter(provider);
854+
const promptCacheOptions = { mode: "explicit", ttl: "30m" };
855+
const request = adapter.buildRequest({
856+
modelId: "gpt-5.6-sol",
857+
context: { messages: [] },
858+
stream: true,
859+
options: {},
860+
_rawBody: {
861+
model: "gpt-5.6-sol",
862+
input: "hi",
863+
prompt_cache_retention: "24h",
864+
prompt_cache_options: promptCacheOptions,
865+
},
866+
}, { headers: new Headers({ authorization: "Bearer token" }) });
867+
const body = JSON.parse(request.body) as {
868+
prompt_cache_retention?: string;
869+
prompt_cache_options?: unknown;
870+
};
871+
872+
expect(body.prompt_cache_retention).toBeUndefined();
873+
expect(body.prompt_cache_options).toEqual(promptCacheOptions);
874+
});
875+
825876
const expandedRawBody = {
826877
model: "gpt-5.5",
827878
previous_response_id: "resp_1",

0 commit comments

Comments
 (0)