Framework Integrations
Supported Frameworks
| Framework | Package | Status |
|---|---|---|
| LangGraph | substr8-langgraph | ✅ Production |
| AutoGen | Coming soon | 🔜 |
| CrewAI | Coming soon | 🔜 |
| PydanticAI | Coming soon | 🔜 |
LangGraph
The primary supported framework.
Installation
pip install substr8-langgraph langgraphBasic Usage
from langgraph.graph import StateGraph, END
from substr8_langgraph import instrument_graph
from typing import TypedDict
# Define state
class MyState(TypedDict):
input: str
output: str
# Define nodes
def process(state: MyState) -> dict:
return {"output": f"Processed: {state['input']}"}
# Build graph
graph = StateGraph(MyState)
graph.add_node("process", process)
graph.set_entry_point("process")
graph.add_edge("process", END)
# Compile
compiled = graph.compile()
# Wrap with Substr8
instrumented = instrument_graph(
compiled,
agent_id="my-agent",
project="my-project",
)
# Run
result = instrumented.invoke({"input": "Hello"})
# Result includes proof
print(f"Output: {result['output']}")
print(f"Run ID: {result['run_id']}")
print(f"Proof status: {result['proof_status']}")Saving the Proof
import json
proof = result["proof"]
proof_dict = proof.model_dump(mode="json")
with open("runproof.json", "w") as f:
json.dump(proof_dict, f, indent=2)Verifying
substr8 proof verify runproof.jsonEvents Captured
| Event | When |
|---|---|
run_started | Graph invocation begins |
node_started | Node execution begins |
node_ended | Node execution completes |
run_ended | Graph invocation completes |
Full Example
See the demo repository: substr8-langgraph-demo
git clone https://github.com/Substr8-Labs/substr8-langgraph-demo
cd substr8-langgraph-demo
pip install -r requirements.txt
python demo_agent.py
substr8 proof verify runproof.jsonComing Soon
AutoGen
Microsoft’s multi-agent framework.
# Coming in v1.1
from substr8_autogen import instrument_agentsCrewAI
Role-based agent orchestration.
# Coming in v1.1
from substr8_crewai import instrument_crewPydanticAI
Type-safe agent framework.
# Coming in v1.1
from substr8_pydanticai import instrument_agentCustom Integrations
For frameworks not yet supported, use substr8-core directly:
from substr8_core import RunState, RunStatus
state = RunState(agent_id="custom-agent", project="my-project")
# Start run
state.start()
# Emit events during your agent's execution
state.add_event("tool_called", {"tool": "search", "query": "..."})
state.add_event("tool_result", {"result": "..."})
# End run
state.end(RunStatus.COMPLETED, outputs={"answer": "..."})
# Build and save proof
proof = state.build_proof()This gives you full control over event emission.
Next Steps
- Quickstart — Full walkthrough
- SDK Reference — API details
- RunProof — Proof structure