Observed since 20 Oct, 22:43 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Python Agent Graph Orchestration Engine - Build multi-agent workflows as executable graphs
Build agent and multi-agent workflows as executable graphs
Mesh is a lightweight Python library for orchestrating multi-agent workflows as executable graphs. Build complex agent systems with token-by-token streaming, state management, and seamless integration with Vel and OpenAI Agents SDK.
Comprehensive guides and API reference:
# Basic installation
pip install agentmesh-py
# With OpenAI Agents SDK support
pip install agentmesh-py[agents]
# With FastAPI server support
pip install agentmesh-py[server]
# Development installation
pip install agentmesh-py[dev]
# All features
pip install agentmesh-py[all]
# With Vel SDK support (install separately)
pip install agentmesh-py
pip install git+https://github.com/rscheiwe/vel.git
Create a .env file in your project root:
cp .env.example .env
Add your OpenAI API key:
OPENAI_API_KEY=sk-your-key-here
Load it in your code:
from mesh.utils import load_env
load_env() # Loads variables from .env
import asyncio
from mesh import StateGraph, Executor, ExecutionContext, MemoryBackend
from mesh.nodes import LLMNode
async def main():
# Build graph
graph = StateGraph()
graph.add_node("llm", None, node_type="llm", model="gpt-4")
graph.add_edge("START", "llm")
graph.set_entry_point("llm")
# Compile and execute
compiled = graph.compile()
executor = Executor(compiled, MemoryBackend())
context = ExecutionContext(
graph_id="my-graph",
session_id="session-1",
chat_history=[],
variables={},
state={}
)
# Stream results
async for event in executor.execute("What is 2+2?", context):
if event.type == "token":
print(event.content, end="", flush=True)
asyncio.run(main())
from mesh import ReactFlowParser, NodeRegistry, Executor
# Parse Flowise JSON
registry = NodeRegistry()
parser = ReactFlowParser(registry)
graph = parser.parse(flow_json)
# Execute
executor = Executor(graph, backend)
async for event in executor.execute(input_data, context):
print(event)
from fastapi import FastAPI
from mesh import Executor, ExecutionContext
from mesh.streaming import SSEAdapter
app = FastAPI()
@app.post("/execute/stream")
async def execute_stream(request: ExecuteRequest):
executor = Executor(graph, backend)
context = ExecutionContext(...)
adapter = SSEAdapter()
return adapter.to_streaming_response(
executor.execute(request.input, context)
)
Mesh supports template variables in node configurations:
{{$question}} - User input{{node_id}} - Reference node output{{node_id.field}} - Access nested fields{{$vars.key}} - Global variables{{$chat_history}} - Formatted chat history{{$iteration}} - Current iteration value (in loops)# In-memory (for development)
from mesh.backends import MemoryBackend
backend = MemoryBackend()
# SQLite (for production)
from mesh.backends import SQLiteBackend
backend = SQLiteBackend("mesh_state.db")
from mesh.nodes import Condition
def check_success(output):
return "success" in str(output).lower()
graph.add_node("condition", [
Condition("success", check_success, "success_handler"),
Condition("failure", lambda x: not check_success(x), "error_handler"),
], node_type="condition")
graph.add_node("loop", None, node_type="loop",
array_path="$.items", max_iterations=100)
def my_tool(input: str, multiplier: int = 2) -> str:
return input * multiplier
graph.add_node("tool", my_tool, node_type="tool",
config={"bindings": {"multiplier": 3}})
# Vel Agent (with streaming)
from vel import Agent as VelAgent
vel_agent = VelAgent(
id="assistant",
model={
"provider": "openai",
"name": "gpt-4",
"temperature": 0.7,
},
)
graph.add_node("agent", vel_agent, node_type="agent")
# Stream the output
async for event in executor.execute("Hello!", context):
if event.type == "token":
print(event.content, end="", flush=True)
# OpenAI Agents SDK (with Vel translation by default)
from agents import Agent
openai_agent = Agent(
name="Assistant",
instructions="You are a helpful assistant"
)
graph.add_node("agent", openai_agent, node_type="agent", config={"model": "gpt-4"})
# Or use native events
graph.add_node("agent", openai_agent, node_type="agent",
use_native_events=True, config={"model": "gpt-4"})
By default, Mesh uses Vel's event translation for consistent event handling across providers:
# Default: Vel-translated events (consistent across providers)
graph.add_node("agent", agent, node_type="agent")
# All providers emit the same event types
async for event in executor.execute(input, context):
if event.type == "token": # Same for OpenAI, Anthropic, Google
print(event.content, end="", flush=True)
# Optional: Use provider's native events
graph.add_node("agent", agent, node_type="agent", use_native_events=True)
See Event Translation Guide for details.
┌─────────────────────────────────────────────┐
│ User Application │
│ (FastAPI/Flask/Django) │
└────────────────┬────────────────────────────┘
│
▼
┌─────────────────────────────────────────────┐
│ MESH LIBRARY │
├─────────────────────────────────────────────┤
│ ┌──────────────┐ ┌──────────────┐ │
│ │ Parsers │ │ Builders │ │
│ │ - ReactFlow │ │ - StateGraph│ │
│ └──────┬───────┘ └──────┬───────┘ │
│ └──────────┬─────────┘ │
│ ▼ │
│ ┌──────────────────┐ │
│ │ Graph Compiler │ │
│ └────────┬─────────┘ │
│ ▼ │
│ ┌──────────────────┐ │
│ │ Execution Engine │ │
│ │ - Queue-based │ │
│ │ - Streaming │ │
│ └────────┬─────────┘ │
│ ▼ │
│ ┌───────────────────────┐ │
│ │ Node Implementations│ │
│ │ Agent│LLM│Tool│... │ │
│ └───────────────────────┘ │
└─────────────────────────────────────────────┘
See the examples/ directory:
Guides:
# Clone repository
git clone https://github.com/rscheiwe/mesh.git
cd mesh
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install development dependencies
pip install -e ".[all]"
# Run tests
pytest
# Run tests with coverage
pytest --cov=mesh --cov-report=html
# Format code
black mesh/
ruff check mesh/
# Type checking
mypy mesh/
For AI Assistants: See CLAUDE.md for comprehensive development context and architecture details.
Contributions welcome! Please read our contributing guidelines and submit PRs.
MIT License - see LICENSE file for details.
Inspired by:
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.2.1 | 5 Oct 2026 | 17 |
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 22:43 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:0efe41064341299a3c6a90d80bf8ff91e6edaffd361c3e9257515c7d88a663f9