feat(coding-agent): added coding-agent approval types and mode options
- Added `ToolTier`, `ToolApproval`, and `ToolApprovalDecision` types and exported approval APIs. - Updated approval-mode options from `auto|prompt|custom` to `always-ask|write|yolo` and defaulted mode to `yolo`. - Changed approval resolution to apply per-tool decisions first, then mode-tier limits, with legacy-mode migration. - Assigned read/write/exec `approval` and approval-detail prompts across built-in, custom, extension, and MCP tools.
This commit is contained in:
@@ -533,10 +533,10 @@ function createSubagentSettings(baseSettings: Settings): Settings {
|
||||
"async.enabled": false,
|
||||
"bash.autoBackground.enabled": false,
|
||||
// Subagents run headless — there is no UI to confirm prompts against, so
|
||||
// any non-auto mode would deadlock on the first destructive call. The
|
||||
// parent's approval of the `task` invocation is the user's authorization
|
||||
// for the work the subagent performs.
|
||||
"tools.approvalMode": "auto",
|
||||
// the parent task approval is the authorization boundary. Use yolo mode
|
||||
// to preserve unattended subagent execution while still honoring any
|
||||
// tool-level safety override that can be handled before execution.
|
||||
"tools.approvalMode": "yolo",
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import planModeSubagentPrompt from "../prompts/system/plan-mode-subagent.md" wit
|
||||
import subagentUserPromptTemplate from "../prompts/system/subagent-user-prompt.md" with { type: "text" };
|
||||
import taskDescriptionTemplate from "../prompts/tools/task.md" with { type: "text" };
|
||||
import taskSummaryTemplate from "../prompts/tools/task-summary.md" with { type: "text" };
|
||||
import { truncateForPrompt } from "../tools/approval";
|
||||
import { formatBytes, formatDuration } from "../tools/render-utils";
|
||||
import {
|
||||
type AgentDefinition,
|
||||
@@ -214,6 +215,24 @@ function validateTaskModeParams(simpleMode: TaskSimpleMode, params: TaskParams):
|
||||
*/
|
||||
export class TaskTool implements AgentTool<TaskToolSchemaInstance, TaskToolDetails, Theme> {
|
||||
readonly name = "task";
|
||||
readonly approval = "exec" as const;
|
||||
readonly formatApprovalDetails = (args: unknown): string[] => {
|
||||
const params = args as Partial<TaskParams>;
|
||||
const lines: string[] = [];
|
||||
if (typeof params.agent === "string") {
|
||||
lines.push(`Agent: ${truncateForPrompt(params.agent)}`);
|
||||
}
|
||||
const tasks = Array.isArray(params.tasks) ? params.tasks : [];
|
||||
const firstTask = tasks[0];
|
||||
if (firstTask) {
|
||||
lines.push(`Task: ${truncateForPrompt(firstTask.id)}`);
|
||||
lines.push(`Assignment:\n${truncateForPrompt(firstTask.assignment)}`);
|
||||
if (tasks.length > 1) {
|
||||
lines.push(`+${tasks.length - 1} more task${tasks.length === 2 ? "" : "s"}`);
|
||||
}
|
||||
}
|
||||
return lines;
|
||||
};
|
||||
readonly label = "Task";
|
||||
readonly summary = "Spawn a subagent to complete a parallel task";
|
||||
readonly strict = true;
|
||||
|
||||
Reference in New Issue
Block a user