File size: 448 Bytes
8eaa451
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
"""
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