StateWeave
Enables the transfer of an AI agent's accumulated knowledge, goals, and task states between the CrewAI framework and other agent platforms.
Allows exporting and importing agent cognitive state, including conversation history and working memory, to enable migration between LangGraph and other supported frameworks.
Supports exporting and importing cognitive states for OpenAI Agents, preserving knowledge such as conversation history and tool results.
StateWeave is git for agent brains โ debug, time-travel, and migrate agent state across 10 frameworks. When a 20-step autonomous workflow derails at step 15, see exactly what changed, rewind to step 14, and replay. Export from LangGraph, import into CrewAI with zero data loss. Checkpoint, rollback, diff, encrypt, sign โ all through a single Universal Schema.
When your agent hallucinates, crashes, or drifts โ stateweave why shows you the exact state transition that went wrong. When your enterprise needs to audit agent behavior, every state change is versioned, signed, and encrypted.
Why StateWeave?
StateWeave solves three critical problems in the AI agent ecosystem:
๐ Debugging โ Agent workflows are non-deterministic. When they go wrong, you need to pause, rewind, inspect, and replay โ not restart. stateweave why shows you the exact state transition that caused the failure. Version control for agent cognition.
๐ Security โ Agent state contains the agent's entire cognitive history. StateWeave encrypts at rest (AES-256-GCM), signs payloads (Ed25519), strips credentials on export, and enforces compliance policies.
๐ Portability โ Every framework has persistence, none have portability. StateWeave's Universal Schema โ a canonical representation of agent cognitive state โ lets you move state between any of 10 frameworks. One schema, N adapters, zero data loss (with explicit warnings for anything non-portable).
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โ LangGraph โ โ MCP โ โ CrewAI โ โ AutoGen โ
โ Adapter โ โ Adapter โ โ Adapter โ โ Adapter โ
โโโโโโโโฌโโโโโโโ โโโโโโโโฌโโโโโโโ โโโโโโโโฌโโโโโโโ โโโโโโโโฌโโโโโโโ
โ โ โ โ
โโโโโโโโโโโโโฌโโโโโโโโดโโโโโโโโโโโโฌโโโโโโโโ โ
โ โ โ
โผ โผ โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐งถ Universal Schema v1 โ
โ โ
โ conversation_history ยท working_memory ยท goal_tree โ
โ tool_results_cache ยท trust_parameters ยท audit_trail โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโStar topology, not mesh. N adapters, not Nยฒ translation pairs. Adding a new framework = one adapter, instant compatibility with everything else.
See it working
$ pip install stateweave
$ python examples/full_demo.py
โโ 1. Export from LangGraph โโ
โ Exported 4 messages
โ Source framework: langgraph
โโ 2. Import into MCP โโ
โ Imported into mcp
โ Messages preserved: 4
โโ 3. Verify Round-Trip โโ
โ Zero data loss: YES
โโ 4. Diff Agent States โโ
Summary: 7 added, 4 removed, 7 modified
โโ 5. Time Travel โโ
โ Checkpoint v1 (initial-research)
โ Checkpoint v2 (after-drug-discovery)
โ Rolled back โ 4 msgs
โโ 6. Encryption (AES-256-GCM) โโ
โ 1,733 bytes โ 1,749 bytes encrypted
โ Decrypted: 4 messages intact
โโ 7. Non-Portable Warnings โโ
โ No non-portable warnings (clean export)
7/7 steps passed. Everything runs from PyPI.Try it now:
pip install stateweave && stateweave quickstartโ zero-code demo in 10 seconds.Or run the full 7-step demo:
python examples/full_demo.py
One-Command Migration
$ stateweave migrate --from langgraph --to crewai --agent my-agent
๐งถ StateWeave Migrate: langgraph โ crewai
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโ Step 1: Export from langgraph โโ
โ Exported 12 messages, 5 memory keys (0.01s)
โโ Step 2: Validate payload โโ
โ Payload valid โ all schema checks passed
โโ Step 3: Import into crewai โโ
โ Imported into crewai (0.00s)
โโ Step 4: Verify round-trip โโ
โ Messages: 12 โ 12 (zero loss)
โ Memory keys: 5 โ 5 (zero loss)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
Migration complete: langgraph โ crewai (0.01s)One-Line Auto-Instrumentation
import stateweave
stateweave.auto(verbose=True) # Auto-checkpoint + confidence alerts + session summary card.After every agent run, StateWeave prints a rich session summary:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐งถ StateWeave Session Summary โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Agent: my-agent โ
โ Steps: 12 Checkpoints: 3 โ
โ Confidence: 87% โฒ โ
โ โ
No alerts โ agent ran clean โ
โ ๐ก Run: stateweave report โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโgit-Style CLI
stateweave log my-agent # Beautiful checkpoint history with confidence sparkline
stateweave blame my-agent confidence # Which checkpoint changed confidence? Value history.
stateweave stash my-agent # Save current state (like git stash)
stateweave pop my-agent # Restore stashed state
stateweave replay my-agent # Step-by-step state debugger
stateweave watch # Live agent health dashboard (htop for agent brains)
stateweave ci my-agent # CI regression detection โ exits non-zero on failureQuick Start
Install
pip install stateweaveUse with Claude Desktop / Cursor
Add to your MCP config (~/.cursor/mcp.json or Claude Desktop settings):
{
"mcpServers": {
"stateweave": {
"command": "python3",
"args": ["-m", "stateweave.mcp_server"]
}
}
}Claude and Cursor can now export, import, and diff your agent state directly.
Export an Agent's State
from stateweave import LangGraphAdapter, MCPAdapter, diff_payloads
# Set up a LangGraph agent with some state
lg = LangGraphAdapter()
lg._agents["my-agent"] = {
"messages": [
{"type": "human", "content": "What's the weather?"},
{"type": "ai", "content": "It's 72ยฐF and sunny!"},
],
"current_task": "weather_check",
}
# Export from LangGraph
payload = lg.export_state("my-agent")
print(f"Exported: {len(payload.cognitive_state.conversation_history)} messages")Import into Another Framework
from stateweave import MCPAdapter
# Import into MCP
mcp_adapter = MCPAdapter()
mcp_adapter.import_state(payload)
# The agent resumes with its memories intactAuto-Checkpoint Middleware
from stateweave.middleware import auto_checkpoint
# Simple: checkpoint every 5 steps
@auto_checkpoint(every_n_steps=5)
def run_agent(payload):
return payload
# Smart: only checkpoint on significant state changes
@auto_checkpoint(strategy="on_significant_delta", delta_threshold=3)
def smart_agent(payload):
return payload
# Manual: zero overhead, checkpoint when you decide
@auto_checkpoint(strategy="manual_only")
def hot_path_agent(payload):
return payloadMigrate with Encryption
from stateweave import EncryptionFacade, MigrationEngine
# Set up encrypted migration
key = EncryptionFacade.generate_key()
engine = MigrationEngine(
encryption=EncryptionFacade(key)
)
# Full pipeline: export โ validate โ encrypt โ transport
result = engine.export_state(
adapter=langgraph_adapter,
agent_id="my-agent",
encrypt=True,
)
# Decrypt โ validate โ import on the other side
engine.import_state(
adapter=mcp_adapter,
encrypted_data=result.encrypted_data,
nonce=result.nonce,
)Diff Two States
from stateweave import diff_payloads
diff = diff_payloads(state_before, state_after)
print(diff.to_report())
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# ๐ STATEWEAVE DIFF REPORT
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# Changes: 5 (+2 -1 ~2)
# [working_memory]
# + working_memory.new_task: 'research'
# ~ working_memory.confidence: 0.7 โ 0.95Framework Support
Framework | Adapter | Export | Import | Tier |
LangGraph |
| โ | โ | ๐ข Tier 1 |
MCP |
| โ | โ | ๐ข Tier 1 |
CrewAI |
| โ | โ | ๐ข Tier 1 |
AutoGen |
| โ | โ | ๐ข Tier 1 |
DSPy |
| โ | โ | ๐ก Tier 2 |
OpenAI Agents |
| โ | โ | ๐ก Tier 2 |
LlamaIndex |
| โ | โ | ๐ต Community |
Haystack |
| โ | โ | ๐ต Community |
Letta / MemGPT |
| โ | โ | ๐ต Community |
Semantic Kernel |
| โ | โ | ๐ต Community |
Custom | Extend | โ | โ | DIY |
Tier definitions: ๐ข Tier 1 = Core team maintained, guaranteed stability. ๐ก Tier 2 = Actively maintained, patches may lag. ๐ต Community = Best-effort, contributed by community.
Debug Agent Failures
When your agent hallucinates, crashes, or drifts โ stateweave why shows you exactly what happened:
$ stateweave why my-agent
๐ StateWeave Autopsy: my-agent
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Checkpoints: 5 versions
Latest: v5 (2026-03-20 14:23:01)
๐ State Evolution
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
v1 โ v2: 3 changes (+2 added, ~1 modified)
v2 โ v3: 7 changes (+4 added, ~2 modified, -1 removed) โ BIGGEST
v3 โ v4: 1 change (~1 modified)
v4 โ v5: 2 changes (+1 added, ~1 modified)
๐ฉบ Diagnosis
Biggest change: v2 โ v3 (7 changes)
Label: after-tool-failure
๐ก Recommendation: stateweave rollback my-agent 2Then rollback and continue:
from stateweave.core.timetravel import CheckpointStore
store = CheckpointStore()
restored = store.rollback("my-agent", version=2)
# Agent brain restored to pre-failure stateSee the full demo:
python examples/viral_demo.py
MCP Server
StateWeave ships as an MCP Server โ any MCP-compatible AI assistant can use it directly.
Tools
Tool | Description |
| Export an agent's cognitive state from any supported framework |
| Import state into a target framework with validation |
| Compare two states and return a detailed change report |
Resources
Resource | URI |
Universal Schema spec |
|
Migration history log |
|
Live agent snapshot |
|
Prompts
Prompt | Use Case |
| Agent self-requests state backup before risky ops |
| Step-by-step framework migration template |
The Universal Schema
Every agent's state is represented as a StateWeavePayload:
StateWeavePayload(
stateweave_version="0.3.15",
source_framework="langgraph",
exported_at=datetime,
cognitive_state=CognitiveState(
conversation_history=[...], # Full message history
working_memory={...}, # Current task state
goal_tree={...}, # Active goals
tool_results_cache={...}, # Cached tool outputs
trust_parameters={...}, # Confidence scores
long_term_memory={...}, # Persistent knowledge
episodic_memory=[...], # Past experiences
),
metadata=AgentMetadata(
agent_id="my-agent",
access_policy="private",
),
audit_trail=[...], # Full operation history
non_portable_warnings=[...], # Explicit data loss docs
)Security
AES-256-GCM authenticated encryption with unique nonce per operation
PBKDF2 key derivation (600K iterations, OWASP recommended)
Ed25519 payload signing โ digital signatures verify sender identity and detect tampering
Credential stripping โ API keys, tokens, and passwords are flagged as non-portable and stripped during export
Non-portable warnings โ every piece of state that can't fully transfer is explicitly documented (no silent data loss)
Associated data โ encrypt with AAD to bind ciphertext to specific agent metadata
Payload Signing
from stateweave import EncryptionFacade
# Generate a signing key pair
private_key, public_key = EncryptionFacade.generate_signing_keypair()
# Sign serialized payload
signature = EncryptionFacade.sign(payload_bytes, private_key)
# Verify on receipt
is_authentic = EncryptionFacade.verify(payload_bytes, signature, public_key)Delta State Transport
For large state payloads, send only the changes:
from stateweave.core.delta import create_delta, apply_delta
# Create delta: only the differences
delta = create_delta(old_payload, new_payload)
# Apply delta on the receiver side
updated = apply_delta(base_payload, delta)Agent Time Travel
Version, checkpoint, rollback, and branch agent cognitive state:
from stateweave.core.timetravel import CheckpointStore
store = CheckpointStore()
# Save a checkpoint
store.checkpoint(payload, label="before-experiment")
# View history
print(store.format_history("my-agent"))
# Roll back to a previous version
restored = store.rollback("my-agent", version=3)
# Branch from a checkpoint
store.branch("my-agent", version=3, new_agent_id="my-agent-experiment")
# Diff two versions
diff = store.diff_versions("my-agent", version_a=1, version_b=5)
print(diff.to_report())Content-addressable storage (SHA-256), parent hash chains, delta compression between versions.
A2A Bridge
Bridge between the Agent2Agent (A2A) protocol and StateWeave. A2A defines how agents communicate โ StateWeave adds what agents know:
from stateweave.a2a import A2ABridge
bridge = A2ABridge()
# Package state for A2A handoff
artifact = bridge.create_transfer_artifact(payload)
# Extract state from received A2A message
extracted = bridge.extract_payload(a2a_message_parts)
# Generate AgentCard skill for capability advertisement
caps = bridge.get_agent_capabilities()
skill = caps.to_agent_card_skill()State Merge (CRDT Foundation)
Merge state from parallel agents:
from stateweave.core.merge import merge_payloads, ConflictResolutionPolicy
result = merge_payloads(
agent_a_state, agent_b_state,
policy=ConflictResolutionPolicy.LAST_WRITER_WINS,
)
merged_payload = result.payloadNon-Portable State
Not everything can transfer between frameworks. StateWeave handles this honestly:
Category | Example | Behavior |
DB connections |
| โ ๏ธ Stripped, warning emitted |
Credentials |
| ๐ด Stripped, CRITICAL warning |
Framework internals | LangGraph | โ ๏ธ Stripped, warning emitted |
Thread/async state |
| โ ๏ธ Stripped, warning emitted |
Live connections | Network sockets, file handles | โ ๏ธ Stripped, warning emitted |
All non-portable elements appear in payload.non_portable_warnings[] with severity, reason, and remediation guidance.
Zero-Loss Translations
Framework-specific state that doesn't map to universal fields is not silently dropped โ it's preserved in cognitive_state.framework_specific:
# LangGraph internals survive the round-trip
payload = lg_adapter.export_state("my-thread")
print(payload.cognitive_state.framework_specific)
# {"__channel_versions__": {"messages": 5}, "checkpoint_id": "ckpt-abc"}
# Import back into LangGraph โ internal state is restored
target = LangGraphAdapter()
target.import_state(payload)Three layers of state handling:
Layer | Storage | Round-Trip |
Universal |
| โ Fully portable |
Framework-specific |
| โ Preserved in same-framework |
Non-portable |
| โ ๏ธ Stripped with warnings |
Building a Custom Adapter
Extend StateWeaveAdapter to add support for any framework:
from stateweave.adapters.base import StateWeaveAdapter
from stateweave.schema.v1 import StateWeavePayload, AgentInfo
class MyFrameworkAdapter(StateWeaveAdapter):
@property
def framework_name(self) -> str:
return "my-framework"
def export_state(self, agent_id: str, **kwargs) -> StateWeavePayload:
# Translate your framework's state โ Universal Schema
...
def import_state(self, payload: StateWeavePayload, **kwargs):
# Translate Universal Schema โ your framework's state
...
def list_agents(self) -> list[AgentInfo]:
# Return available agents
...The UCE adapter_contract scanner automatically validates that all adapters correctly implement the ABC.
CLI
# โโ Get started in 10 seconds โโ
stateweave quickstart # zero-code demo: checkpoint, diff, rollback
stateweave init # set up project config (.stateweave/config.toml)
# โโ One-command migration โโ
stateweave migrate --from langgraph --to crewai --agent my-agent
stateweave benchmark # round-trip fidelity test across all 10 frameworks
# โโ Debug agent failures โโ
stateweave why my-agent # autopsy: what changed and where it went wrong
stateweave doctor # diagnostic health checks
stateweave replay my-agent # step-by-step state debugger
# โโ git-style state management โโ
stateweave log my-agent # checkpoint history with confidence sparkline
stateweave blame my-agent confidence # trace which checkpoint changed a key
stateweave stash my-agent # save current state (like git stash)
stateweave pop my-agent # restore stashed state
# โโ Version control for agent state โโ
stateweave checkpoint state.json --label "before-experiment"
stateweave history my-agent
stateweave rollback my-agent 3 -o restored.json
stateweave diff before.json after.json
# โโ Export / Import โโ
stateweave export -f langgraph -a my-agent -o state.json
stateweave import -f crewai --payload state.json
stateweave detect state.json # auto-detect source framework
stateweave inspect state.json # pretty-print payload with structured summary
# โโ Monitoring โโ
stateweave watch # live agent health dashboard (htop for brains)
stateweave status my-agent # agent state summary
stateweave stats # aggregate dashboard: agents, checkpoints, store size
stateweave ci my-agent # CI regression detection (exits non-zero on failure)
# โโ Utilities โโ
stateweave try # interactive migration picker
stateweave report # shareable markdown report for PRs/Slack
stateweave hook install # install git pre-commit hook (auto-runs ci)
stateweave version # version, adapters, encryption status
stateweave adapters # list all 10 framework adapters
stateweave scan # scan for installed frameworks
stateweave schema -o schema.json # dump Universal Schema as JSON Schema
stateweave validate state.json # validate a payload file
stateweave generate-adapter my-framework # scaffold new adapter
stateweave completions bash # generate shell completions (bash/zsh/fish)
# โโ Maintenance โโ
stateweave clean --keep 5 # prune old checkpoints (keep latest 5)
stateweave config list # view config without editing TOML
stateweave config set --key framework --value langgraph
stateweave upgrade # check for new versions on PyPI
stateweave env # full environment snapshot (Python, frameworks, store)
stateweave search "confidence" # search checkpoint history for key/value
stateweave compare my-agent 1 3 # visual diff between two checkpoint versionsCompliance (UCE)
StateWeave enforces its own architectural standards via the Universal Compliance Engine โ 12 automated scanners that catch architecture violations before they ship:
Scanner | What It Checks | Mode |
| Universal Schema models have required fields | BLOCK |
| All adapters implement the full ABC | BLOCK |
| No raw pickle/json.dumps outside serializer | BLOCK |
| All crypto goes through EncryptionFacade | BLOCK |
| MCP server has all required tools | BLOCK |
| No cross-layer imports | BLOCK |
| All loggers use | BLOCK |
| Minimum test file coverage ratio | BLOCK |
| No orphan files outside MANIFEST | WARN |
| No circular imports | BLOCK |
| Adapters cannot import across isolation boundaries | BLOCK |
| Ruff formatting standards enforced | BLOCK |
# Run UCE locally
python scripts/uce.py
# Run in CI mode (exit 1 on failure)
python scripts/uce.py --mode=CI --jsonWhy Not Just Serialize to JSON Yourself?
You could โ and it'll work for one framework. Here's what you'd have to build:
Problem | DIY JSON | StateWeave |
Map LangGraph's | Write it yourself for each pair | Handled by adapters |
Detect credentials in state (API keys, OAuth tokens) | Easy to miss โ leaked secrets | Auto-stripped with warnings |
Validate state structure after migration | Write your own schema checks | Pydantic models + UCE scanners |
Track what was lost during migration | Hope you remember |
|
Encrypt state for transport | DIY crypto (dangerous) | AES-256-GCM + Ed25519 |
Roll back if migration goes wrong | No undo |
|
Support 10 frameworks | 90 translation pairs (Nยฒ) | 10 adapters (N) |
StateWeave exists because the translation layer between frameworks is boring, error-prone work that every team rebuilds. We built it once.
Contributing
We welcome contributions! The highest-impact way to contribute is building a new framework adapter. See Building a Custom Adapter above.
Development Setup
git clone https://github.com/GDWN-BLDR/stateweave.git
cd stateweave
pip install -e ".[dev]"
# Run tests
pytest tests/ -v
# Run UCE
python scripts/uce.pyArchitecture
stateweave/
โโโ schema/ # Universal Schema (Pydantic models)
โโโ core/ # Engine (serializer, encryption, diff, delta, timetravel, environment, doctor)
โโโ adapters/ # Framework adapters (10 frameworks)
โโโ a2a/ # A2A protocol bridge
โโโ middleware/ # Auto-checkpoint middleware
โโโ playground/ # Interactive playground (REST API + UI)
โโโ registry/ # Schema registry (publish, search, discover)
โโโ templates/ # Project scaffolding (create-stateweave-agent)
โโโ mcp_server/ # MCP Server implementation
โโโ compliance/ # UCE scannersAdditional Tools
Tool | Description |
VS Code Extension | Payload preview, diff, doctor, adapter scaffold โ |
TypeScript SDK | Universal Schema types, serializer, diff โ |
GitHub Action | CI validation + PR diffs โ |
Using StateWeave?
Add the badge to your project's README:
[](https://github.com/GDWN-BLDR/stateweave)License
Apache 2.0 โ use it, modify it, ship it. Patent shield included.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/GDWN-BLDR/stateweave'
If you have feedback or need assistance with the MCP directory API, please join our Discord server