ai_agent_memory
No security coverage
Overview
The default AI module's AgentRunner deletes agent state when an agent finishes a turn. This means every new user message starts a completely fresh agent run — the LLM has no memory of previous tool calls, tool results, or reasoning from earlier in the conversation.
AI Agent Memory fixes this by decorating the AgentRunner to persist agent state across conversation turns in a separate temp store bin. Agents retain full awareness of their previous actions within a chat session, enabling coherent multi-turn workflows where each step builds on the last.
Features
- Cross-turn agent continuity — Agent state persists after completion so the next user message resumes with full context, not a blank slate.
- Turn-aware history trimming — Keeps the context window bounded by dropping middle turns while preserving the first turn (initial context) and recent turns. Never splits tool call/result pairs.
- Configurable per-agent opt-in — Only agents listed in the module's settings get persistent state. All others pass through to the default
AgentRunnerunchanged. - Stale data detection — Automatically discards persisted state when the agent has finished and no new messages have arrived, preventing replay of outdated context.
- File binary stripping — Removes binary file data from chat messages before persistence, working around a serialization issue in the upstream
ChatMessageclass.
Requirements
- AI module (ai_agents and ai_assistant_api sub-modules)
Configuration
- Install the module.
- Navigate to
/admin/config/ai/agent-memory. - Select which agents should have persistent state.
- Optionally adjust history trimming settings (max messages, recent turns to keep).