Context Mesh
The Context Mesh is Syntha's shared knowledge space where agents store, discover, and retrieve information.
Basic Usage
from syntha import ContextMesh
# Create a context mesh for a specific user
context = ContextMesh(user_id="user123")
Core Operations
Pushing Context
# Global context (accessible by all agents)
context.push("project_name", "AI Customer Service")
# Agent-specific context
context.push(
"api_credentials",
{"endpoint": "https://api.example.com"},
subscribers=["BackendAgent", "APIAgent"]
)
# Topic-based context
context.push(
"customer_feedback",
{"rating": 4.5, "comments": "Great service!"},
topics=["sales", "support"]
)
Retrieving Context
# Get specific context item
project_name = context.get("project_name", "SalesAgent")
# Get all accessible context for an agent
all_context = context.get_all_for_agent("SalesAgent")
Context Routing
Global Context
Available to all agents.
Subscriber-Based Routing
Direct agent targeting.
Topic-Based Routing
Agents can receive context based on topics.
Configuration
# SQLite (default)
context = ContextMesh(user_id="user123")
# PostgreSQL
context = ContextMesh(
user_id="user123",
db_backend="postgresql",
connection_string="postgresql://user:pass@localhost:5432/syntha_db"
)