Skip to content

.on()

Subscribe to typed agent lifecycle and execution events.

Updated View as Markdown

Signature

agent.on(type: EventType, handler: EventHandler): XsafAgent

Usage

agent
  .on("tool.called", (event) => {
    console.log(event.sessionId, event.tool);
  })
  .on("tool.failed", (event) => {
    reportError(event.error);
  });

Handlers can be registered before or after the agent is sealed. .on() returns the agent, so subscriptions can stay in the configuration chain.

Privacy boundary

Public telemetry intentionally excludes validated tool arguments and tool results. Use .approve() for privileged argument inspection, and publish tool results explicitly only when your application permits it.

Available events cover lifecycle, model calls, tools, delegates, schedules, heartbeats, and errors. See Types and events for the complete event union.

Navigation

Type to search…

↑↓ navigate↵ selectEsc close