if I raise a ToolError in on_enter, is the agent g...
# ask-ai
p
if I raise a ToolError in on_enter, is the agent going to process it as if it was thrown from a function tool?
t
Thanks for reaching out, Mario. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I understand that raising a
ToolError
in
on_enter
might be a bit confusing. Just to clarify, this type of error is meant specifically for the tool execution pipeline. So, when it's raised in
on_enter
, it will cause the task to fail and the error will be logged, but it won’t be sent back to the agent as a tool-specific error message. If you're looking to manage errors in
on_enter
, a good approach would be to use the usual Python error handling and logging techniques. This way, you can keep things running smoothly and have better control over the errors. I hope this helps! Feel free to ask if you'd like more guidance on this. Sources: livekit-agents/livekit/agents/voice/agent.py | Tool definition and use | LiveKit Docs | Docs::Agents