fix(coding-agent): align ToolDefinition.execute signature with AgentTool

BREAKING CHANGE: ToolDefinition.execute parameter order changed from
(id, params, onUpdate, ctx, signal) to (id, params, signal, onUpdate, ctx).

This aligns with AgentTool.execute so wrapping built-in tools no longer
requires parameter reordering. Update extensions by swapping signal and
onUpdate parameters.
This commit is contained in:
Mario Zechner 2026-02-02 00:29:47 +01:00
parent 287a0b606d
commit 0a26db53ef
17 changed files with 36 additions and 25 deletions

View file

@ -352,7 +352,7 @@ export default function antigravityImageGen(pi: ExtensionAPI) {
description:
"Generate an image via Google Antigravity image models. Returns the image as a tool result attachment. Optional saving via save=project|global|custom|none, or PI_IMAGE_SAVE_MODE/PI_IMAGE_SAVE_DIR.",
parameters: TOOL_PARAMS,
async execute(_toolCallId, params: ToolParams, onUpdate, ctx, signal) {
async execute(_toolCallId, params: ToolParams, signal, onUpdate, ctx) {
const { accessToken, projectId } = await getCredentials(ctx);
const model = params.model || DEFAULT_MODEL;
const aspectRatio = params.aspectRatio || DEFAULT_ASPECT_RATIO;

View file

@ -23,7 +23,7 @@ export default function (pi: ExtensionAPI) {
pi.registerTool({
...bashTool,
execute: async (id, params, onUpdate, _ctx, signal) => {
execute: async (id, params, signal, onUpdate, _ctx) => {
return bashTool.execute(id, params, signal, onUpdate);
},
});

View file

@ -14,7 +14,7 @@ export default function (pi: ExtensionAPI) {
name: Type.String({ description: "Name to greet" }),
}),
async execute(_toolCallId, params, _onUpdate, _ctx, _signal) {
async execute(_toolCallId, params, _signal, _onUpdate, _ctx) {
const { name } = params as { name: string };
return {
content: [{ type: "text", text: `Hello, ${name}!` }],

View file

@ -40,7 +40,7 @@ export default function question(pi: ExtensionAPI) {
description: "Ask the user a question and let them pick from options. Use when you need user input to proceed.",
parameters: QuestionParams,
async execute(_toolCallId, params, _onUpdate, ctx, _signal) {
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
if (!ctx.hasUI) {
return {
content: [{ type: "text", text: "Error: UI not available (running in non-interactive mode)" }],

View file

@ -81,7 +81,7 @@ export default function questionnaire(pi: ExtensionAPI) {
"Ask the user one or more questions. Use for clarifying requirements, getting preferences, or confirming decisions. For single questions, shows a simple option list. For multiple questions, shows a tab-based interface.",
parameters: QuestionnaireParams,
async execute(_toolCallId, params, _onUpdate, ctx, _signal) {
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
if (!ctx.hasUI) {
return errorResult("Error: UI not available (running in non-interactive mode)");
}

View file

@ -211,7 +211,7 @@ export default function (pi: ExtensionAPI) {
pi.registerTool({
...localBash,
label: "bash (sandboxed)",
async execute(id, params, onUpdate, _ctx, signal) {
async execute(id, params, signal, onUpdate, _ctx) {
if (!sandboxEnabled || !sandboxInitialized) {
return localBash.execute(id, params, signal, onUpdate);
}

View file

@ -23,7 +23,7 @@ export default function (pi: ExtensionAPI) {
label: "Finish and Exit",
description: "Complete a task and exit pi",
parameters: Type.Object({}),
async execute(_toolCallId, _params, _onUpdate, ctx, _signal) {
async execute(_toolCallId, _params, _signal, _onUpdate, ctx) {
// Do any final work here...
// Request graceful shutdown (deferred until agent is idle)
ctx.shutdown();
@ -44,7 +44,7 @@ export default function (pi: ExtensionAPI) {
parameters: Type.Object({
environment: Type.String({ description: "Target environment (e.g., production, staging)" }),
}),
async execute(_toolCallId, params, onUpdate, ctx, _signal) {
async execute(_toolCallId, params, _signal, onUpdate, ctx) {
onUpdate?.({ content: [{ type: "text", text: `Deploying to ${params.environment}...` }], details: {} });
// Example deployment logic

View file

@ -127,7 +127,7 @@ export default function (pi: ExtensionAPI) {
pi.registerTool({
...localRead,
async execute(id, params, onUpdate, _ctx, signal) {
async execute(id, params, signal, onUpdate, _ctx) {
const ssh = getSsh();
if (ssh) {
const tool = createReadTool(localCwd, {
@ -141,7 +141,7 @@ export default function (pi: ExtensionAPI) {
pi.registerTool({
...localWrite,
async execute(id, params, onUpdate, _ctx, signal) {
async execute(id, params, signal, onUpdate, _ctx) {
const ssh = getSsh();
if (ssh) {
const tool = createWriteTool(localCwd, {
@ -155,7 +155,7 @@ export default function (pi: ExtensionAPI) {
pi.registerTool({
...localEdit,
async execute(id, params, onUpdate, _ctx, signal) {
async execute(id, params, signal, onUpdate, _ctx) {
const ssh = getSsh();
if (ssh) {
const tool = createEditTool(localCwd, {
@ -169,7 +169,7 @@ export default function (pi: ExtensionAPI) {
pi.registerTool({
...localBash,
async execute(id, params, onUpdate, _ctx, signal) {
async execute(id, params, signal, onUpdate, _ctx) {
const ssh = getSsh();
if (ssh) {
const tool = createBashTool(localCwd, {

View file

@ -416,7 +416,7 @@ export default function (pi: ExtensionAPI) {
].join(" "),
parameters: SubagentParams,
async execute(_toolCallId, params, onUpdate, ctx, signal) {
async execute(_toolCallId, params, signal, onUpdate, ctx) {
const agentScope: AgentScope = params.agentScope ?? "user";
const discovery = discoverAgents(ctx.cwd, agentScope);
const agents = discovery.agents;

View file

@ -141,7 +141,7 @@ export default function (pi: ExtensionAPI) {
description: "Manage a todo list. Actions: list, add (text), toggle (id), clear",
parameters: TodoParams,
async execute(_toolCallId, params, _onUpdate, _ctx, _signal) {
async execute(_toolCallId, params, _signal, _onUpdate, _ctx) {
switch (params.action) {
case "list":
return {

View file

@ -72,7 +72,7 @@ export default function (pi: ExtensionAPI) {
"Read the contents of a file with access logging. Some sensitive paths (.env, secrets, credentials) are blocked.",
parameters: readSchema,
async execute(_toolCallId, params, _onUpdate, ctx) {
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
const { path, offset, limit } = params;
const absolutePath = resolve(ctx.cwd, path);

View file

@ -52,7 +52,7 @@ export default function (pi: ExtensionAPI) {
description: `Search file contents using ripgrep. Output is truncated to ${DEFAULT_MAX_LINES} lines or ${formatSize(DEFAULT_MAX_BYTES)} (whichever is hit first). If truncated, full output is saved to a temp file.`,
parameters: RgParams,
async execute(_toolCallId, params, _onUpdate, ctx) {
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
const { pattern, path: searchPath, glob } = params;
// Build the ripgrep command