RAG retrieves facts, not state. Why I’m experimenting with "State Injection" for coding.
gist.github.com·16h·
Discuss: r/programming
📋MCP
Preview
Report Post

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…

Similar Posts

Loading similar posts...