ExAthena.Compactors.BudgetReduction (ExAthena v0.4.8)

Copy Markdown View Source

First stage of the compaction pipeline. Replaces oversized tool-result contents with a short reference pointer.

The pattern is from Claude Code's applyToolResultBudget: any tool result whose content exceeds :per_tool_result_max_chars (default 16_000 characters) is swapped for a placeholder describing the size and a stable reference id. The full payload moves to state.assigns[:tool_result_archive] so a future reload tool (PR2 ships only the archive plumbing; reload tooling is host-side) can restore it.

This stage is deterministic and cheap — no LLM calls, no message drops. It runs before Snip / Microcompact / ContextCollapse / Summary and often gets the conversation under target on its own when one outlier tool produced a giant response (think: a Read of a 100KB file or a Bash grep over a huge tree).