mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 13:38:31 +00:00
fix(codex): preserve Responses text format
Add "text" to Codex Responses API allowlist so text.format.json_schema reaches upstream for structured outputs instead of being stripped. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
committed by
decolua
co-authored by
Cursor
parent
c842dc8f07
commit
e544bfceae
@@ -32,7 +32,8 @@ const CODEX_PASSTHROUGH_TOOL_TYPES = new Set(["custom"]);
|
|||||||
// Allowlist of fields accepted by Codex Responses API — anything else is stripped
|
// Allowlist of fields accepted by Codex Responses API — anything else is stripped
|
||||||
const RESPONSES_API_ALLOWLIST = new Set([
|
const RESPONSES_API_ALLOWLIST = new Set([
|
||||||
"model", "input", "instructions", "tools", "tool_choice", "stream", "store",
|
"model", "input", "instructions", "tools", "tool_choice", "stream", "store",
|
||||||
"reasoning", "service_tier", "include", "prompt_cache_key", "client_metadata"
|
"reasoning", "service_tier", "include", "prompt_cache_key", "client_metadata",
|
||||||
|
"text"
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Convert role=system → role=developer in body.input (keeps content in cacheable prefix)
|
// Convert role=system → role=developer in body.input (keeps content in cacheable prefix)
|
||||||
|
|||||||
@@ -20,6 +20,47 @@ function normalizeTools(tools) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe("CodexExecutor tool normalization", () => {
|
describe("CodexExecutor tool normalization", () => {
|
||||||
|
it("preserves Responses text.format for structured outputs", () => {
|
||||||
|
const executor = new CodexExecutor();
|
||||||
|
const schema = {
|
||||||
|
type: "object",
|
||||||
|
additionalProperties: false,
|
||||||
|
properties: {
|
||||||
|
title: { type: "string" },
|
||||||
|
},
|
||||||
|
required: ["title"],
|
||||||
|
};
|
||||||
|
const body = {
|
||||||
|
model: "gpt-5.4-mini",
|
||||||
|
input: [{ type: "message", role: "user", content: [{ type: "input_text", text: "test for session title" }] }],
|
||||||
|
stream: true,
|
||||||
|
metadata: { unsupported: true },
|
||||||
|
text: {
|
||||||
|
format: {
|
||||||
|
type: "json_schema",
|
||||||
|
name: "codex_output_schema",
|
||||||
|
strict: true,
|
||||||
|
schema,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
executor.transformRequest("gpt-5.4-mini", body, true, {
|
||||||
|
connectionId: "test-codex-structured-output",
|
||||||
|
providerSpecificData: {},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(body.text).toEqual({
|
||||||
|
format: {
|
||||||
|
type: "json_schema",
|
||||||
|
name: "codex_output_schema",
|
||||||
|
strict: true,
|
||||||
|
schema,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
expect(body.metadata).toBeUndefined();
|
||||||
|
});
|
||||||
|
|
||||||
it("preserves Responses-native tool_search tools", () => {
|
it("preserves Responses-native tool_search tools", () => {
|
||||||
const tools = normalizeTools([
|
const tools = normalizeTools([
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user