Validate tool execution results to prevent silent failures - #29
Conversation
There was a problem hiding this comment.
Checked the guard against the surrounding control flow in agent/core/engine.py: it sits after the try/except/finally so the spinner is always stopped, mirrors the existing "Unknown tool" early-return pattern, and both call sites (lines 116 and 128) ignore the return value, so the early return changes nothing else. Without it, a tool that returns None instead of a ToolResult would hit format_tool_result's result.success and raise an AttributeError outside the try block, or record the literal string "None" into the conversation — the guard turns that into a recorded error message instead. All execute implementations are annotated -> ToolResult, so this only fires on a genuine tool bug; scoped to 7 lines in one file and matches the PR description.
What
Add validation that tool execution results are not None before adding to conversation.
Why
Prevents silent failures when tools crash without returning a ToolResult object.