ctx.events
Emit structured events from your agent. The platform delivers them to subscribers (other agents, webhook endpoints) and records them for attestation. You stay decoupled from consumers.
Why it exists: So event-driven workflows and integrations use one vocabulary and one bus. How it helps: You get delivery, retries, and attestation without building queues or webhook glue.
ctx.events.emit
Pass an event type, optional subject (resource kind + URI), and payload. The platform routes to subscribers and logs the event for provenance.
typescript
// Emit a structured event — platform handles delivery and attestationawait ctx.events.emit({ type: 'invoice.validated', subject: { kind: 'core.invoice.document', uri: `resource://core/invoice/${invoiceId}` }, payload: { invoice_id: invoiceId, total: 14200, status: 'approved', validated_at: new Date().toISOString(), },});
// Subscribers (other agents, webhooks, muscles) receive the event// without your agent knowing who they are — decoupled, event-driven workflows.See also
- Manifest — Declare
on[]event triggers so your agent is woken by matching events. - Webhooks & event triggers —
on[], signing, and local testing. - Webhook integration guide — HTTPS subscribers, verification, retries, Command Plane.
- ctx.provenance — Events are part of the audit trail.