A tool call finished successfully; the payload is a ToolCallDonePayload, carrying the result the tool returned and how long the call took.
A tool call failed; the payload is a ToolCallErrorPayload, carrying the reason in error when the server gave one. The agent carries on with the conversation.
The agent has begun a tool call; the payload is a ToolCallStartedPayload, carrying the call's id, the tool's name and the arguments the agent's LLM produced.
The tool-call events delivered to onToolEvent.
Switch on the first argument of the handler to tell them apart: it narrows the second argument to the payload that event carries — see ToolEventCallback. The members' values are the wire strings the server sends, so compare against the enum rather than writing the string out. Expressive (V4) agents only.
Example