@@ -378,6 +378,9 @@ export class AgentBlockHandler implements BlockHandler {
378378 if ( ctx . workflowId ) {
379379 params . workflowId = ctx . workflowId
380380 }
381+ if ( ctx . userId ) {
382+ params . userId = ctx . userId
383+ }
381384
382385 const url = buildAPIUrl ( '/api/tools/custom' , params )
383386 const response = await fetch ( url . toString ( ) , {
@@ -488,7 +491,9 @@ export class AgentBlockHandler implements BlockHandler {
488491 usageControl : tool . usageControl || 'auto' ,
489492 executeFunction : async ( callParams : Record < string , any > ) => {
490493 const headers = await buildAuthHeaders ( )
491- const execUrl = buildAPIUrl ( '/api/mcp/tools/execute' )
494+ const execParams : Record < string , string > = { }
495+ if ( ctx . userId ) execParams . userId = ctx . userId
496+ const execUrl = buildAPIUrl ( '/api/mcp/tools/execute' , execParams )
492497
493498 const execResponse = await fetch ( execUrl . toString ( ) , {
494499 method : 'POST' ,
@@ -597,6 +602,7 @@ export class AgentBlockHandler implements BlockHandler {
597602 serverId,
598603 workspaceId : ctx . workspaceId ,
599604 workflowId : ctx . workflowId ,
605+ ...( ctx . userId ? { userId : ctx . userId } : { } ) ,
600606 } )
601607
602608 const maxAttempts = 2
@@ -671,7 +677,9 @@ export class AgentBlockHandler implements BlockHandler {
671677 usageControl : tool . usageControl || 'auto' ,
672678 executeFunction : async ( callParams : Record < string , any > ) => {
673679 const headers = await buildAuthHeaders ( )
674- const execUrl = buildAPIUrl ( '/api/mcp/tools/execute' )
680+ const discoverExecParams : Record < string , string > = { }
681+ if ( ctx . userId ) discoverExecParams . userId = ctx . userId
682+ const execUrl = buildAPIUrl ( '/api/mcp/tools/execute' , discoverExecParams )
675683
676684 const execResponse = await fetch ( execUrl . toString ( ) , {
677685 method : 'POST' ,
@@ -1056,6 +1064,7 @@ export class AgentBlockHandler implements BlockHandler {
10561064 responseFormat : providerRequest . responseFormat ,
10571065 workflowId : providerRequest . workflowId ,
10581066 workspaceId : ctx . workspaceId ,
1067+ userId : ctx . userId ,
10591068 stream : providerRequest . stream ,
10601069 messages : 'messages' in providerRequest ? providerRequest . messages : undefined ,
10611070 environmentVariables : ctx . environmentVariables || { } ,
0 commit comments