Files
Agent-System/deploy/pi-agent/pi-args.mjs
T
weichenandCursor 686f739b19 fix(pi-agent): enforce a no-tool reasoning profile
语义摘要、变更叙事和 U9 分段改为请求 reasoning。该 profile 的 argv 使用 --no-tools 且不加载搜索扩展;未知 profile 拒绝启动。文档生成仍保留读写工具。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-20 04:59:15 +00:00

46 lines
1.4 KiB
JavaScript

/**
* pi 进程参数。reasoning 只允许纯推理:不加载扩展,并用 --no-tools 关掉内置工具。
* workspace 保持调用方给出的工具名单。未知 profile 失败关闭,不能退回读写工具。
*/
export const TOOL_PROFILE_WORKSPACE = "workspace";
export const TOOL_PROFILE_REASONING = "reasoning";
export function buildPiLaunchArgs({
toolProfile,
provider,
model,
systemPromptFile,
extension,
workspaceTools,
}) {
const profile = String(toolProfile || "").trim() || TOOL_PROFILE_WORKSPACE;
if (profile !== TOOL_PROFILE_WORKSPACE && profile !== TOOL_PROFILE_REASONING) {
const err = new Error("unknown tool_profile");
err.code = "UNKNOWN_TOOL_PROFILE";
throw err;
}
const args = ["--mode", "rpc"];
if (profile === TOOL_PROFILE_WORKSPACE && extension) {
args.push("-e", extension);
}
args.push("--no-session", "--provider", provider, "--model", model);
if (systemPromptFile) {
args.push("--append-system-prompt", systemPromptFile);
}
if (profile === TOOL_PROFILE_REASONING) {
args.push("--no-tools");
return args;
}
args.push("--tools", workspaceTools || "read,write,edit", "--approve");
return args;
}
const FORBIDDEN_REASONING_ARGV = ["read", "write", "edit", "search", "tavily"];
export function reasoningArgvLeaksTools(args) {
const joined = args.join(" ").toLowerCase();
return FORBIDDEN_REASONING_ARGV.some((word) => joined.includes(word));
}