@@ -87,7 +87,7 @@ function M.create_handler(action_name, has_function_calling, opts)
8787end
8888
8989--- @param action_name MCPHub.ActionType
90- --- @param tool table
90+ --- @param tool CodeCompanion.Agent.Tool
9191--- @param chat any
9292--- @param llm_msg string
9393--- @param is_error boolean
@@ -106,7 +106,10 @@ local function add_tool_output(action_name, tool, chat, llm_msg, is_error, has_f
106106 tool ,
107107 text ,
108108 (user_msg or show_result_in_chat or is_error ) and (user_msg or text )
109- or string.format (" **`%s` Tool**: Successfully finished" , action_name )
109+ or string.format (
110+ " **`%s` Tool**: Successfully finished" ,
111+ opts .format_action and opts .format_action (action_name , tool ) or action_name
112+ )
110113 )
111114 for _ , image in ipairs (images ) do
112115 helpers .add_image (chat , image )
@@ -124,7 +127,10 @@ local function add_tool_output(action_name, tool, chat, llm_msg, is_error, has_f
124127 })
125128 chat :add_buf_message ({
126129 role = config .constants .USER_ROLE ,
127- content = string.format (" I've shared the result of the `%s` tool with you.\n " , action_name ),
130+ content = string.format (
131+ " I've shared the result of the `%s` tool with you.\n " ,
132+ opts .format_action and opts .format_action (action_name , tool ) or action_name
133+ ),
128134 })
129135 end
130136 end
@@ -154,7 +160,7 @@ function M.create_output_handlers(action_name, has_function_calling, opts)
154160%s
155161````
156162]] ,
157- action_name ,
163+ opts . format_action and opts . format_action ( action_name , self ) or action_name ,
158164 stderr
159165 )
160166 add_tool_output (action_name , self , agent .chat , err_msg , true , has_function_calling , opts , nil , {})
@@ -179,7 +185,7 @@ function M.create_output_handlers(action_name, has_function_calling, opts)
179185````
180186%s
181187````]] ,
182- action_name ,
188+ opts . format_action and opts . format_action ( action_name , self ) or action_name ,
183189 result .text
184190 )
185191 end
@@ -204,7 +210,7 @@ function M.create_output_handlers(action_name, has_function_calling, opts)
204210````
205211%s
206212````]] ,
207- action_name ,
213+ opts . format_action and opts . format_action ( action_name , self ) or action_name ,
208214 string.format (" %d image%s returned" , # result .images , # result .images > 1 and " s" or " " )
209215 )
210216 end
@@ -219,7 +225,10 @@ function M.create_output_handlers(action_name, has_function_calling, opts)
219225 end
220226 end
221227 end
222- local fallback_to_llm = string.format (" **`%s` Tool**: Completed with no output" , action_name )
228+ local fallback_to_llm = string.format (
229+ " **`%s` Tool**: Completed with no output" ,
230+ opts .format_action and opts .format_action (action_name , self ) or action_name
231+ )
223232 add_tool_output (
224233 action_name ,
225234 self ,
0 commit comments