Codex: use model-level API for native search relevance

This commit is contained in:
Christof Salis 2026-03-15 11:40:51 +01:00
parent 21270f900b
commit 160fda3f29
2 changed files with 44 additions and 1 deletions

View File

@ -209,3 +209,43 @@ describe("shouldSuppressManagedWebSearchTool", () => {
).toBe(false);
});
});
describe("isCodexNativeWebSearchRelevant", () => {
it("treats a default model with model-level openai-codex-responses api as relevant", async () => {
const { isCodexNativeWebSearchRelevant } = await import("./codex-native-web-search.js");
expect(
isCodexNativeWebSearchRelevant({
config: {
agents: {
defaults: {
model: {
primary: "gateway/gpt-5.4",
},
},
},
models: {
providers: {
gateway: {
api: "openai-responses",
baseUrl: "https://gateway.example/v1",
models: [
{
id: "gpt-5.4",
name: "gpt-5.4",
api: "openai-codex-responses",
reasoning: false,
input: ["text"],
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
contextWindow: 128_000,
maxTokens: 16_384,
},
],
},
},
},
},
}),
).toBe(true);
});
});

View File

@ -283,9 +283,12 @@ export function isCodexNativeWebSearchRelevant(params: {
agentId: params.agentId,
});
const configuredProvider = params.config.models?.providers?.[defaultModel.provider];
const configuredModelApi = configuredProvider?.models?.find(
(candidate) => candidate.id === defaultModel.model,
)?.api;
return isCodexNativeSearchEligibleModel({
modelProvider: defaultModel.provider,
modelApi: configuredProvider?.api,
modelApi: configuredModelApi ?? configuredProvider?.api,
});
}