An agent loop accumulates tool results faster than any context window can hold them, so something has to be dropped. The usual approach — truncate the longest thing, or paraphrase — drops exactly what the next step needs: the reason a call failed, the order id it produced, and the fact that one call's outcome was never established at all.
This walkthrough uses the tool's public README and checked-in example files. Run the command from a repository checkout with Node.js 22+; inspect the source before using it on your own files.
Run the checked-in example
cat > results.json <<'JSON'
{
"schemaVersion": "1",
"results": [
{
"id": "call-0007",
"tool": "payments.refund",
"status": "failed",
"sections": [
{ "name": "error", "kind": "failure", "priority": 0,
"text": "Refund declined: acquirer code 51.",
"sourceHash": "sha256:9f2c1a4b7e0d3c5a", "pointer": "results/call-0007/error.txt" },
{ "name": "order", "kind": "identifier", "priority": 0, "text": "ord_9F2KQ4" },
{ "name": "retry", "kind": "next-action", "priority": 0,
"text": "Fund the source account, then retry with the same key." },
{ "name": "transcript", "kind": "evidence", "priority": 5,
"text": "REQUEST POST /v2/refunds ...",
"sourceHash": "sha256:deadbeefdeadbeef", "pointer": "results/call-0007/transcript.log" }
]
}
]
}
JSON
node bin/tool-result-compressor.mjs --results results.json --budget-chars 600
node bin/tool-result-compressor.mjs --results results.json --budget-chars 600 --jsonRead the result
A consumer that pipes stdout must handle an empty stdout on exit 2. That is documented rather than papered over: emitting a fake report for a run that never started would be worse.
Where this check stops
Every limit is enforced and every one has a CLI flag. Reaching one produces an incomplete report naming the limit — never a silent truncation and never a pass.
Before adapting the command to your own workflow, review the accepted inputs, exit codes and safety boundaries in the README.
Compiled with AI assistance from checked-in public documentation and example scripts. Run the example and review the repository's current documentation before relying on its result.