@@ -150,6 +150,7 @@ function M.create_output_handlers(action_name, has_function_calling, opts)
150150 local result = has_function_calling and stdout [# stdout ] or cmd [# cmd ]
151151 agent = has_function_calling and agent or self
152152 -- Show text content if present
153+ local tool_call_result_added = false
153154 if result .text and result .text ~= " " then
154155 local to_llm = string.format (
155156 [[ **`%s` Tool**: Returned the following:
@@ -161,13 +162,12 @@ function M.create_output_handlers(action_name, has_function_calling, opts)
161162 result .text
162163 )
163164 add_tool_output (action_name , self , agent .chat , to_llm , false , has_function_calling , opts )
164- else
165+ tool_call_result_added = true
166+ end
167+ if not tool_call_result_added then
165168 -- When a tool returns no text content, still send a message to
166169 -- ensure the tool_call_id protocol is satisfied
167- local to_llm = string.format (
168- " **`%s` Tool**: Completed with no output" ,
169- action_name
170- )
170+ local to_llm = string.format (" **`%s` Tool**: Completed with no output" , action_name )
171171 add_tool_output (action_name , self , agent .chat , to_llm , false , has_function_calling , opts )
172172 end
173173 -- TODO: Add image support when codecompanion supports it
0 commit comments