fix(config): respect disabled web search auto-enable

This commit is contained in:
Peter Steinberger
2026-05-03 22:26:40 +01:00
parent fa5c90f9fd
commit f79eeea49c
2 changed files with 49 additions and 2 deletions

View File

@@ -104,6 +104,52 @@ describe("applyPluginAutoEnable providers", () => {
expect(result.changes).toContain("brave web search provider selected, enabled automatically.");
});
it("does not auto-enable selected web search provider plugins when web search is disabled", () => {
const result = applyPluginAutoEnable({
config: {
tools: {
web: {
search: {
enabled: false,
provider: "brave",
},
},
},
plugins: {
allow: ["telegram"],
},
agents: {
defaults: {
model: "codex/gpt-5.4",
},
},
},
env,
manifestRegistry: makeRegistry([
{
id: "brave",
channels: [],
contracts: {
webSearchProviders: ["brave"],
},
},
{
id: "codex",
channels: [],
providers: ["codex"],
},
]),
});
expect(result.config.plugins?.entries?.codex?.enabled).toBe(true);
expect(result.config.plugins?.entries?.brave).toBeUndefined();
expect(result.config.plugins?.allow).toEqual(["telegram", "codex"]);
expect(result.changes).toContain("codex/gpt-5.4 model configured, enabled automatically.");
expect(result.changes).not.toContain(
"brave web search provider selected, enabled automatically.",
);
});
it("materializes xai setup auto-enable when the plugin-owned x_search tool is configured", () => {
const result = materializePluginAutoEnableCandidates({
config: {

View File

@@ -280,7 +280,7 @@ function collectPluginIdsForConfiguredChannel(
}
if (claims.length === 0) {
return [];
return builtInId ? [builtInId] : [];
}
const claimIds = new Set(claims.map((claim) => claim.plugin.id));
@@ -645,8 +645,9 @@ export function resolveConfiguredPluginAutoEnableCandidates(params: {
}
}
const webSearchConfig = params.config.tools?.web?.search;
const webSearchProvider =
typeof params.config.tools?.web?.search?.provider === "string"
webSearchConfig?.enabled !== false && typeof webSearchConfig?.provider === "string"
? params.config.tools.web.search.provider
: undefined;
const webSearchPluginId = resolvePluginIdForConfiguredWebSearchProvider(