LangChain integration for Mesh Cognition — give any agent distributed memory across devices
Project description
langchain-mesh-cognition
Give any LangChain agent distributed memory across devices. What one agent learns, all agents can recall.
Install
pip install langchain-mesh-cognition
Prerequisite: the mesh service must be running on each device:
npm install -g mesh-cognition-service
mesh-cognition start --daemon
Quick Start
Use tools directly (no LLM needed)
The tools work standalone — no API keys, no LLM costs:
from langchain_mesh_cognition import MeshMemoryWrite, MeshMemorySearch
# Write a memory — broadcasts to all mesh peers
MeshMemoryWrite().invoke({"content": "Team standup moved to 10am Monday", "tags": "meeting,standup"})
# Search from any device on the mesh
print(MeshMemorySearch().invoke({"query": "standup"}))
# → [Hongweis-MacBook-Air.local] Team standup moved to 10am Monday (tags: meeting, standup)
Use with a LangChain agent (optional)
Add mesh memory to a conversational agent that decides when to read/write:
from langchain_mesh_cognition import MeshCognitionToolkit
from langchain_openai import ChatOpenAI
from langgraph.prebuilt import create_react_agent
agent = create_react_agent(ChatOpenAI(model="gpt-4o"), MeshCognitionToolkit().get_tools())
agent.invoke({"messages": [("user", "What meetings do I have?")]})
# → Agent calls mesh_memory_search, finds meetings stored by any device on the mesh
Tools
| Tool | Description |
|---|---|
mesh_memory_write |
Store a memory and broadcast to all mesh peers |
mesh_memory_search |
Search memories across all devices on the mesh |
mesh_status |
Check mesh health — peer count, Kuramoto r(t), uptime |
mesh_context |
Get context from aligned peers for enriched reasoning |
Use Individual Tools
from langchain_mesh_cognition import MeshMemoryWrite, MeshMemorySearch
# Add specific tools to any agent
tools = [MeshMemoryWrite(), MeshMemorySearch()]
Custom Service URL
toolkit = MeshCognitionToolkit(base_url="http://192.168.1.100:18790")
Multi-Agent with LangGraph
from langchain_mesh_cognition import MeshCognitionToolkit
from langgraph.prebuilt import create_react_agent
# Two agents sharing the same mesh
research_agent = create_react_agent(llm, MeshCognitionToolkit().get_tools())
writing_agent = create_react_agent(llm, MeshCognitionToolkit().get_tools())
# Research agent stores findings → writing agent recalls them
research_agent.invoke({"messages": [("user", "Research quantum computing trends")]})
writing_agent.invoke({"messages": [("user", "Write a summary using mesh memory")]})
For cross-device mesh, start mesh-cognition on each machine. Agents on different devices share memory automatically via Bonjour/mDNS discovery.
How It Works
LangChain Agent
↓ uses tools
MeshCognitionToolkit
↓ HTTP calls
mesh-cognition-service (localhost:18790)
↓ TCP + Bonjour
Other mesh nodes on the network
The agent doesn't need to know about networking, discovery, or coupling. It just reads and writes memories — the mesh handles distribution.
Links
SYM.BOT Ltd · Apache 2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langchain_mesh_cognition-0.1.0.tar.gz.
File metadata
- Download URL: langchain_mesh_cognition-0.1.0.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77b83092ea270a6d2fd5a523665c0d0a3164e60a89d557b93f58bcc4579ae6b9
|
|
| MD5 |
3ab04057717990e9c1477c54bf4504ee
|
|
| BLAKE2b-256 |
762bc071fa4e5e86c433c6153d2d082ecf90b1755fb55affe8d8256393e8f3a5
|
File details
Details for the file langchain_mesh_cognition-0.1.0-py3-none-any.whl.
File metadata
- Download URL: langchain_mesh_cognition-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3bdefd54a1eff9fb73d68ffc290c29efb28977f74d0782cc33094ce12a46bf07
|
|
| MD5 |
b1b1342cafc5920bf5ed11495bee5240
|
|
| BLAKE2b-256 |
8cb123ac7fa16f9c39e8032327a5a38bd3c7e951446758e38f29e1da154f10ce
|