Skip to main content

langchain-mesh-cognition

Give any LangChain agent distributed memory across devices. What one agent learns, all agents can recall.

PyPI License

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_mesh_cognition-0.1.0.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_mesh_cognition-0.1.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file langchain_mesh_cognition-0.1.0.tar.gz.

File metadata

File hashes

Hashes for langchain_mesh_cognition-0.1.0.tar.gz
Algorithm Hash digest
SHA256 77b83092ea270a6d2fd5a523665c0d0a3164e60a89d557b93f58bcc4579ae6b9
MD5 3ab04057717990e9c1477c54bf4504ee
BLAKE2b-256 762bc071fa4e5e86c433c6153d2d082ecf90b1755fb55affe8d8256393e8f3a5

See more details on using hashes here.

File details

Details for the file langchain_mesh_cognition-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_mesh_cognition-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3bdefd54a1eff9fb73d68ffc290c29efb28977f74d0782cc33094ce12a46bf07
MD5 b1b1342cafc5920bf5ed11495bee5240
BLAKE2b-256 8cb123ac7fa16f9c39e8032327a5a38bd3c7e951446758e38f29e1da154f10ce

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page