@@ -20,7 +20,10 @@ import {
2020 copyAgentToolSourceExecutionGuard ,
2121 runAgentToolSourceExecutionGuard ,
2222} from "./agent-tool-source-execution-guard.js" ;
23- import { recordGenericToolActionDecision } from "./agent-tools.before-tool-call.decision.js" ;
23+ import {
24+ recordGenericToolActionDecision ,
25+ runWithGenericToolActionDecision ,
26+ } from "./agent-tools.before-tool-call.decision.js" ;
2427import {
2528 buildToolContentPrivateData ,
2629 emitSkillUsedDiagnostic ,
@@ -527,9 +530,6 @@ export function wrapToolWithBeforeToolCallHook(
527530 // Host capabilities can close while hooks, approval, validation, or
528531 // steering awaits. Recheck at the final synchronous source boundary.
529532 runAgentToolSourceExecutionGuard ( tool ) ;
530- if ( ! outcome . ownerDecision ) {
531- recordGenericToolActionDecision ( tool , toolCallId , "allowed" ) ;
532- }
533533 onImplementationStart ?.( ) ;
534534 recordAdjustedParamsForToolCall ( toolCallId , executeParams , ctx ?. runId ) ;
535535 const eventBase = buildEventBase ( executeParams ) ;
@@ -544,13 +544,11 @@ export function wrapToolWithBeforeToolCallHook(
544544 try {
545545 let result : Awaited < ReturnType < ForwardedToolExecution > > ;
546546 try {
547- result = await ( execute as ForwardedToolExecution ) (
548- toolCallId ,
549- executeParams ,
550- signal ,
551- forwardedOnUpdate ,
552- ...executionArgs ,
553- ) ;
547+ const args = [ toolCallId , executeParams , signal , forwardedOnUpdate , ...executionArgs ] ;
548+ const invoke = ( ) => ( execute as ForwardedToolExecution ) ( ...args ) ;
549+ result = outcome . ownerDecision
550+ ? await invoke ( )
551+ : await runWithGenericToolActionDecision ( tool , toolCallId , invoke ) ;
554552 } catch ( error ) {
555553 throw tool . resultContentSource === "network" &&
556554 getBeforeToolCallFailureDisposition ( error ) === undefined
0 commit comments