Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Heuristic:7onez Cti expert Context Budget Truncation

From Leeroopedia
Knowledge Sources
Domains LLMs, Optimization, Debugging
Last Updated 2026-10-28 14:00 GMT

Overview

Tool output and transcript history are bounded by character budgets in `context_budget.json` — truncation is NEVER silent; every cut carries a visible marker stating what was dropped and where the full copy lives.

Description

The harness bounds how much of a tool's output, and how much of a conversation's accumulated history, may occupy the model's context window. Two separate leaks motivated this:

  • Tool results: A `pivot_extract` over a large cluster, a reverse-WHOIS with hundreds of domains, or an IntelX page can return hundreds of kilobytes of JSON as ONE text block. Without a cap, a single call could consume most of a phase's window and push the actual instructions out of it. The default cap is 12,000 characters; "large result" tools (collectors, reverse/expansion queries) get 40,000. The head fraction (70%) is kept from the start (JSON leads with `meta` the model needs); the remainder from the end (closing summary/tail of a list). A minimum tail (800 chars) prevents collapse.
  • Transcript: The OpenAI-compat backend appends every message per turn with no trimming — a long collect grows the request until the provider rejects it. The ceiling is 360,000 characters; the oldest tool-call rounds are elided first, keeping the 6 most-recent rounds and never eliding the system prompt or original task message.

The critical rule: truncation is never silent. Every cut carries a visible marker stating the original size, what was dropped, and where the full copy lives — because a quietly shortened result is indistinguishable from a tool that found less, and "found less" is how a false negative enters a case.

Usage

Use this heuristic when:

  • Tuning tool output caps: Raise `large_chars` for a tool whose evidence is being cut in a way that loses findings. Add a tool to `large_result_tools` when its payload IS the evidence. Do NOT add read-only status tools — their useful output is a few hundred characters and their long tail is noise.
  • Tuning transcript budget: Set `max_total_chars` to the context window of whichever model `HARNESS_BACKEND` points at. The default (360,000) is sized for a 128k-token window at ~4 chars/token with room for the reply.
  • Debugging false negatives: If the model missed findings that the tool actually returned, check whether the result was truncated. The truncation marker tells you what was dropped and where the full copy lives.

The Insight (Rule of Thumb)

  • Action: Tune `result_budget` and `transcript_budget` in `context_budget.json`.
  • Value: `default_chars=12000`, `large_chars=40000`, `head_fraction=0.7`, `min_tail_chars=800`. `transcript_budget`: `max_total_chars=360000`, `keep_recent_rounds=6`.
  • Trade-off: Raising caps → more evidence in context but higher cost and slower processing. Lowering caps → cheaper but risk of truncated findings.
  • NEVER make truncation silent: The visible marker is the difference between "the tool found less" (a false negative) and "the tool found more but it was cut" (a known limitation). Always preserve the marker.

Reasoning

A tool that returns 500KB of JSON in one text block can consume an entire phase's context window, pushing the system prompt and task instructions out of what the model can see — the model then starts confidently answering a different question. The head/tail split preserves the JSON `meta` block (host, status, capability, collection time) that the model needs to reason at all, and the closing summary. The transcript budget prevents the OpenAI-compat backend (which has no automatic context handling, unlike the Anthropic SDK) from growing the request until the provider rejects it with a mysterious API error. The never-silent rule ensures the model knows it is seeing a truncated result and can ask for more or reference the full copy on disk.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment