@@ -649,38 +649,40 @@ func (r *runtime) processToolCalls(ctx context.Context, sess *session.Session, c
649649 slog .Debug ("Processing tool call" , "agent" , a .Name (), "tool" , toolCall .Function .Name , "session_id" , sess .ID )
650650 handler , exists := r .toolMap [toolCall .Function .Name ]
651651 if exists {
652+ tool := tools.Tool {
653+ Annotations : tools.ToolAnnotations {
654+ // TODO: We need to handle the transfer task tool better
655+ Title : "Transfer Task" ,
656+ },
657+ }
652658 slog .Debug ("Using runtime tool handler" , "tool" , toolCall .Function .Name , "session_id" , sess .ID )
653659 if sess .ToolsApproved || toolCall .Function .Name == "transfer_task" {
654- r .runAgentTool (callCtx , handler , sess , toolCall , events , a )
660+ r .runAgentTool (callCtx , handler , sess , toolCall , tool , events , a )
655661 } else {
656662 slog .Debug ("Tools not approved, waiting for resume" , "tool" , toolCall .Function .Name , "session_id" , sess .ID )
657- events <- ToolCallConfirmation (toolCall , tools.Tool {
658- Annotations : tools.ToolAnnotations {
659- // TODO: We need to handle the transfer task tool better
660- Title : "Transfer Task" ,
661- },
662- }, a .Name ())
663+
664+ events <- ToolCallConfirmation (toolCall , tool , a .Name ())
663665
664666 select {
665667 case cType := <- r .resumeChan :
666668 switch cType {
667669 case ResumeTypeApprove :
668670 slog .Debug ("Resume signal received, approving tool handler" , "tool" , toolCall .Function .Name , "session_id" , sess .ID )
669- r .runAgentTool (callCtx , handler , sess , toolCall , events , a )
671+ r .runAgentTool (callCtx , handler , sess , toolCall , tool , events , a )
670672 case ResumeTypeApproveSession :
671673 slog .Debug ("Resume signal received, approving session" , "tool" , toolCall .Function .Name , "session_id" , sess .ID )
672674 sess .ToolsApproved = true
673- r .runAgentTool (callCtx , handler , sess , toolCall , events , a )
675+ r .runAgentTool (callCtx , handler , sess , toolCall , tool , events , a )
674676 case ResumeTypeReject :
675677 slog .Debug ("Resume signal received, rejecting tool handler" , "tool" , toolCall .Function .Name , "session_id" , sess .ID )
676- r .addToolRejectedResponse (sess , toolCall , events )
678+ r .addToolRejectedResponse (sess , toolCall , tool , events )
677679 }
678680 case <- callCtx .Done ():
679681 slog .Debug ("Context cancelled while waiting for resume" , "tool" , toolCall .Function .Name , "session_id" , sess .ID )
680682 // Synthesize cancellation responses for the current and any remaining tool calls
681- r .addToolCancelledResponse (sess , toolCall , events )
683+ r .addToolCancelledResponse (sess , toolCall , tool , events )
682684 for j := i + 1 ; j < len (calls ); j ++ {
683- r .addToolCancelledResponse (sess , calls [j ], events )
685+ r .addToolCancelledResponse (sess , calls [j ], tool , events )
684686 }
685687 callSpan .SetStatus (codes .Ok , "tool call canceled by user" )
686688 return
@@ -716,17 +718,17 @@ func (r *runtime) processToolCalls(ctx context.Context, sess *session.Session, c
716718 r .runTool (callCtx , tool , toolCall , events , sess , a )
717719 case ResumeTypeReject :
718720 slog .Debug ("Resume signal received, rejecting tool handler" , "tool" , toolCall .Function .Name , "session_id" , sess .ID )
719- r .addToolRejectedResponse (sess , toolCall , events )
721+ r .addToolRejectedResponse (sess , toolCall , tool , events )
720722 }
721723
722724 slog .Debug ("Added tool response to session" , "tool" , toolCall .Function .Name , "session_id" , sess .ID , "total_messages" , len (sess .GetAllMessages ()))
723725 break toolLoop
724726 case <- callCtx .Done ():
725727 slog .Debug ("Context cancelled while waiting for resume" , "tool" , toolCall .Function .Name , "session_id" , sess .ID )
726728 // Synthesize cancellation responses for the current and any remaining tool calls
727- r .addToolCancelledResponse (sess , toolCall , events )
729+ r .addToolCancelledResponse (sess , toolCall , tool , events )
728730 for j := i + 1 ; j < len (calls ); j ++ {
729- r .addToolCancelledResponse (sess , calls [j ], events )
731+ r .addToolCancelledResponse (sess , calls [j ], tool , events )
730732 }
731733 callSpan .SetStatus (codes .Ok , "tool call canceled by user" )
732734 return
@@ -752,7 +754,7 @@ func (r *runtime) runTool(ctx context.Context, tool tools.Tool, toolCall tools.T
752754 ))
753755 defer span .End ()
754756
755- events <- ToolCall (toolCall , a .Name ())
757+ events <- ToolCall (toolCall , tool , a .Name ())
756758
757759 var res * tools.ToolCallResult
758760 var err error
@@ -781,7 +783,7 @@ func (r *runtime) runTool(ctx context.Context, tool tools.Tool, toolCall tools.T
781783 slog .Debug ("Agent tool call completed" , "tool" , toolCall .Function .Name , "output_length" , len (res .Output ))
782784 }
783785
784- events <- ToolCallResponse (toolCall , res .Output , a .Name ())
786+ events <- ToolCallResponse (toolCall , tool , res .Output , a .Name ())
785787
786788 // Ensure tool response content is not empty for API compatibility
787789 content := res .Output
@@ -798,7 +800,7 @@ func (r *runtime) runTool(ctx context.Context, tool tools.Tool, toolCall tools.T
798800 sess .AddMessage (session .NewAgentMessage (a , & toolResponseMsg ))
799801}
800802
801- func (r * runtime ) runAgentTool (ctx context.Context , handler ToolHandler , sess * session.Session , toolCall tools.ToolCall , events chan Event , a * agent.Agent ) {
803+ func (r * runtime ) runAgentTool (ctx context.Context , handler ToolHandler , sess * session.Session , toolCall tools.ToolCall , tool tools. Tool , events chan Event , a * agent.Agent ) {
802804 // Start a child span for runtime-provided tool handler execution
803805 ctx , span := r .startSpan (ctx , "runtime.tool.handler.runtime" , trace .WithAttributes (
804806 attribute .String ("tool.name" , toolCall .Function .Name ),
@@ -808,7 +810,7 @@ func (r *runtime) runAgentTool(ctx context.Context, handler ToolHandler, sess *s
808810 ))
809811 defer span .End ()
810812
811- events <- ToolCall (toolCall , a .Name ())
813+ events <- ToolCall (toolCall , tool , a .Name ())
812814 start := time .Now ()
813815 res , err := handler (ctx , sess , toolCall , events )
814816 duration := time .Since (start )
@@ -834,7 +836,7 @@ func (r *runtime) runAgentTool(ctx context.Context, handler ToolHandler, sess *s
834836 slog .Debug ("Tool executed successfully" , "tool" , toolCall .Function .Name )
835837 }
836838
837- events <- ToolCallResponse (toolCall , output , a .Name ())
839+ events <- ToolCallResponse (toolCall , tool , output , a .Name ())
838840
839841 // Ensure tool response content is not empty for API compatibility
840842 content := output
@@ -851,12 +853,12 @@ func (r *runtime) runAgentTool(ctx context.Context, handler ToolHandler, sess *s
851853 sess .AddMessage (session .NewAgentMessage (a , & toolResponseMsg ))
852854}
853855
854- func (r * runtime ) addToolRejectedResponse (sess * session.Session , toolCall tools.ToolCall , events chan Event ) {
856+ func (r * runtime ) addToolRejectedResponse (sess * session.Session , toolCall tools.ToolCall , tool tools. Tool , events chan Event ) {
855857 a := r .CurrentAgent ()
856858
857859 result := "The user rejected the tool call."
858860
859- events <- ToolCallResponse (toolCall , result , a .Name ())
861+ events <- ToolCallResponse (toolCall , tool , result , a .Name ())
860862
861863 toolResponseMsg := chat.Message {
862864 Role : chat .MessageRoleTool ,
@@ -867,12 +869,12 @@ func (r *runtime) addToolRejectedResponse(sess *session.Session, toolCall tools.
867869 sess .AddMessage (session .NewAgentMessage (a , & toolResponseMsg ))
868870}
869871
870- func (r * runtime ) addToolCancelledResponse (sess * session.Session , toolCall tools.ToolCall , events chan Event ) {
872+ func (r * runtime ) addToolCancelledResponse (sess * session.Session , toolCall tools.ToolCall , tool tools. Tool , events chan Event ) {
871873 a := r .CurrentAgent ()
872874
873875 result := "The tool call was canceled by the user."
874876
875- events <- ToolCallResponse (toolCall , result , a .Name ())
877+ events <- ToolCallResponse (toolCall , tool , result , a .Name ())
876878
877879 toolResponseMsg := chat.Message {
878880 Role : chat .MessageRoleTool ,
0 commit comments