memory_load tool needs guardrails against bad LLM parameters
Title
memory_load tool allows LLM to pass non-existent area filters and overly restrictive thresholds, causing memory retrieval failures
Description
When using non-OpenAI models (tested with Qwen3-Coder via vLLM), the LLM frequently passes bad parameters to the memory_load tool, causing memory searches to return zero results even when relevant memories clearly exist in the FAISS index.
Problems Found
1. LLM invents area filter names that don't exist
The LLM consistently passes filters like area=='personal' or area=='credentials' or area=='user' — none of which are valid memory areas. Actual memories are stored in main, fragments, and solutions. Since memory_load.py passes the filter string directly to FAISS with no validation, these searches always return empty.
Example from logs:
Query: email address Gmail Google Workspace
Threshold: 0.7
Filter: area=='personal' or area=='credentials'
Result: "No memories found"
Meanwhile the Memory Dashboard shows 13 matching entries in area "main" for the same query.
2. LLM sets threshold too high
The default threshold in memory_load.py is 0.7, and the LLM consistently uses it or higher. With OpenAI embeddings (text-embedding-3-large), 0.7 is too restrictive for many semantic queries. A threshold of 0.3-0.5 produces much better recall without significant noise.
3. No behaviour default to check memory before responding
When asked personal questions like "what is my email?", models like Qwen immediately respond "I don't have access to personal information" without ever calling memory_load. The default behaviour prompt (agent.system.behaviour_default.md) doesn't instruct the agent to check memory first.
Suggested Fixes
-
Validate area filters in
memory_load.py— strip or ignore filter values that reference non-existent areas. Valid areas could be checked againstMemory.Areaenum values. -
Cap the threshold — add a floor/ceiling so the LLM can't set it above 0.5 or below 0.1 regardless of what it passes.
-
Add memory-first instruction to
agent.system.behaviour_default.md:- always search your memory first before responding to any user request
Environment
- Agent Zero: latest Docker image
- Chat model: Qwen3-Coder-Next-FP8 via vLLM (OpenAI-compatible)
- Embedding model: OpenAI text-embedding-3-large
- Also reproducible with local MiniLM embeddings
Workaround
Modified memory_load.py to cap threshold at 0.5 and strip invalid area filters:
class MemoryLoad(Tool):
async def execute(self, query="", threshold=DEFAULT_THRESHOLD, limit=DEFAULT_LIMIT, filter="", **kwargs):
db = await Memory.get(self.agent)
if threshold > 0.5:
threshold = DEFAULT_THRESHOLD
if filter and any(x in filter.lower() for x in ["personal", "user", "credentials", "private"]):
filter = ""
docs = await db.search_similarity_threshold(query=query, limit=limit, threshold=threshold, filter=filter)
...
Also created /a0/usr/memory/default/behaviour.md with instruction to always search memory before responding.
Closing due to inactivity of 90 days.