fix(coding-agent): restore builtin-only tool disabling

closes #3592
This commit is contained in:
Mario Zechner
2026-04-23 20:39:34 +02:00
parent e97051313d
commit e38647f376
8 changed files with 161 additions and 17 deletions

View File

@@ -47,11 +47,19 @@ export interface CreateAgentSessionOptions {
/** Models available for cycling (Ctrl+P in interactive mode) */
scopedModels?: Array<{ model: Model<any>; thinkingLevel?: ThinkingLevel }>;
/**
* Optional default tool suppression mode when no explicit allowlist is provided.
*
* - "all": start with no tools enabled
* - "builtin": disable the default built-in tools (read, bash, edit, write)
* but keep extension/custom tools enabled
*/
noTools?: "all" | "builtin";
/**
* Optional allowlist of tool names.
*
* When omitted, pi enables the default built-in tools (read, bash, edit, write)
* and leaves extension/custom tools enabled.
* and leaves extension/custom tools enabled unless `noTools` changes that default.
* When provided, only the listed tool names are enabled.
*/
tools?: string[];
@@ -245,7 +253,12 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
}
const defaultActiveToolNames: ToolName[] = ["read", "bash", "edit", "write"];
const initialActiveToolNames: string[] = options.tools ? [...options.tools] : defaultActiveToolNames;
const allowedToolNames = options.tools ?? (options.noTools === "all" ? [] : undefined);
const initialActiveToolNames: string[] = options.tools
? [...options.tools]
: options.noTools
? []
: defaultActiveToolNames;
let agent: Agent;
@@ -366,7 +379,7 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
customTools: options.customTools,
modelRegistry,
initialActiveToolNames,
allowedToolNames: options.tools,
allowedToolNames,
extensionRunnerRef,
sessionStartEvent: options.sessionStartEvent,
});