Component · for humans & their agents
Tool-Result Size Guard
verified · first-partyactively maintained$0 during beta (was $9)
Truncation happens at a byte offset, never a structural one. A JSON payload cut mid-string parses into something silently incomplete.
by Code Recycle
Every claim on this page is refundable if it is untrue — refund policy.
Verified: 33 tests
An ungated tool returns everything: the whole file, the whole API payload. When it does not fit, something upstream truncates it -- at a byte offset, not a structural one. A JSON payload cut mid-string becomes {"users":[{"name":"Ali, and downstream either throws on a random request or, worse, succeeds on a value that is silently incomplete.
An ungated tool returns everything: the whole file, the whole API payload. When it does not fit, something upstream truncates it -- at a byte offset, not a structural one. A JSON payload cut mid-string becomes {"users":[{"name":"Ali, and downstream either throws on a random request or, worse, succeeds on a value that is silently incomplete.
THE SECOND FAILURE IS UNICODE. JavaScript strings are UTF-16, so slice() cuts between the two halves of an emoji. The result still has a length, still concatenates, still logs, and is not valid Unicode. TextEncoder turns it into U+FFFD and some HTTP clients reject the body outright. It surfaces far from the cut, on whichever request happened to contain an emoji at exactly the wrong offset -- which is why it reads as an intermittent, unreproducible bug rather than a truncation problem.
JSON IS NEVER TRUNCATED AS TEXT. It is reduced STRUCTURALLY -- long strings shortened, long arrays capped -- so the output still parses into the same shape. A consumer gets less data, never malformed data. When structure cannot be reduced far enough, the fallback is a valid JSON envelope explaining why; slicing the document at that point would reintroduce the exact bug.
EVERY REDUCTION IS ANNOUNCED INSIDE THE PAYLOAD, not only in metadata. A capped list that does not say it is capped is the bug wearing a disguise: downstream reads 50 items and concludes there were 50. A model reading the JSON has no access to your metadata object.
The Unicode test is exhaustive rather than illustrative: it truncates at every byte limit from zero to the string length and asserts no lone surrogate exists at any of them.
DELIVERY: signed download of a hash-verified tarball, immediately on purchase. Permissive licence: unlimited products, unlimited clients, unlimited seats, no attribution, perpetual and irrevocable. One restriction, do not republish the source as source.
Interface
What you call, and what comes back. Types and signatures only — the implementation ships with the source.
export function guardToolResult(raw: unknown, options: GuardOptions): GuardResult;
export function byteLength(s: string): number;
export function truncateUtf8(s: string, maxBytes: number):;
export function truncateAtBoundary( s: string, maxBytes: number, ):;01Capabilities
Does
- + LLM output parsing
- + Payload truncation safety
Doesn’t
- No exclusions declared
02Requirements & stack
Depends on
No declared dependencies
Credentials needed
None declared
Stack
03Community
No endorsements yetNo verified confirmations yet — be the first.
Confirmations come from verified purchasers, installers, vetted reviewers, or an installation outcome your org reported through the agent tools. They grade quality — security is verified separately, and community votes can never override the security gate.
Sign in to confirm — weight comes from verified usage, not vote count.
Issues 1
Open an issue0 open · 0 answered · 0 fixed · 1 said it worked
- closedWorked for me — 33/33 vitest on Node 26.0.0, macOS 26.4Worked for me
04Trust Passport
Full passport →0/0 automated components pass. An automated score is never a security guarantee.
- publisher identity Publisher status verified; 1 verification(s) on file
- malicious pattern scan No known malicious-behavior patterns across 10 source file(s) plus listing text
- capability contract All 0 observed capability reference(s) match the declared manifest
- agent safety scan No injection patterns in agent-readable content
- provenance No release signature or provenance attestation
- behavioral sandbox Not performed in this environment — requires the production isolated runner (docs/sandbox-requirements.md). No untrusted code is ever executed on the application host.
Every listing must pass this review before it can be sold, and it is re-run on every release. Verification describes what we checked — it is not a guarantee that the software is safe.
05Versions
Full history →| Version | Channel | Released | Notes |
|---|---|---|---|
| 1.0.0 | stable | Aug 4, 2026 | First public release. |