I’ve found that RAG is great for documentation ("What is the syntax for X?"), but it fails hard at decision state ("Did we agree to use Factory or Singleton 3 turns ago?"). Even with 128k+ context windows, we hit the "Lost in the Middle" problem. The model effectively forgets negative constraints (e.g., "Don’t use Lodash") established at the start of the session, even if they are technically in the history token limit. Instead of stuffing the context or using vector search, I tried treating the LLM session like a State Machine. I run a small local model (Llama-3-8B) in the background to diff the conversation. It ignores the chit-chat and only extracts decisions and negative constraints. This compressed "State Key" gets injected into the System Prompt of every new…
I’ve found that RAG is great for documentation ("What is the syntax for X?"), but it fails hard at decision state ("Did we agree to use Factory or Singleton 3 turns ago?"). Even with 128k+ context windows, we hit the "Lost in the Middle" problem. The model effectively forgets negative constraints (e.g., "Don’t use Lodash") established at the start of the session, even if they are technically in the history token limit. Instead of stuffing the context or using vector search, I tried treating the LLM session like a State Machine. I run a small local model (Llama-3-8B) in the background to diff the conversation. It ignores the chit-chat and only extracts decisions and negative constraints. This compressed "State Key" gets injected into the System Prompt of every new request, bypassing the chat history entirely. System Prompt attention weight > Chat History attention weight. By forcing the "Rules" into the system slot, the instruction drift basically disappears. You are doubling your compute to run the background compression step. Has anyone else experimented with "State-based" memory architectures rather than vector-based RAG for code? I’m looking for standards on "Semantic Compression" that are more efficient than just asking an LLM to "summarize the diff."