I ran into a similar issue when the return_direct tool raises an exception. AgentWorkflow._call_tool converts the exception to a string
here. This propagates up to the AgentOutput
here, but from there I don't see an easy way to tell that the AgentOutput.raw was actually an error instead of a string.
Maybe the
if-condition should be filtering out Tool outputs that are errors, or maybe the ToolOutput shouldn't convert the exception to string, or maybe both?