What it does
This example demonstrates a realistic two-agent email automation workflow with comprehensive failure handling:
- Register two agents — a planner (Agent A) and an executor (Agent B)
- Agent A reads calendar events after offline scope verification
- Agent A delegates
email:send to Agent B (subset of its own scopes)
- Agent B sends an email using the delegated, scoped permission
- Failure: unauthorized scope — Agent B tries
calendar:read (not delegated) and is rejected immediately
- Failure: cascade revocation — Agent A’s grant is revoked, which automatically invalidates Agent B’s delegated token
- Recovery pattern — Agent B detects the revoked token and reports that a new delegation is needed
- 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