T02 · Agent Memory Poisoning
- Location
scripts/mem_curate.py:82- Finding
Untrusted Transcript Content Can Poison Permanent Agent Memory
- Content
View full analysis
list[dict]: """Send transcript to LLM curator and get back gems.""" system_prompt = load_curator_prompt() user_prompt = f"""Here is the full conversation transcript for {date_str}. Read it holistically and extract the valuable gems worth remembering long-term. TRANSCRIPT: {transcript[:30000]} Return ONLY a JSON array of gems. No other text.""" try: resp = requests.post( f"{OLLAMA_HOST}/api/chat", json={ "model": CURATOR_MODEL, "messages": [ {"role": "system", "content": system_prompt}, {"role": "user", "content": user_prompt}, ], "stream": False, "options": { "temperature": 0.3, "num_predict": 4096, }, }, timeout=300, ) ``` The generated data is subsequently accepted and stored: ```python gems = json.loads(content) if not isinstance(gems, list): print(f" ⚠️ LLM returned non-list: {type(gems)}", file=sys.stderr) return [] return gems ``` ```python point = PointStruct( id=str(uuid.uuid4()), vector=vector, payload={ "gem": gem_text, "context": context, "date": gem.get("date", date_str), "timestamp": ts_float, "categories": gem.get("categories", []), "project": gem.get("project"), "people": gem.get("people", []), "importance": gem.get("importance", "medium"), "confidence": gem.get("confidence", 0.8), "content_hash": content_hash(gem_text), "curated_at": datetime.now(t ...[truncated 2304 chars]- Remediation
View remediation
