- Version
0.1.0 - Purity pure zero-dep (browser-safe; no workspace or external deps, no
node:*) - Purpose Cut verbose tool output before it re-enters an agent’s context, with two guarantees: pass-through-safe (tiny inputs / low-savings return untouched) and failure-preserving (an error line in the input is guaranteed to survive into the output).
- Workspace deps none
- External deps none
tool-result and context insertion. The whole package is pure string transforms, no process spawning, no I/O. The single . entry point has no subpath exports. UTF-8 byte length is measured via the global TextEncoder (Node 22+/browsers).
The two invariants in code: compactToolOutput returns the original (with applied: false) when the input is below minBytes (default 512), when the compaction would drop a failure line, or when savings fall below minSavings (default 0.05). Every call returns stats so a bad rule is auditable.
Public API
Functions
Types & interfaces
Classes
None; this package exports only functions, types, and constants.Constants
Failure-preserving is enforced at the package boundary, not by trusting each rule. After a rule transforms the output,
compactToolOutput re-runs failureLines over the original and falls back to the untouched input (failure-preserve-fallback) if any failure line did not survive as a substring. A buggy overlay rule cannot silently swallow an error.Used by
@clawboo/db;tools/broker.tsrunscompactToolOutput(call.name, raw).textover a brokered tool call’s result (unlessopts.compact === false), so the broker pipeline compacts tool output before it returns.apps/web(server);lib/executorRunner.tspassescompactToolResultMarkdown(text).textas the runner’scompactdep, applied to a child’s report-up summary before it becomes a board comment /[Task Update].apps/web(server);lib/teamChat/teamOrchestrator.tswirescompactToolResultMarkdown(text).textas the server-side team orchestrator’scompactdep.
Source
Barrel:packages/compaction/src/index.ts (re-exports ./compact, ./rules, and the ./types types).
See also
@clawboo/db, the tool broker that compacts brokered results@clawboo/executor, theRuntimeEventtool-resultthis sits behind- Observability concepts
- Package overview