The integration pattern
MeshFlow sits above your agent framework as a production control plane. This guide shows how to wrap a LangGraph pipeline so every node execution gets governance, traceability, and cost controls automatically.
We'll use a three-agent pipeline that processes a regulatory filing: one agent extracts key clauses, one flags compliance issues, one drafts a summary for legal review.
Start with your LangGraph pipeline
LangGraph's typed state graph is an excellent way to model multi-step agent workflows. Define a TypedDict for your state, wire nodes together with conditional edges, and get deterministic routing with full type safety.
from langgraph.graph import StateGraphclass FilingState(TypedDict): filing: str clauses: list[str] issues: list[str] summary: str
graph = StateGraph(FilingState) graph.add_node("extract", extract_clauses) graph.add_node("review", flag_issues) graph.add_node("draft", draft_summary) graph.add_edge("extract", "review") graph.add_edge("review", "draft") ```
This works well for orchestration. But for regulated industries, you also need compliance enforcement, PII blocking, cost caps, and a tamper-evident audit trail.
Add MeshFlow governance in one line
Wrap your compiled graph with the MeshFlow LangGraph adapter:
agent = from_langgraph( graph.compile(), compliance_profile=compliance_profile("sox"), cost_cap=CostCap(usd=0.25), ) result = await agent.step("Process this filing", {}) ```
What you get without changing your graph code: - SHA-256 tamper-evident audit chain on every node execution - PIIBlocker running before every LLM call - Hard cost cap enforced at the kernel level - SOX compliance profile active with per-control pass/fail reporting - Per-step cost attribution in the result
What MeshFlow adds at each layer
| Layer | What MeshFlow provides |
|---|---|
| Per-node tracing | Input/output hashes, model version, causal chain |
| Policy enforcement | HIPAA, SOC 2, GDPR profiles — enforced before each LLM call |
| Cost governance | Hard caps, ModelRouter, per-step spend attribution |
| Durable execution | Checkpoint + resume across restarts and failures |
| Audit export | Signed evidence bundle downloadable for any compliance review |
Governance overhead
The MeshFlow adapter adds approximately 2–3ms per node for trace recording and policy evaluation. At three nodes, that is ~7ms total — within measurement noise for most production workloads.
Deploying to MeshFlow Cloud
Once you add the adapter, every run appears in MeshFlow Cloud's Trace Explorer. You get span timelines, per-step cost breakdowns, compliance check results, and the ability to download a signed evidence bundle for auditors.
meshflow.init(api_key="YOUR_API_KEY") # traces stream to the cloud dashboard ```
Running in production
For production deployments, use the full Workflow + DurableWorkflowExecutor for checkpoint-based resume:
executor = DurableWorkflowExecutor(backend="postgres") result = await executor.run(agent, task=filing_text, resume_run_id=prior_run_id) ```
You keep your existing LangGraph graph logic. MeshFlow wraps it with the production control plane — governance, cost, and auditability run transparently in the adapter layer.