Skip to content

Implement PowerMem LangChain middleware for VLDB 2026 scoring. - #1182

Closed
WeiJinMei0 wants to merge 1 commit into
oceanbase:vldb_2026from
WeiJinMei0:vldb_2026
Closed

WeiJinMei0 wants to merge 1 commit into
oceanbase:vldb_2026from
WeiJinMei0:vldb_2026

Conversation

@WeiJinMei0

Copy link
Copy Markdown

Summary

Implement PowerMemMiddleware for the powermem-langchain package, enabling LangChain v1 agents to use PowerMem as a long-term memory layer.

The middleware retrieves relevant user memories before model invocation, injects them into the model-visible context, and optionally persists the completed user-assistant interaction after the agent run.

Solution Description

  • Implemented synchronous and asynchronous PowerMem retrieval through the LangChain middleware lifecycle.
  • Uses the latest user message as the PowerMem search query.
  • Uses the explicit user_id constructor argument as the memory identity.
  • Respects the configured search_limit.
  • Stores retrieved memories in middleware state and injects them into the model system prompt through wrap_model_call and awrap_model_call.
  • Normalizes different PowerMem search-result formats and supports both plain-text and structured message content.
  • Persists the latest user message and assistant response through after_agent and aafter_agent.
  • Skips interaction persistence when save_interactions=False.
  • Uses non-inference write-back so the complete user-assistant interaction is stored reliably.
  • Handles PowerMem search and write-back failures in a fail-open manner, allowing the agent result to remain available.
  • Validates that an explicit user_id is provided and that search_limit is valid.
  • Updated the package documentation to describe the completed middleware behavior and usage.

The existing package test suite passes without modifying the provided test files:
6 passed

@CLAassistant

CLAassistant commented Jul 15, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@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 16, 2026
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