serve() function runs multiple interfaces at the same time, with automatic restart on failure and graceful shutdown on Ctrl+C.
Quick Example
serve() Function
BaseInterface
required
One or more interface instances to run concurrently.
str
default:"None"
Display name for logging. When
None, uses a generated name.IdentityResolver
default:"None"
Shared identity resolver propagated to all interfaces. See Identity Resolution.
Behavior
- Concurrent execution — each interface runs as an independent asyncio task
- Automatic restart — if an interface crashes, it restarts with exponential backoff (1s → 2s → 4s → … → 60s max)
- Stability threshold — if an interface runs for 60+ seconds without crashing, the backoff resets to 1s
- Graceful shutdown — Ctrl+C stops all interfaces and waits for clean shutdown
Agent.serve()
Agent.serve() creates an AgentRuntime that runs interfaces alongside webhooks, cron triggers, and an HTTP server:
agent.serve() is a blocking sync call. Use agent.aserve() for async contexts.