-
-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
Objective
Use LangChain memory modules for cross-tool session persistence.
Repository
https://github.com/langchain-ai/langchain
Effort
3 days
Implementation
Constitutional Memory Class
from langchain.memory import ConversationBufferMemory
class ConstitutionalMemory:
def __init__(self, session_id: str):
self.memory = ConversationBufferMemory(
memory_key="session_state",
return_messages=True
)
async def add_stage(self, stage: str, result: dict):
"""Store stage results (111→222→333→...)"""
self.memory.save_context(
{"stage": stage},
{"result": result}
)
async def get_context(self) -> dict:
"""Retrieve full session context"""
return self.memory.load_memory_variables({})Tool Integration
@mcp.tool()
async def agi_sense(query: str, session_id: str) -> dict:
memory = ConstitutionalMemory(session_id)
result = await sense_logic(query)
await memory.add_stage("111_sense", result)
return resultSubtasks
- Install LangChain:
pip install langchain langchain-community - Create
codebase/memory/session.py - Implement ConstitutionalMemory class
- Integrate with all 9 MCP tools
- Add cross-tool state chaining
- Test session persistence
Acceptance Criteria
- Session state persists: init_gate → agi_sense → ... → vault_seal
- Each tool accesses prior stage outputs
- Memory survives restart (if [P0] Sprint 1.3: Fix T1.1 Ledger Persistence with Memory Server #166 done)
Files Changed
codebase/memory/session.py(new)- All tool files in
mcp_server/tools/*.py
Blockers
None (enhanced by #166)
Related
- Issue [P1] Sprint 2.2: Wrap 9 Tools for LangChain Ecosystem #168
- INTEGRATION_MASTERPLAN.md
Reactions are currently unavailable