LangGraph Detective: Does a Smaller Context Help?
- When
- November 2026
- Kind
- Side project
An AI detective solves mystery cases by reading clue files, and the project tests four ways of managing what goes into its prompt. After about 340 runs on five models, the simplest method, one prompt, was the most accurate and the cheapest.
Problem
Long agent runs fill the context window, so the usual fix is a memory harness that swaps what was read for notes. It is not clear that this helps, and it adds code, calls and cost, so the question was worth measuring instead of assuming.
Highlights
- Four methods compared on the same cases: a memory harness, a context-budget harness, a plain chat that keeps everything, and one prompt with the whole case.
- Six cases from 3.4K to 13.9K tokens, each blind-solved by a separate agent before use, with distractor documents checked so they cannot reveal the culprit alone.
- Ran on local Qwen 3.5 9B with Ollama, then 332 cloud runs across four OpenRouter models, each pinned to one provider. Total cloud spend was $4.22.
- One prompt matched or beat the memory harness on accuracy for every model, at 7x to 20x lower cost. The harness cut the peak prompt by 40 to 50% but read 7x to 18x more tokens in total.
- Rules the model cannot break live in code: file reads are limited to the case folder, so the agent can never open the solution, and a cost cap and reply caps stop runaway runs.
- Findings are written up honestly, including what was not done: the tight-budget sweep failed because the last compression step was never built, so that conclusion is an inference, not a measurement.
- 94 tests with fake models, and a LangGraph concept map that points each idea to the line where it lives.
7x to 20x cheaperOne prompt matched or beat the memory harness on accuracy for every model tested.
Stack
Architecture
Screens




What I learned
- Do not summarize, select. When material does not fit, pick the specific parts a task needs and give them in full, original form.
- Do not optimize for the wrong thing. Measure the real constraint first: here it was accuracy and cost, not prompt size.
- Put anything that must be exact in code, not in a prompt: file access, budgets, formats and scoring.