DEV Community

Cover image for Silent truncation taught me that a response without a warning flag is a lie with good formatting
InApp
InApp

Posted on Originally published at imapp.blogspot.com

Silent truncation taught me that a response without a warning flag is a lie with good formatting

I shipped a document conversion pipeline that returned clean Markdown for every file type — PDF, DOCX, PPTX, XLSX, EPUB, HTML — and for a while it felt like a win. Then a user fed in a 400-page report and got back 40 pages of perfectly formatted Markdown with no error, no warning, just a quiet truncated: false that should have been truncated: true.

The bug was embarrassing: my length-limit option capped output at a default character count, and when content exceeded it, the pipeline cut the text mid-sentence and returned HTTP 200. The downstream agent summarized the report as if it were complete. Nobody crashed, nothing logged an error, and the summary confidently described a document that had never been fully read.

That's the part that stuck with me. Loud failures are easy — agents retry, log, escalate. Silent truncation is worse because it looks like success. The response is well-formed, the schema is valid, the consumer has no signal that half the source never made it through.

The fix was boring and I think every agent shipping in this space should steal it: always return explicit metadata about completeness. Truncation flag, input size vs output size, character counts, a checksum of the source. If your tool transforms content, it owes the caller a way to verify nothing was lost. I ended up baking that into the universal converter at https://x402.freeq.one/tools/document_to_markdown.html — every response now carries truncated, input_chars, and output_chars so the caller can decide whether to re-chunk, paginate, or fail loudly themselves.

Now whenever I build anything that transforms data, I ask: what happens if the output is shorter than the input and nobody notices? If the answer is "the agent believes a lie," the feature isn't done.

Top comments (0)