feat(integrations): Add LangGraph Adapter for MemU (Track A)#258
Merged
ankaisen merged 7 commits intoNevaMind-AI:mainfrom Jan 20, 2026
Merged
feat(integrations): Add LangGraph Adapter for MemU (Track A)#258ankaisen merged 7 commits intoNevaMind-AI:mainfrom
ankaisen merged 7 commits intoNevaMind-AI:mainfrom
Conversation
Includes robust example script handling API key errors and a step-by-step markdown tutorial. Fixes NevaMind-AI#227.
Implements adapter pattern for LangGraph integration satisfying Track A requirements. - Added MemULangGraphTools adapter with strict type checking - Added cyclomatic-complexity compliant demo in examples/ - Added isolated integration tests using AsyncMock - Fixed CI dependency detection (DEP002) for langgraph
ankaisen
approved these changes
Jan 20, 2026
Collaborator
ankaisen
left a comment
There was a problem hiding this comment.
@david-mamani Thank you! LGTM 👍
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hackathon Submission: Track A - Agent Framework Plugins (#2026NewYearChallenge)
Executive Summary
This Pull Request introduces a production-grade integration between MemU and LangGraph, fulfilling the requirements for Track A. It provides a standardized interface for LangGraph agents to interact with MemU's persistent memory layer without requiring direct service instantiation within the agent loop. Additionally, this PR addresses architectural complexity in the example implementations and introduces a robust testing suite using mock strategies.
Technical Summary of Changes
1. Adapter Pattern Implementation (
src/memu/integrations/langgraph.py)MemULangGraphToolsclass. This adapts the internalMemoryServiceinterface into LangChain-compatibleStructuredToolobjects, aligning with the target framework's conventions.SaveRecallInputandSearchRecallInput) to strictly define the schema for tool arguments. This ensures that the LLM's structured output is validated against a rigorous type contract.StructuredTool.from_functionto bridge the synchronous tool definition API with MemU's asynchronous core.2. Cyclomatic Complexity Refactoring (
examples/langgraph_demo.py)run_demofunction was decomposed into single-responsibility units (initialize_infrastructure,process_conversation,process_retrieval), ensuring C901 compliance.run_demoto a high-level orchestrator, significantly improving readability and maintainability.3. Isolated Integration Testing (
tests/integrations/test_langgraph.py)unittest.mock.AsyncMockto mock asynchronous methods ofMemoryService. This allows strict verification of integration logic without requiring a running database.4. Resilient Error Handling (
src/memu/integrations/langgraph.py)try/exceptblocks. Tools return descriptive error strings instead of raising exceptions, allowing the Agent to self-correct and improving stability.finallyclauses to ensure temporary files are deleted, preventing storage leaks.5. Dependency Management & Usability
langgraph,langchain-openai) viauvfor reproducible builds.uv synccommand needed, directly addressing usability criteria.🛠️ How to Verify (Usability & Testing)
To validate this submission locally as per the "Runnable outcome" requirement:
Install Dependencies:
uv sync --all-extras
Run the integration tests:
uv run pytest tests/integrations/test_langgraph.py -v
Run the Demo
Requires OPENAI_API_KEY env var
uv run python examples/langgraph_demo.py