Extracts the nearest toolName from an error's cause chain.
Walks the chain from the provided error toward its causes, returning the
first ToolError encountered (that is, the outermost ToolError in the
chain). Falls back to the provided fallback when no ToolError is found.
Parameters
error: unknown
Root error to inspect
fallback: string
Default tool name when no ToolError is in the chain
Extracts the nearest
toolNamefrom an error's cause chain.Walks the chain from the provided error toward its causes, returning the first
ToolErrorencountered (that is, the outermostToolErrorin the chain). Falls back to the providedfallbackwhen noToolErroris found.