Files
oh-my-pi/packages/coding-agent/src/tool-discovery/mode.ts
T
can1357 2e425b7b65 docs(coding-agent): documented auto discovery mode behavior
- 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.
2026-06-06 01:14:14 +02:00

25 lines
1.0 KiB
TypeScript

import type { Settings } from "../config/settings";
import type { SettingValue } from "../config/settings-schema";
export const TOOL_DISCOVERY_AUTO_THRESHOLD = 40;
export const TOOL_DISCOVERY_SEARCH_TOOL_NAME = "search_tool_bm25";
export type ToolDiscoveryModeSetting = SettingValue<"tools.discoveryMode">;
export type EffectiveToolDiscoveryMode = Exclude<ToolDiscoveryModeSetting, "auto">;
export function countToolsForAutoDiscovery(toolNames: Iterable<string>): number {
let count = 0;
for (const name of toolNames) {
if (name !== TOOL_DISCOVERY_SEARCH_TOOL_NAME) count++;
}
return count;
}
export function resolveEffectiveToolDiscoveryMode(settings: Settings, toolCount: number): EffectiveToolDiscoveryMode {
const configuredMode = settings.get("tools.discoveryMode");
if (configuredMode === "all" || configuredMode === "mcp-only") return configuredMode;
if (settings.get("mcp.discoveryMode")) return "mcp-only";
if (configuredMode === "auto" && toolCount > TOOL_DISCOVERY_AUTO_THRESHOLD) return "mcp-only";
return "off";
}