Skip to content

feat(adapters): add LangChain memory middleware#466

Draft
March-77 wants to merge 4 commits into
TencentCloud:mainfrom
March-77:feat/235-langchain-memory-middleware
Draft

feat(adapters): add LangChain memory middleware#466
March-77 wants to merge 4 commits into
TencentCloud:mainfrom
March-77:feat/235-langchain-memory-middleware

Conversation

@March-77

Copy link
Copy Markdown

Description | 描述

Adds a focused LangChain v1 / LangGraph middleware adapter on top of the shared Gateway adapter kit from #316.

  • maps beforeAgent to Gateway /recall
  • maps afterAgent to Gateway /capture
  • resolves a stable LangGraph thread/session identity through host runtime context
  • normalizes LangChain BaseMessage values to JSON-safe { role, content } messages
  • fails open by default when the Gateway is unavailable, with an opt-in fail-closed mode
  • adds focused unit tests and a Mermaid data-flow/usage guide
  • does not add LangChain as a core dependency; the host injects its installed createMiddleware

Related Issue | 关联 Issue

Related to #235
Depends on #316

Change Type | 修改类型

  • Bug fix | Bug 修复
  • New feature | 新功能
  • Documentation update | 文档更新
  • Code optimization | 代码优化

Self-test Checklist | 自测清单

  • Verified locally | 本地验证通过
  • No existing features affected | 无影响现有功能

Verification:

  • npm.cmd exec vitest run src/adapters/langchain/langchain.test.ts src/adapters/gateway-client/gateway-client.test.ts: 8 passed
  • npm.cmd test: 75 passed
  • npm.cmd run build:plugin: passed
  • git diff --check: passed

Additional Notes | 其他说明

This is intentionally a small platform-specific follow-up. It reuses #316 instead of introducing another Gateway client or adapter SDK. The PR is opened as draft while #316 is pending; once #316 lands, this branch can be rebased so the review diff contains only the LangChain middleware commit.

RerankerGuo and others added 4 commits June 30, 2026 20:40
Signed-off-by: Ziyang Guo <121015044+RerankerGuo@users.noreply.github.com>
Signed-off-by: Ziyang Guo <121015044+RerankerGuo@users.noreply.github.com>
Signed-off-by: Ziyang Guo <121015044+RerankerGuo@users.noreply.github.com>
Signed-off-by: zhangzherui <jerry_@whut.edu.cn>
@Maxwell-Code07

Copy link
Copy Markdown
Collaborator

Thank you for submitting this PR and participating in Tencent Rhino-bird Open-source Training Program!
We have successfully received your submission. The program is currently in full swing, and we will complete the Code Review for you as soon as possible. Please keep an eye on the status notifications for this PR so you can follow up promptly once the review feedback is provided.
Thanks again for your contribution and open-source spirit! 🚀

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.

3 participants