Bugfix: Should the extraction LLM receive the enriched prompt or the...
Documentation for Sessions
🐛 Bugfix: Should the extraction LLM receive the enriched prompt or the...
Date: 2026-02-11
Time: 23:01:37 UTC
Session: gspace1-106.14
Agent: backend
Confidence: 98%
Status: ✅ Documented
📋 Decision Context
Question:
Should the extraction LLM receive the enriched prompt or the raw user message?
Task: Fix memory extraction reliability — extraction was getting polluted input
🎯 Decision Made
Chosen:
Raw user message only — frontends must send rawUserMessage field alongside enriched prompt
Options Considered:
- Send enriched prompt (contains system instructions + history)
- Send raw user message only
- Try to strip system prompt from enriched prompt on backend
💭 Reasoning
The enriched prompt contains 500+ tokens of system instructions, persona guidance, memory context, and conversation history — all prepended to the actual user message. When this entire blob is sent to the extraction LLM as 'the user message', the LLM can't reliably distinguish user-stated facts from system instructions. It frequently returned [] because the signal-to-noise ratio was too low. The fix: a new rawUserMessage field in the HTTP request carries the clean user input. The controller passes this to ChatService, which uses it exclusively for extraction. This is a simple, reliable solution that doesn't require prompt parsing on the backend.
📁 Files Involved
apis/backend-ai-api/src/app/chat/chat.service.tsapis/backend-ai-api/src/app/chat/chat.controller.ts
🔗 Related
- Decision ID:
dev_1770850897680_gwu5yea - Session: 106
- Workspace: gspace1
Auto-generated by MCP Smart Consolidation