Skip to main content

Poison-resistant, Byzantine-fault-tolerant shared chat memory for LangChain agent swarms — one prompt-injected agent can't corrupt the shared history.

Project description

memora-langchain

Poison-resistant, Byzantine-fault-tolerant shared chat memory for LangChain agent swarms.

When several LangChain agents share one conversation memory, that memory is the weakest link — one prompt-injected or malfunctioning agent can overwrite what every other agent then reads. memora-langchain backs LangChain's message history with Memora, a CRDT + Byzantine- tolerant shared store: concurrent writers merge without losing turns, and no single agent can silently rewrite the shared history.

pip install memora-langchain

That's it — this pulls in the memora-swarm engine and langchain-core for you. Get a free API key (25,000 ops free) at memora.optitransfer.ch/dashboard.

Quickstart

from memora_langchain import MemoraChatMessageHistory

history = MemoraChatMessageHistory(
    "support-crew",              # room: every agent using this room shares one history
    api_key="opti_sk_...",
    node_id="triage-agent",      # unique per agent
)

history.add_user_message("customer can't log in")
history.add_ai_message("checking their account status…")

for m in history.messages:       # merged view across the whole swarm
    print(type(m).__name__, m.content)

Use it with RunnableWithMessageHistory

from langchain_core.runnables.history import RunnableWithMessageHistory

chain_with_memory = RunnableWithMessageHistory(
    your_chain,
    lambda session_id: MemoraChatMessageHistory(session_id, api_key="opti_sk_...", node_id="agent"),
    input_messages_key="input",
    history_messages_key="history",
)

MemoraChatMessageHistory is a standard langchain_core.chat_history.BaseChatMessageHistory, so it works anywhere LangChain accepts a chat history — including as the shared store behind a LangGraph node.

Why it's safe under a swarm

  • No lost turns. The history is stored as uniquely-tagged message elements and every replica's view is unioned on read, so two agents writing at once can't clobber each other — both sets of turns survive.
  • No silent rewrite. Every write is signed and attributable to a node in the underlying Memora engine; a rogue agent's contribution is convicted/evicted rather than trusted on faith.
  • Durable + replayable. State survives restarts via a local append-only log.

Pricing

The first 25,000 ops are free (unlimited agents). After that it's metered per semantic op — see memora.optitransfer.ch. Reads and keepalive are never billed.

Links

Apache-2.0 · a product of optitransfer.ch

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

memora_langchain-0.1.0-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for memora_langchain-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ebcb553b1d38a8993bf3a3e8451d7273cf5ee543bb583458db49393cf9dce272
MD5 94a5175a0c3323feb348c5327a9f7561
BLAKE2b-256 5ac53c34c16548a83415f5c3bc9dd4ab1b92f3a96473a94efebb4c925dfd0c91

See more details on using hashes here.

Supported by

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