Skip to content
docsv0.12.0

ToolFailedEvent

POST event (tool-runtime 0.5, event-driven retrofit): a tool's callback threw. Dispatched by {@see \Milpa\ToolRuntime\ToolRegistry::call()} as `tool.failed` — pure notification, readonly, no slot (an exception has already happened; there is nothing left to veto or short-circuit). {@see \Milpa\ToolRuntime\ToolAuditLogger} subscribes to this event to log the failure exactly as it did before this event existed. Only dispatched for an exception thrown by the tool's own callback during execution — NOT for validation errors, authorization denials, or rate-limit rejections, which are rejected before `tool.executing` is ever dispatched (see the security anchor on {@see \Milpa\ToolRuntime\ToolRegistry::call()}) and continue to be logged directly by {@see \Milpa\ToolRuntime\ToolAuditLogger::logValidationFailure()} / {@see \Milpa\ToolRuntime\ToolAuditLogger::logAuthFailure()} / the rate-limit branch's direct {@see \Milpa\ToolRuntime\ToolAuditLogger::log()} call.

ToolFailedEvent::__construct()

public function __construct(string $name, Milpa\ToolRuntime\Contracts\ToolContext $ctx, array $args, Throwable $exception, int $tookMs):

Parameters

Parameters of __construct()
NameTypeDescription
$namestringTool name that failed
$ctxToolContextExecution context the call ran under
$argsarray<string, mixed>The (validated/clamped) arguments the call ran with
$exception\ThrowableThe exception thrown by the tool's callback
$tookMsintElapsed time in milliseconds up to the failure