Reference

Event System

Open Astra emits typed, Zod-validated events for every significant action. Events are published on an in-process event bus and optionally forwarded to configured outbound webhooks. All event payloads are JSON-serializable.

Event bus

The event bus (events/bus.ts) is a singleton initialized at startup via getEventBus(). You can subscribe to events programmatically in plugins or custom tools:

typescript
import { getEventBus } from '../events/index';

const bus = getEventBus();
bus.on('agent.completed', (event) => {
  console.log(\`Agent ${event.agentId} completed in ${event.durationMs}ms\`);
});

Agent events

EventWhen emittedKey payload fields
agent.startedAt the start of each agent turnagentId, sessionId, userId, surface
agent.completedAfter the agent turn finishes (including tool loop)agentId, sessionId, durationMs, usage, toolCallCount
agent.failedWhen an unhandled error occurs during a turnagentId, error, consecutiveFailures
agent.pausedWhen max consecutive failures is reachedagentId, consecutiveFailures
agent.resumedWhen a paused agent is resumedagentId, resumedBy
agent.compactedWhen context is compacted due to token limitagentId, sessionId, messagesCompacted

Streaming events

EventWhen emittedKey payload fields
agent.stream.deltaEach token chunk during streamingagentId, sessionId, delta
agent.stream.tool_callWhen a tool call is detected in streamagentId, toolName, params
agent.stream.tool_resultAfter a tool finishes in streamagentId, toolName, result, durationMs
agent.stream.completeWhen stream finishesagentId, sessionId, totalTokens

Tool events

EventWhen emittedKey payload fields
tool.executedAfter any tool call completes (success or error)toolName, agentId, params, result, durationMs, error?

Memory events

EventWhen emittedKey payload fields
memory.writtenWhen a new memory entry is savedtier, type, userId, workspaceId

Session events

EventWhen emittedKey payload fields
session.createdWhen a new session is createdsessionId, userId, surface, agentId

Webhook events

EventWhen emittedKey payload fields
webhook.dispatchedAfter an outbound webhook firesurl, event, statusCode, durationMs
approval.requestedWhen a tool requires human approvalrequestId, agentId, tool, params, expiresAt
quota.exceededWhen a quota limit is hitagentId, quotaType, limit, current

Outbound webhooks

Configure a webhook URL to receive events as HTTP POST requests. The payload is a JSON object with an event field and all event payload fields. Requests are signed with HMAC-SHA256 using WEBHOOK_SECRET:

typescript
// Verify webhook signature in your receiver
import { createHmac } from 'crypto';

function verifyWebhook(body: string, signature: string, secret: string): boolean {
  const expected = createHmac('sha256', secret)
    .update(body)
    .digest('hex');
  return signature === \`sha256=${expected}\`;
}