Skip to content

feat: LangChain drop-in with auto-provenance - #3

Merged
mthamil107 merged 1 commit into
mainfrom
feat/langchain
Jul 27, 2026
Merged

feat: LangChain drop-in with auto-provenance#3
mthamil107 merged 1 commit into
mainfrom
feat/langchain

Conversation

@mthamil107

Copy link
Copy Markdown
Owner

Closes the biggest seamlessness gap: a drop-in LangChain chat history that gives you recoverable, poison-cleanable agent memory with no manual provenance tagging.

What

  • MemorywireChatMessageHistory(BaseChatMessageHistory) — persists every message to memorywire, auto-deriving source from the message role:
    • HumanMessageuser, SystemMessagesystem, AIMessageagent (trusted)
    • ToolMessage/FunctionMessagetool_result (untrusted — the injection vector)
  • Works anywhere LangChain wants a BaseChatMessageHistory (e.g. RunnableWithMessageHistory). Sync + async.
  • .recover() / .arecover() — cleans the session, scoped to conversation trust ({user, system, agent}): purges tool-origin poison without deleting the conversation. dry_run defaults to True.
  • [langchain] optional dep (langchain-core>=0.3).

Why it matters

recover's power depends on the source field. Until now that was the developer's job to set. This makes it automatic in the biggest agent framework — turning recover from "works if you instrument everything" into "works out of the box."

Tests

3 new (tests/unit/test_langchain.py) — role→source mapping; a ToolMessage becomes purge-flagged while user/ai/system stay; clear forgets. Full unit suite green (315). A test caught (and we fixed) that the agent's own replies must be trusted in a conversation, else recover would nuke them.

Additive; docs in docs/langchain.md.

MemorywireChatMessageHistory persists LangChain messages to memorywire, deriving source
from message role (tool->tool_result untrusted; user/system/agent trusted) so recover works
with zero manual tagging. Exposes .recover()/.arecover() scoped to conversation trust
(purges tool-origin poison, keeps the conversation). [langchain] optional dep. 3 tests;
full suite green (315). Docs + README.
@mthamil107
mthamil107 merged commit 73f2e87 into main Jul 27, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant