@@ -17,6 +17,7 @@ import (
1717 "github.com/docker/cagent/internal/tui/core"
1818 "github.com/docker/cagent/internal/tui/core/layout"
1919 "github.com/docker/cagent/internal/tui/types"
20+ "github.com/docker/cagent/pkg/tools"
2021)
2122
2223// Model represents a chat message list component
@@ -30,8 +31,8 @@ type Model interface {
3031 AddErrorMessage (content string ) tea.Cmd
3132 AddAssistantMessage () tea.Cmd
3233 AddSeparatorMessage () tea.Cmd
33- AddOrUpdateToolCall (toolName , toolCallID , arguments string , status types.ToolStatus ) tea.Cmd
34- AddToolResult (toolName , toolCallID , result string , status types.ToolStatus ) tea.Cmd
34+ AddOrUpdateToolCall (agentName string , toolCall tools. ToolCall , status types.ToolStatus ) tea.Cmd
35+ AddToolResult (toolCall tools. ToolCall , result string , status types.ToolStatus ) tea.Cmd
3536 AppendToLastMessage (agentName string , content string ) tea.Cmd
3637 ClearMessages ()
3738 ScrollToBottom () tea.Cmd
@@ -545,14 +546,14 @@ func (m *model) AddSeparatorMessage() tea.Cmd {
545546}
546547
547548// AddOrUpdateToolCall adds a tool call or updates existing one with the given status
548- func (m * model ) AddOrUpdateToolCall (toolName , toolCallID , arguments string , status types.ToolStatus ) tea.Cmd {
549+ func (m * model ) AddOrUpdateToolCall (agentName string , toolCall tools. ToolCall , status types.ToolStatus ) tea.Cmd {
549550 // First try to update existing tool by ID
550551 for i := len (m .messages ) - 1 ; i >= 0 ; i -- {
551552 msg := & m .messages [i ]
552- if msg .ToolCallID == toolCallID {
553+ if msg .ToolCall . ID == toolCall . ID {
553554 msg .ToolStatus = status
554- if arguments != "" {
555- msg .Arguments = arguments
555+ if toolCall . Function . Arguments != "" {
556+ msg .ToolCall . Function . Arguments = toolCall . Function . Arguments
556557 }
557558 // Update the corresponding view
558559 view := m .createToolCallView (msg )
@@ -567,10 +568,9 @@ func (m *model) AddOrUpdateToolCall(toolName, toolCallID, arguments string, stat
567568 // Create new tool call
568569 msg := types.Message {
569570 Type : types .MessageTypeToolCall ,
570- ToolName : toolName ,
571- ToolCallID : toolCallID ,
571+ Sender : agentName ,
572+ ToolCall : toolCall ,
572573 ToolStatus : status ,
573- Arguments : arguments ,
574574 }
575575 m .messages = append (m .messages , msg )
576576
@@ -581,10 +581,10 @@ func (m *model) AddOrUpdateToolCall(toolName, toolCallID, arguments string, stat
581581}
582582
583583// AddToolResult adds tool result to the most recent matching tool call
584- func (m * model ) AddToolResult (_ , toolCallID , result string , status types.ToolStatus ) tea.Cmd {
584+ func (m * model ) AddToolResult (toolCall tools. ToolCall , result string , status types.ToolStatus ) tea.Cmd {
585585 for i := len (m .messages ) - 1 ; i >= 0 ; i -- {
586586 msg := & m .messages [i ]
587- if msg .ToolCallID == toolCallID {
587+ if msg .ToolCall . ID == toolCall . ID {
588588 msg .Content = result
589589 msg .ToolStatus = status
590590 // Update the corresponding view
0 commit comments