CLI: suppress Codex native search summary when web search is off

This commit is contained in:
Christof Salis
2026-03-17 06:18:17 +01:00
committed by Peter Steinberger
parent 0a891543c9
commit 13f1190149
3 changed files with 73 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
import { describe, expect, it } from "vitest";
import {
buildCodexNativeWebSearchTool,
describeCodexNativeWebSearch,
patchCodexNativeWebSearchPayload,
resolveCodexNativeSearchActivation,
resolveCodexNativeWebSearchConfig,
@@ -108,6 +109,24 @@ describe("resolveCodexNativeSearchActivation", () => {
});
describe("Codex native web-search payload helpers", () => {
it("omits the summary when global web search is disabled", () => {
expect(
describeCodexNativeWebSearch({
tools: {
web: {
search: {
enabled: false,
openaiCodex: {
enabled: true,
mode: "live",
},
},
},
},
}),
).toBeUndefined();
});
it("normalizes optional config values", () => {
const result = resolveCodexNativeWebSearchConfig({
tools: {

View File

@@ -295,6 +295,10 @@ export function isCodexNativeWebSearchRelevant(params: {
export function describeCodexNativeWebSearch(
config: OpenClawConfig | undefined,
): string | undefined {
if (config?.tools?.web?.search?.enabled === false) {
return undefined;
}
const nativeConfig = resolveCodexNativeWebSearchConfig(config);
if (!nativeConfig.enabled) {
return undefined;

View File

@@ -556,4 +556,54 @@ describe("finalizeSetupWizard", () => {
);
expect(prompter.note).not.toHaveBeenCalledWith(expect.any(String), "Dashboard ready");
});
it("does not show a Codex native search summary when web search is globally disabled", async () => {
const note = vi.fn(async () => {});
const prompter = buildWizardPrompter({
note,
select: vi.fn(async () => "later") as never,
confirm: vi.fn(async () => false),
});
await finalizeSetupWizard({
flow: "advanced",
opts: {
acceptRisk: true,
authChoice: "skip",
installDaemon: false,
skipHealth: true,
skipUi: true,
},
baseConfig: {},
nextConfig: {
tools: {
web: {
search: {
enabled: false,
openaiCodex: {
enabled: true,
mode: "cached",
},
},
},
},
},
workspaceDir: "/tmp",
settings: {
port: 18789,
bind: "loopback",
authMode: "token",
gatewayToken: undefined,
tailscaleMode: "off",
tailscaleResetOnExit: false,
},
prompter,
runtime: createRuntime(),
});
expect(note).not.toHaveBeenCalledWith(
expect.stringContaining("Codex native search:"),
"Codex native search",
);
});
});