- System prompt 0
- Conversation history 0
- Your prompt 0
- Retrieved documents (RAG) 0
Assembling the context
What happens. The request is assembled: the history (or its summary, if it no longer fits), the documents the RAG retrieves and your prompt, in a fixed order. A prefix that does not change between requests can be cached and costs less.
What can go wrong. A retrieved document can carry a hidden order: that is indirect injection. Compacting the history can lose one of your instructions. And a change at the start of the request breaks the cache.
In depth:/embeddings/llm-costs/context-forge
The journey stops at “AI gateway”.
Everything the detectors found was seen by some layer.