Skip to content

Conversation

mylux
Copy link
Contributor

@mylux mylux commented Oct 18, 2025

The real purpose behind #431 and object of discussion in #434

@evalstate
Copy link
Owner

OK, I think this has the correct behaviour now:

async def test_error_handling_e2e(fast_agent, model_name):
"""Call a faulty tool and make sure the loop does as we expect."""
fast = fast_agent
# Define the agent
@fast.agent(
"agent",
instruction="SYSTEM PROMPT",
model=model_name,
servers=["test_server"],
)
async def agent_function():
async with fast.run() as agent:
await agent.agent.generate("fail please")
assert 4 == len(agent.agent.message_history)
# this makes sure that the user message has the tool result with the error
assert next(iter(agent.agent.message_history[-2].tool_results.values())).isError is True
await agent_function()

In the case of a standard Tool Call error, we reflect it back to the LLM to self-correct (hence the 4 messages in the test). If you want to capture that it happened, you can check the tool results isError flag (will usually be on the message_history[-2]).

The FAST_AGENT_ERROR_CHANNEL should really be used for otherwise unrecoverable exceptions; in this case the failure is "soft" - e.g. the LLM messed up some parameters or the MCP Server wanted to flag something going wrong, but not fatally.

LMK if this works for you, I'm very keen to get this merged now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants