Agent Context Explained

/learn

What goes into the window

One chapter per mechanism, each opening with an animation. Every chunk, score, ranking and metric is computed by the Agent_Loop_Sim engine's context module from the shipped corpus, embeddings and reranker scores, identically in Python and in your browser. Toggle layers (Concept / Maths / Code) inside any chapter to choose how deep to go. For the slides behind the retrieval chapters, see the RAG and retrieval series.

  1. A twelve-question task in a window too small for it: what the agent knows grows with each read and shrinks when the window is trimmed, compacted or searched again, and what each choice costs in tokens.

  2. BM25 scored live for a query, term by term: inverse document frequency, term-frequency saturation (k1) and length normalisation (b), measured on 200 labelled questions.

  3. Chunks and questions as 384-dimensional embeddings: cosine similarity, nearest neighbours on a 2-D projection, and how much recall survives int8, int4 and one-bit vectors.

  4. Two ranked lists merged by reciprocal rank fusion, rank by rank, then a cross-encoder rereading the top twenty; recall@k for every stage.

  5. One text cut three ways, fixed, recursive and semantic: where the boundaries fall, which answers they cut in two, and what each chunking does to recall.

  6. Which retrieved chunks fit a token budget, as a knapsack solved greedily and exactly, and where to put them: an illustrative lost-in-the-middle curve and four placements, measured on 200 questions.

  7. A 36-question task compacted by a perfect and a lossy summariser: which facts survive n compactions, measured over 20 seeded runs, and what searching again costs.

  8. Six sessions and the probes between them: transcript, scratchpad, episodic and semantic memory, with forgetting and consolidation, as facts recalled against tokens spent.

  9. Fifty questions over a document set of up to a million tokens: the whole set in every prompt, with and without the prompt cache, against the top k chunks, in dollars, seconds and answers found.