Lion Cipher Lab

Measure lost-in-the-middle recall for an evidence-reading agent, then fix it by reordering

Why it matters

An incident-triage agent is handed a long evidence bundle - hundreds of log lines - and asked to find the one that matters: a single malicious IOC, a C2 beacon to a specific IP, a suspicious parent-child process. Liu and colleagues showed in 2023 that a long-context reader does not weigh every line equally: it recalls a fact at the START or END of its context far better than one in the MIDDLE, a U-shaped curve. So the fact can be sitting right there in the context and the agent still misses it - not a retrieval failure, an attention failure. This lab builds a deterministic stub whose recall…

What you'll learn

Steps in this lab

  1. The words first: long context, recall, a needle in a haystack, the U-shaped lost-middle curve, salience, reorder, chunk and rerank - and the fact that the reader here is a stub
  2. Where this sits: three neighbouring AI-agent labs, and what only this one measures
  3. Open a terminal and make a scratch folder (Windows, macOS, Linux)
  4. Write the stub reader: its whole positional-recall model, written down, and what context length does to the middle
  5. Measure the recall-by-position curve by sweeping the target across every position
  6. Apply and measure the two mitigations - and measure their honest negatives in the same run
  7. The honest negatives, stated plainly - why each fix has a catch you must design around
  8. When to reach for which fix, and how a pro treats a lost middle
  9. What you built, and the one sentence to keep

Open the full interactive lab →