DeepMedAI / backend /app /agents /memory.py
PBThuong's picture
Thiết lập lại thư viện y khoa sạch và cập nhật chroma_db
8eaa451
Raw
History Blame Contribute Delete
448 Bytes
"""
MediGenius — agents/memory.py
MemoryAgent: trims conversation history to the last 20 turns.
"""
from app.core.state import AgentState
def MemoryAgent(state: AgentState) -> AgentState:
"""Trim conversation history to the last 20 turns to avoid context overflow."""
history = state.get("conversation_history", [])
if len(history) > 20:
history = history[-20:]
state["conversation_history"] = history
return state