@@ -1660,7 +1660,27 @@ const subAgentSSEHandlers: Record<string, SSEHandler> = {
16601660 const name : string | undefined = toolData . name || data ?. toolName
16611661 if ( ! id || ! name ) return
16621662
1663- const args = toolData . arguments
1663+ // Arguments can come in different locations depending on SSE format
1664+ // Check multiple possible locations
1665+ let args = toolData . arguments || toolData . input || data ?. arguments || data ?. input
1666+
1667+ // If arguments is a string, try to parse it as JSON
1668+ if ( typeof args === 'string' ) {
1669+ try {
1670+ args = JSON . parse ( args )
1671+ } catch {
1672+ logger . warn ( '[SubAgent] Failed to parse arguments string' , { args } )
1673+ }
1674+ }
1675+
1676+ logger . info ( '[SubAgent] tool_call received' , {
1677+ id,
1678+ name,
1679+ hasArgs : ! ! args ,
1680+ argsKeys : args ? Object . keys ( args ) : [ ] ,
1681+ toolDataKeys : Object . keys ( toolData ) ,
1682+ dataKeys : Object . keys ( data || { } ) ,
1683+ } )
16641684
16651685 // Initialize if needed
16661686 if ( ! context . subAgentToolCalls [ parentToolCallId ] ) {
@@ -1713,7 +1733,7 @@ const subAgentSSEHandlers: Record<string, SSEHandler> = {
17131733 // Auto-execute tools without interrupts
17141734 const ctx = createExecutionContext ( { toolCallId : id , toolName : name } )
17151735 try {
1716- await def . execute ( args || { } , ctx )
1736+ await def . execute ( ctx , args || { } )
17171737 } catch ( execErr : any ) {
17181738 logger . error ( '[SubAgent] Tool execution failed' , { id, name, error : execErr ?. message } )
17191739 }
@@ -1725,7 +1745,7 @@ const subAgentSSEHandlers: Record<string, SSEHandler> = {
17251745 const hasInterruptDisplays = ! ! instance . getInterruptDisplays ?.( )
17261746 if ( ! hasInterruptDisplays ) {
17271747 try {
1728- await instance . execute ( args )
1748+ await instance . execute ( args || { } )
17291749 } catch ( execErr : any ) {
17301750 logger . error ( '[SubAgent] Class tool execution failed' , { id, name, error : execErr ?. message } )
17311751 }
0 commit comments