onError
Register an agent-level hook that runs when any SWAIG tool handler throws. Use it to report the failure to your error tracker and, optionally, to decide what the caller hears. The error is always contained: a thrown handler never breaks the live call.
The hook runs after the tool’s own onError option, if one was set in
defineTool().
Parameters
handler
Called with (error, context). Return a FunctionResult
to control the response, or return nothing to fall back to the tool’s
errorMessage or the default message. Pass undefined to clear the hook.
Returns
AgentBase — Returns this for method chaining.