fix(hooks): support 'ask' decision for BeforeTool hooks (#21146)

This commit is contained in:
Christian Gunderman
2026-03-21 03:52:39 +00:00
committed by GitHub
parent d3766875f8
commit d1dc4902fd
32 changed files with 1016 additions and 117 deletions
@@ -115,10 +115,25 @@ export class ToolExecutor {
{ shellExecutionConfig, setExecutionIdCallback },
this.config,
request.originalRequestName,
true, // skipBeforeHook
);
const toolResult: ToolResult = await promise;
if (call.request.inputModifiedByHook) {
const modificationMsg = `\n\n[System] Tool input parameters were modified by a hook before execution.`;
if (typeof toolResult.llmContent === 'string') {
toolResult.llmContent += modificationMsg;
} else if (Array.isArray(toolResult.llmContent)) {
toolResult.llmContent.push({ text: modificationMsg });
} else if (toolResult.llmContent) {
toolResult.llmContent = [
toolResult.llmContent,
{ text: modificationMsg },
];
}
}
if (signal.aborted) {
completedToolCall = await this.createCancelledResult(
call,