Skip to content

feat: implement powermem langchain middleware - #1181

Closed
ANNSstudy wants to merge 1 commit into
oceanbase:vldb_2026from
ANNSstudy:ANNSstudy-patch-1
Closed

ANNSstudy wants to merge 1 commit into
oceanbase:vldb_2026from
ANNSstudy:ANNSstudy-patch-1

Conversation

@ANNSstudy

Copy link
Copy Markdown

Summary

Implement PowerMemMiddleware for LangChain v1 agents, providing PowerMem as a reusable long-term memory layer.

Changes

  • Retrieve relevant memories before model calls
  • Inject retrieved memories into model-visible context
  • Persist the latest user message and assistant response after agent execution
  • Respect save_interactions=False
  • Use the explicitly configured user_id
  • Fail open when PowerMem search or persistence fails
  • Support synchronous and asynchronous agent invocation
  • Preserve existing system prompts when injecting memory context

Testing

Executed from the repository root:

uv run --no-project \
  --python 3.11 \
  --with-editable "." \
  --with-editable "packages/powermem-langchain[test]" \
  pytest packages/powermem-langchain/tests -q


##result
6 passed, 3 third-party dependency warnings

Implement PowerMem middleware for LangChain v1 with synchronous and asynchronous memory retrieval, model context injection, interaction persistence, configurable persistence, and fail-open behavior.
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@LINxiansheng

Copy link
Copy Markdown
Member

LangChain Contract Score

LangChain Contract Score
========================
score: 100.00 / 100
suites: 2
rule: A weighted capability receives credit only when it passes on every configured Python suite and all declared prerequisite capabilities also receive credit. Gate tests are reported but do not add points.

Public import contract: PASS (gate)
  py311: passed
  py312: passed
Retrieve memory before model call: PASS (35/35)
  py311: passed
  py312: passed
Persist interaction after agent run: PASS (25/25)
  py311: passed
  py312: passed
Disable interaction persistence: PASS (10/10)
  py311: passed
  py312: passed
Fail-open on search error: PASS (15/15)
  py311: passed
  py312: passed
Async memory injection: PASS (15/15)
  py311: passed
  py312: passed

LangChain Contract Report

LangChain Contract Report
=========================
score: 100.00 / 100
rule: A weighted capability receives credit only when it passes on every configured Python suite and all declared prerequisite capabilities also receive credit. Gate tests are reported but do not add points.

Suite Summary
-------------
py311: passed=6/6, failures=0, errors=0, skipped=0
py312: passed=6/6, failures=0, errors=0, skipped=0

Gate Checks
-----------
Public import contract [gate] PASS
  - py311: passed
  - py312: passed

Weighted Breakdown
------------------
Retrieve memory before model call [35/35] PASS
  - py311: passed
  - py312: passed
Persist interaction after agent run [25/25] PASS
  - py311: passed
  - py312: passed
Disable interaction persistence [10/10] PASS
  - py311: passed
  - py312: passed
Fail-open on search error [15/15] PASS
  - py311: passed
  - py312: passed
Async memory injection [15/15] PASS
  - py311: passed
  - py312: passed

Workflow run

@PsiACE PsiACE added the vldb 2026 VLDB 2026 contributions label Jul 15, 2026 — with ChatGPT Codex Connector
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

vldb 2026 VLDB 2026 contributions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants