Find answers from the community

Updated last week

The Final Agentoutput.raw Converts Tool's Raw_output Into A String

Hi,
I'm trying out the new AgentWorkflows with some return_direct tools, and I'm wondering why the final AgentOutput.raw is converting the tool's raw_output into a string. https://github.com/run-llama/llama_index/blob/98a1a4bfd4d54e108aaff52a550ff0763b1dab68/llama-index-core/llama_index/core/agent/workflow/multi_agent_workflow.py#L465 I understand that I could listen for the ToolCallResult events on the context's event stream for the raw output. I was just expecting the raw output to be available from the StopEvent.
L
J
10 comments
ah ok, thank you for fixing it!
Thanks for catching that πŸ‘
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?
I guess since it's a return_direct tool, it's ok that the final AgentOutput contains an error, it just needs to have a way to tell that it's an error.
@JG someone else brought this up somwhere, I was thinking of adding an argument to tools like raise_errors=True (or a global option on the workflow itself) -- unsure of which is best, and haven't had time to take a stab
As a quick solution, can we change raw_output=str(e) to raw_output=e here?
Yea that could work πŸ€”
If I can't tell the difference between a regular string response from the LLM and an error message in the StopEvent, then I'd either have to stop using StopEvent or stop using return_direct it seems like. Just don't want error messages leaking out to end users.
Add a reply
Sign up and join the conversation on Discord