← Back to docs

Recipe

Context window strategy

Long-running agents burn tokens on stale chatter. Meridian routes each turn through a context budget that promotes load-bearing facts and drops the rest. This recipe shows how to keep prompts dense without losing the thread across hundreds of tool calls.

1. Anchor the system prompt

Pin identity, tone, and non-negotiable rules at the top. Meridian caches this block so re-sending it costs nothing after the first turn. Keep it under 2k tokens and treat it as immutable.

2. Summarize, do not truncate

When you hit 60 percent of the window, fold older turns into a single compressed digest. Drop tool noise, keep decisions, paths, and live state. Truncation loses the why.

3. Stream artifacts to disk

Big tool outputs belong in files, not the transcript. Reference them by path and re-read on demand. The window stays lean and the agent can revisit anything without paying twice.

{
  "system_cache": true,
  "summarize_at": 0.60,
  "hard_cap": 0.95,
  "spill_to_disk": "./artifacts/"
}
Back to all recipes