Rebase onto upstream (a4d95fd) #12

Closed
wylab wants to merge 144 commits from rebase-onto-upstream into main
Showing only changes of commit aa91509b43 - Show all commits
+36 -1
View File
@@ -636,8 +636,43 @@ class AgentLoop:
args_str = json.dumps(tool_call.arguments, ensure_ascii=False)
logger.info(f"Tool call: {tool_call.name}({args_str[:200]})")
result = await self.tools.execute(tool_call.name, tool_call.arguments)
# Handle different result types (same logic as main handler)
if isinstance(result, ToolResult):
# Native Anthropic tool result
# Add text content
if result.output:
text_content = result.output
elif result.error:
text_content = f"Error: {result.error}"
else:
text_content = ""
# If both output and error, combine them
if result.output and result.error:
text_content = f"{result.output}\n\nError: {result.error}"
# Note: Image handling for system messages not needed
# (system messages don't render images to users)
# But we should still log if present
if result.base64_image:
logger.warning(
f"Tool {tool_call.name} returned image in system message context - "
"images not supported here"
)
tool_content = text_content
elif isinstance(result, CLIResult):
# CLI-style tool result (text editor)
tool_content = result.output
else:
# Legacy string result from function tools
tool_content = result
messages = self.context.add_tool_result(
messages, tool_call.id, tool_call.name, result
messages, tool_call.id, tool_call.name, tool_content
)
# Interleaved CoT: reflect before next action (skip when thinking is active)
if not getattr(self.provider, 'thinking_budget', 0):