Lion Cipher Lab

Build a subagent harness from scratch — context isolation, per-child tool allowlists and result contracts — then measure what a 50-file security code review costs with and without it

Why it matters

Ask an AI agent to security-review a fifty-file service and something quietly awful happens. It reads file one, file two, file three, and somewhere around file eighteen its CONTEXT WINDOW — the fixed amount of text it can hold at once — is full. Everything after that is truncated away. The agent does not tell you. It does not error. It writes you a confident report about the whole repository having read a third of it, and the report is short because it also got worse at noticing things as its window filled. In the measured run below, a single agent given all fifty files found 3 of the 29…

What you'll learn

Steps in this lab

  1. The words first: subagent, context window, token, isolation, allowlist, result contract
  2. Open a terminal and make a scratch folder (all three operating systems)
  3. Generate the review target: 50 files with defects whose locations you already know
  4. The context ledger: double-entry bookkeeping for tokens
  5. The reviewer is a DETERMINISTIC STUB — read this before you paste it
  6. The scorer: recall, precision and F1 against the planted truth
  7. The baseline: one agent, one window, fifty files — and it finds 3 of 29
  8. Build the harness: a constructed brief, an enforced allowlist, a declared contract
  9. Run the delegated review: 7.3x less peak context, 1.62x more tokens, and say both
  10. What LEAKS if you get isolation wrong — four returns, one job, measured
  11. Find the crossover: below ten files your harness is pure overhead
  12. The findings isolation destroys — and a partial fix that stays partial
  13. When NOT to use a subagent — and why this, not that
  14. The way a pro does it
  15. OPTIONAL appendix: swap the stub for a real local model

Open the full interactive lab →