2e425b7b65
- Described "auto" default gating MCP tools past 40-tool threshold. - Noted late resolution in createAgentSession after registry exists. - Updated legacy mcp.discoveryMode mapping to MCP-only.
46 lines
2.3 KiB
TypeScript
46 lines
2.3 KiB
TypeScript
import { describe, expect, it } from "bun:test";
|
|
import { Settings } from "../../src/config/settings";
|
|
import { resolveEffectiveToolDiscoveryMode, TOOL_DISCOVERY_AUTO_THRESHOLD } from "../../src/tool-discovery/mode";
|
|
|
|
// ─── Subagent discovery mode inheritance tests ────────────────────────────────
|
|
// These are unit-level tests that verify the settings resolution logic
|
|
// without needing to spin up a full AgentSession or subagent.
|
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
|
|
describe("effective discovery mode resolution", () => {
|
|
function resolveEffectiveMode(settings: Settings, toolCount = 0): "off" | "mcp-only" | "all" {
|
|
return resolveEffectiveToolDiscoveryMode(settings, toolCount);
|
|
}
|
|
|
|
it("tools.discoveryMode=all beats mcp.discoveryMode=false", () => {
|
|
const s = Settings.isolated({ "tools.discoveryMode": "all", "mcp.discoveryMode": false });
|
|
expect(resolveEffectiveMode(s)).toBe("all");
|
|
});
|
|
|
|
it("tools.discoveryMode=mcp-only beats mcp.discoveryMode=false", () => {
|
|
const s = Settings.isolated({ "tools.discoveryMode": "mcp-only", "mcp.discoveryMode": false });
|
|
expect(resolveEffectiveMode(s)).toBe("mcp-only");
|
|
});
|
|
|
|
it("tools.discoveryMode=off + mcp.discoveryMode=true → mcp-only (back-compat alias)", () => {
|
|
const s = Settings.isolated({ "tools.discoveryMode": "off", "mcp.discoveryMode": true });
|
|
expect(resolveEffectiveMode(s)).toBe("mcp-only");
|
|
});
|
|
|
|
it("tools.discoveryMode=off + mcp.discoveryMode=false → off", () => {
|
|
const s = Settings.isolated({ "tools.discoveryMode": "off", "mcp.discoveryMode": false });
|
|
expect(resolveEffectiveMode(s)).toBe("off");
|
|
});
|
|
|
|
it("default auto settings stay off at the threshold", () => {
|
|
const s = Settings.isolated({});
|
|
expect(s.get("tools.discoveryMode")).toBe("auto");
|
|
expect(resolveEffectiveMode(s, TOOL_DISCOVERY_AUTO_THRESHOLD)).toBe("off");
|
|
});
|
|
|
|
it("default auto settings enable mcp-only above the threshold", () => {
|
|
const s = Settings.isolated({});
|
|
expect(resolveEffectiveMode(s, TOOL_DISCOVERY_AUTO_THRESHOLD + 1)).toBe("mcp-only");
|
|
});
|
|
});
|