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:ARCANGEL0 EVA Tool Result Truncation

From Leeroopedia
Knowledge Sources
Domains Optimization, LLMs
Last Updated 2026-10-29 12:00 GMT

Overview

Truncate tool execution results to 40,000 characters and vulnerability search output to 18,000 characters to keep conversation history within LLM context limits.

Description

Mitsu enforces a maximum tool result size of 40,000 characters (`MAX_TOOL_RESULT`) for all tool dispatches through `AgentToolHost`. When a tool's output exceeds this limit, it is truncated before being added to the conversation history. Additionally, the vulnerability search pipeline caps its formatted output at 18,000 characters, and individual web search results are limited to 5,000 characters per query. Vulnx results are capped at 32,000 characters. These limits prevent a single large tool output (e.g., an nmap scan of a large network) from consuming the entire LLM context window.

Usage

Apply this heuristic to all tool dispatch results. The truncation is automatic in `AgentToolHost.call` — no configuration needed. The LLM receives a truncated result with enough context to understand the output, and can request more specific queries if needed.

The Insight (Rule of Thumb)

  • Action: Truncate tool results at `MAX_TOOL_RESULT = 40_000` characters.
  • Value: 40,000 chars for general tools, 18,000 for vulnerability search, 5,000 per web search query, 32,000 for Vulnx.
  • Trade-off: Large outputs are truncated and may lose detail, but conversation history stays manageable and the agent can re-query for specifics.
  • Compatibility: Applies to all tools and all agent modes.

Reasoning

A single tool output (e.g., full nmap scan, large file content, or a web page) can easily exceed 100KB. Injecting this into the conversation history would quickly exhaust the LLM's context window, leaving no room for the system prompt, prior conversation, or reasoning. The 40,000-character limit provides approximately 8,000-10,000 tokens of tool output per call, which is sufficient for the agent to understand the result and decide next steps. The agent can always run more targeted queries if it needs specific details from a truncated output.

Code Evidence

Tool result limit from `tools/agent_host.py:51`:

MAX_TOOL_RESULT = 40_000

Vulnerability search output limit from `search/vulnerabilities.py:311`:

return "\n".join(lines)[:18_000]

Per-query web result limit from `search/vulnerabilities.py:294`:

lines.extend((f"[{query}]", result[:5_000], ""))

Vulnx output limit from `search/vulnerabilities.py:204`:

return output[:32_000], None

Related Pages

Page Connections

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