Skip to content

Cookbook

Practical recipes demonstrating common patterns with OpenAgentMesh. Each recipe is a self-contained code sample you can copy and run.

To run any recipe against a local embedded mesh:

import asyncio
from openagentmesh import AgentMesh

async def run():
    async with AgentMesh.local() as mesh:
        # paste the recipe's main() body here
        ...

asyncio.run(run())

Or against your own mesh started with oam mesh up:

async with AgentMesh() as mesh:     # connects to nats://localhost:4222
    ...

Available Recipes

Recipe Pattern
Multi-Process Agents Provider/consumer on a shared bus
Multi-Module Projects Scaling beyond a single file
Shared Plan Coordination CAS-based concurrent state
LLM-Driven Tool Selection Runtime discovery for LLM tools
MCP Bridge Serve mesh agents to MCP clients
Secured Mesh JWT credentials and roles
Error Handling Retry, fallback, monitoring
Surviving Agent Failures Death notices and fast failover
Observing the Mesh Live log tailing and level control
Tracking LLM Usage Per-agent token and cost attribution
Admin UI Browse, invoke, and watch from the browser
Lifecycle-Gated Agents Condition-driven agent on/off
Automatic Load Balancing Queue group scaling
Reactive Pipeline KV watch coordination
Parallel RAG Indexing ObjectStore + queue groups

Interactive demos

For an interactive experience, try oam demo. It starts a local mesh with sample agents you can explore from another terminal.