
CapabilityMesh is the first comprehensive solution designed specifically for universal capability discovery and trust management across multiple Python agent frameworks - CrewAI, AutoGen, LangGraph, A2A, and custom implementations.
🌟 What Makes CapabilityMesh Unique?
CapabilityMesh is the FIRST and ONLY package that solves multi-framework agent discovery and collaboration.
The Problem: Framework Fragmentation
Today's multi-agent ecosystem is fragmented. Each framework operates in isolation:
❌ CrewAI agents can't discover AutoGen agents
❌ LangGraph workflows can't find A2A services
❌ No standard way to query "which agents can translate?"
❌ Manual integration required for every framework pair
❌ No trust or reputation across frameworks
❌ Reinventing discovery for each new agent
The CapabilityMesh Solution
✅ Universal discovery across ALL frameworks (CrewAI, AutoGen, LangGraph, A2A, custom)
✅ Semantic capability matching with natural language queries
✅ Built-in trust and reputation management
✅ Multiple storage backends (in-memory, SQLite, Redis)
✅ A2A protocol compatible
✅ Zero-config default, production-ready optional features
✅ 5 lines of code to working multi-agent discovery
🚀 Quick Start (5 Lines!)
from capabilitymesh import Mesh
mesh = Mesh() # Zero-config, works immediately!
@mesh.agent(name="translator", capabilities=["translation", "nlp"])
def translate(text: str, target_lang: str = "es") -> str:
return f"[Translated to {target_lang}]: {text}"
# Discover agents by capability (agent registered immediately!)
agents = await mesh.discover("translation")
result = await mesh.execute(agents[0].id, "Hello world!", target_lang="es")
That's it! No configuration, no setup, no complexity. Just register and discover.
💡 Deployment Note: This example runs in a single process. For distributed systems (microservices, multi-process), see Discovery Architecture for deployment patterns.
📦 Installation
# Core package (includes semantic search, trust, in-memory storage)
pip install capabilitymesh
# With SQLite persistence
pip install capabilitymesh[sqlite]
# With Redis (distributed systems)
pip install capabilitymesh[redis]
# With framework integrations
pip install capabilitymesh[crewai] # CrewAI support
pip install capabilitymesh[autogen] # AutoGen support
pip install capabilitymesh[langgraph] # LangGraph support
# Everything
pip install capabilitymesh[all]
🎯 Core Features
1. Universal Agent Discovery (The Main Value!)
Discover agents across ANY framework with natural language or exact matching:
from capabilitymesh import Mesh
mesh = Mesh()
# Register agents from different frameworks
@mesh.agent(name="summarizer", capabilities=["summarization", "nlp"])
async def summarize(text: str) -> str:
return "Summary: " + text[:100]
@mesh.agent(name="translator", capabilities=["translation", "language"])
def translate(text: str) -> str:
return "Translated: " + text
# Exact capability matching (works immediately)
agents = await mesh.discover("translation")
# Returns: [translator]
agents = await mesh.discover("summarization")
# Returns: [summarizer]
# Natural language discovery (enhanced with sentence-transformers/OpenAI)
# See examples/04_semantic_search.py for advanced semantic matching
agents = await mesh.discover("convert to another language")
# Can match 'translator' with enhanced embeddings
No Other Package Does This! CapabilityMesh is the ONLY solution for cross-framework capability discovery.
2. Multi-Framework Support (Unique!)
Register agents from ANY framework and discover them universally:
from capabilitymesh import Mesh
from crewai import Agent as CrewAgent
from autogen import AssistantAgent
mesh = Mesh()
# CrewAI agent
crew_researcher = CrewAgent(
role="researcher",
goal="Research topics thoroughly",
backstory="Expert researcher"
)
await mesh.register(crew_researcher, name="crew-researcher")
# AutoGen agent
autogen_coder = AssistantAgent(
name="coder",
system_message="You write clean Python code"
)
await mesh.register(autogen_coder, name="autogen-coder")
# Python function
@mesh.agent(name="my-analyzer", capabilities=["analysis"])
def analyze(data):
return {"result": "analyzed"}
# NOW: Discover across ALL frameworks!
all_agents = await mesh.list_agents()
# Returns: [crew-researcher, autogen-coder, my-analyzer]
# Find by capability - framework doesn't matter!
researchers = await mesh.discover("research information")
coders = await mesh.discover("write code")
analyzers = await mesh.discover("analysis")
Unique Value: Mix and match agents from different frameworks in the same workflow!
3. Built-in Trust & Reputation (Production-Ready!)
Automatically track agent reliability and filter by trust level:
from capabilitymesh import Mesh, TrustLevel
mesh = Mesh()
# Register agents
@mesh.agent(name="reliable-service", capabilities=["task-a"])
def reliable_agent(task):
return "success" # Always works
@mesh.agent(name="unstable-service", capabilities=["task-a"])
def unstable_agent(task):
if random.random() < 0.5:
raise ValueError("Failed!")
return "success"
# Execute multiple times - trust scores update automatically!
for i in range(20):
try:
await mesh.execute(reliable_id, f"task-{i}")
await mesh.execute(unstable_id, f"task-{i}")
except:
pass
# Check trust scores
reliable_score = await mesh.trust.get_score(reliable_id)
print(f"Reliable agent: {reliable_score.level.name}") # HIGH or VERIFIED
print(f"Success rate: {reliable_score.success_rate:.1%}") # ~100%
unstable_score = await mesh.trust.get_score(unstable_id)
print(f"Unstable agent: {unstable_score.level.name}") # LOW or MEDIUM
print(f"Success rate: {unstable_score.success_rate:.1%}") # ~50%
# Discover only trusted agents!
trusted = await mesh.discover("task-a", min_trust=TrustLevel.MEDIUM)
# Returns only agents with MEDIUM+ trust
Trust Levels: UNTRUSTED → LOW → MEDIUM → HIGH → VERIFIED (auto-calculated based on success rate)
4. Flexible Storage Backends (Production-Ready!)
Choose the storage that fits your needs:
from capabilitymesh import Mesh
from capabilitymesh.storage import InMemoryStorage, SQLiteStorage, RedisStorage
# Option 1: In-Memory (default, zero-config)
mesh = Mesh() # Fast, simple, no persistence
# Option 2: SQLite (persistent, full-text search)
mesh = Mesh(storage=SQLiteStorage("agents.db"))
# Agents persist across restarts
# Built-in FTS5 full-text search
# Option 3: Redis (distributed, scalable)
mesh = Mesh(storage=RedisStorage(host="localhost", port=6379))
# Multiple instances share the same agent registry
# Perfect for microservices
# ⚠️ IMPORTANT: Redis storage requires manual registration
# Use await mesh.register() instead of @mesh.agent decorator
# See Redis Usage Notes below for details
| Storage |
Persistence |
Search |
Distribution |
Best For |
| InMemory |
No |
Basic |
Single |
Dev, Testing |
| SQLite |
Yes (file) |
Full-text (FTS5) |
Single |
Production |
| Redis |
Yes (remote) |
Basic |
Multi-instance |
Cloud, Scale |
📘 Note on Distributed Systems: Redis enables discovery across multiple processes/machines, but execution is process-local for Python functions. For true distributed execution, use A2A adapters (HTTP-based agents). See Discovery Architecture for details.
⚠️ Redis Storage - Important Usage Note
Decorators do not work with Redis storage due to async event loop timing. Use manual registration instead:
# ❌ DON'T: Decorators with Redis (causes event loop conflicts)
storage = RedisStorage(host="localhost", port=6379)
mesh = Mesh(storage=storage)
@mesh.agent(name="agent", capabilities=["math"]) # ❌ Fails!
def my_agent(x):
return x * 2
# ✅ DO: Manual registration with Redis (works perfectly)
async def setup():
storage = RedisStorage(host="localhost", port=6379)
mesh = Mesh(storage=storage)
def my_agent(x: int) -> int:
return x * 2
# Use await mesh.register() instead
await mesh.register(my_agent, name="agent", capabilities=["math"])
return mesh
# ✅ ALTERNATIVE: Decorators with InMemory (works great for dev/test)
mesh = Mesh() # Default InMemory storage
@mesh.agent(name="agent", capabilities=["math"]) # ✅ Works!
def my_agent(x):
return x * 2
Why? Decorators run at module import time (before async event loop exists), but Redis operations require async context. This is a Python async limitation, not a bug.
Recommendation:
- Development: Use decorators with InMemory storage
- Production with Redis: Use
await mesh.register()
5. Semantic Search (Smart Discovery!)
Find agents using natural language queries. The default keyword-based embedder provides basic matching, with enhanced semantic search available via sentence-transformers or OpenAI embeddings:
from capabilitymesh import Mesh
mesh = Mesh() # Semantic search enabled by default!
# Register agents with descriptive capabilities
@mesh.agent(
name="sentiment-analyzer",
capabilities=["sentiment-analysis", "emotion-detection", "nlp"],
)
async def analyze_sentiment(text: str):
return {"sentiment": "positive", "confidence": 0.95}
@mesh.agent(
name="entity-extractor",
capabilities=["entity-extraction", "ner", "nlp"],
)
def extract_entities(text: str):
return ["person", "organization", "location"]
# Natural language queries
agents = await mesh.discover("understand the mood of customer reviews")
# Returns: [sentiment-analyzer] - semantic match!
agents = await mesh.discover("find people and places mentioned in text")
# Returns: [entity-extractor] - semantic match!
agents = await mesh.discover("nlp")
# Returns: [sentiment-analyzer, entity-extractor] - both match
How it works: Uses TF-IDF keyword embeddings by default (no external dependencies). Upgrade to sentence-transformers or OpenAI embeddings for even better results!
6. Advanced Capability Schema (Production-Ready!)
Define rich capabilities with versioning, constraints, and metadata:
from capabilitymesh import (
Capability,
CapabilityVersion,
CapabilityConstraints,
SemanticMetadata,
CapabilityType,
IOFormat,
)
# Define a structured capability with full specifications
capability = Capability(
name="translate-en-es",
description="Translate English text to Spanish",
capability_type=CapabilityType.STRUCTURED,
version=CapabilityVersion.from_string("2.1.0"),
# Performance constraints
constraints=CapabilityConstraints(
max_response_time_ms=100,
max_cost_per_call=0.001,
min_availability=0.999,
rate_limit_per_minute=1000,
),
# Semantic metadata for better discovery
semantic=SemanticMetadata(
tags=["translation", "nlp", "spanish"],
categories=["Natural Language Processing"],
domains=["linguistics", "localization"],
),
)
# Register agent with rich capability
@mesh.agent(name="professional-translator", capabilities=[capability])
async def translate(text: str, target_lang: str = "es"):
return f"Translated: {text}"
Capabilities include:
- Semantic versioning with compatibility checking
- Performance constraints (latency, cost, SLA)
- Input/output schemas (JSON Schema support)
- Semantic metadata for better discovery
- Deprecation notices
🎨 Complete Example: Multi-Agent Workflow
import asyncio
from capabilitymesh import Mesh, Capability, TrustLevel
async def main():
# Initialize mesh with persistent storage
mesh = Mesh(storage=SQLiteStorage("multi_agent.db"))
# Register a document processing pipeline
@mesh.agent(name="pdf-extractor", capabilities=["text-extraction", "pdf"])
def extract_text(pdf_path: str) -> str:
return f"Extracted text from {pdf_path}"
@mesh.agent(name="summarizer", capabilities=["summarization", "nlp"])
async def summarize(text: str) -> str:
await asyncio.sleep(0.1) # Simulate async processing
return f"Summary: {text[:100]}..."
@mesh.agent(name="translator", capabilities=["translation", "nlp"])
def translate(text: str, target_lang: str = "es") -> str:
return f"[{target_lang}] {text}"
# Process a document through the pipeline
pdf_path = "document.pdf"
# Step 1: Extract text
extractors = await mesh.discover("extract text from pdf")
text = await mesh.execute(extractors[0].id, pdf_path)
print(f"Extracted: {text}")
# Step 2: Summarize
summarizers = await mesh.discover("summarize text")
summary = await mesh.execute(summarizers[0].id, text)
print(f"Summary: {summary}")
# Step 3: Translate
translators = await mesh.discover("translate to Spanish")
translated = await mesh.execute(translators[0].id, summary, target_lang="es")
print(f"Translated: {translated}")
# Check trust scores
for agent in [extractors[0], summarizers[0], translators[0]]:
score = await mesh.trust.get_score(agent.id)
print(f"{agent.name}: {score.level.name} ({score.success_rate:.0%} success)")
if __name__ == "__main__":
asyncio.run(main())
🔌 Framework Integration Examples
CrewAI Integration
from capabilitymesh import Mesh
from crewai import Agent, Crew, Task
mesh = Mesh()
# Register CrewAI agents
researcher = Agent(
role="Senior Research Analyst",
goal="Uncover cutting-edge developments",
backstory="Expert at finding and analyzing information"
)
writer = Agent(
role="Tech Content Writer",
goal="Create engaging technical content",
backstory="Skilled writer with tech background"
)
# Register with CapabilityMesh
await mesh.register(researcher, name="researcher")
await mesh.register(writer, name="writer")
# Now discover them universally!
research_agents = await mesh.discover("research and analyze information")
writing_agents = await mesh.discover("write content")
AutoGen Integration