Skip to main content

What it does

This example demonstrates a realistic two-agent email automation workflow with comprehensive failure handling:
  1. Register two agents — a planner (Agent A) and an executor (Agent B)
  2. Agent A reads calendar events after offline scope verification
  3. Agent A delegates email:send to Agent B (subset of its own scopes)
  4. Agent B sends an email using the delegated, scoped permission
  5. Failure: unauthorized scope — Agent B tries calendar:read (not delegated) and is rejected immediately
  6. Failure: cascade revocation — Agent A’s grant is revoked, which automatically invalidates Agent B’s delegated token
  7. Recovery pattern — Agent B detects the revoked token and reports that a new delegation is needed
  8. Audit trail inspection — shows a timeline of all success and failure events across both agents

Prerequisites

  • Node.js 18+
  • Docker (Docker Desktop or Docker Engine with Compose)

Run

Start the local Grantex stack from the repository root:
In a separate terminal, run the example:

Expected output

Environment variables

Source code

The full source is in examples/multi-agent-email-flow/src/index.ts.
Last modified on March 30, 2026