@@ -31,6 +31,7 @@ import {
3131 type WorkerGrantStore ,
3232} from "./worker-grant.js" ;
3333import { canonicalToolName } from "../agent/canonical-tool-name.js" ;
34+ import { prepareDispatchedToolCall } from "../agent/tool-aliases.js" ;
3435import { getSubAgentIdentity } from "../subagent/identity-context.js" ;
3536import {
3637 FLEET_VERBS ,
@@ -100,6 +101,23 @@ function resolveWorkerCwd(cwd: string | undefined): string {
100101 return cwd ?? getSubAgentIdentity ( ) ?. cwd ?? process . cwd ( ) ;
101102}
102103
104+ /**
105+ * The call as DynamicToolRunner dispatches it: canonical engine name plus
106+ * hidden-alias argument coercion (gpt `shell` -> run_shell via
107+ * coerceShellArgs). Authorize sees the raw wire call; the middleware that
108+ * consumes an authorized retry sees the dispatched call. Keying both on the
109+ * dispatched shape keeps one fingerprint per executed call. Invalid hidden
110+ * arguments never dispatch, so they keep their raw shape.
111+ */
112+ function dispatchedCall ( call : ToolCallType ) : ToolCallType {
113+ const engine = canonicalToolName ( call . name ) ;
114+ try {
115+ return prepareDispatchedToolCall ( call , engine ) ;
116+ } catch {
117+ return { ...call , name : engine } ;
118+ }
119+ }
120+
103121function workerCallIdentity (
104122 sessionId : string ,
105123 call : ToolCallType ,
@@ -110,10 +128,11 @@ function workerCallIdentity(
110128 args : Record < string , unknown > ;
111129 cwd : string ;
112130} {
131+ const dispatched = dispatchedCall ( call ) ;
113132 return {
114133 sessionId,
115- canonicalTool : canonicalToolName ( call . name ) ,
116- args : ( call . arguments ?? { } ) as Record < string , unknown > ,
134+ canonicalTool : dispatched . name ,
135+ args : ( dispatched . arguments ?? { } ) as Record < string , unknown > ,
117136 cwd,
118137 } ;
119138}
0 commit comments