Synchronous
The simplest way to run an agent. Blocks until the full response is ready.Asynchronous
Usearun() in async contexts such as web servers or async pipelines:
Streaming (Sync)
Stream events in real time. Each event represents a step in the agent’s execution:Streaming (Async)
Run Parameters
All four methods accept the same parameters:Files to include with the user message. When readers are enabled, file content is automatically extracted and injected into the prompt.
The RunOutput Object
Every non-streaming run returns aRunOutput with the full results:
Stream Event Types
Streaming runs yieldRunOutputEvent objects. Key event types:
Deploying with serve()
Useagent.serve() to start the full agent runtime — messaging interfaces, HTTP endpoints, webhooks, and cron jobs in a single call:
agent.serve() is a blocking sync call. Use agent.aserve() for async contexts.
When webhooks or cron triggers are registered via @agent.on(...), they run alongside interfaces automatically. Set agent.auth to protect HTTP endpoints with API key or JWT authentication.
See Agent Runtime for full details on webhooks, cron, event triggers, lifecycle hooks, and the HTTP server.