Silent Truncation: The Agent Bug Where Half the Data Looks Like All of It

Some of the worst agent failures never raise an error. The command ran. The API answered. The agent wrote a confident summary. And the summary was built from the first 30 percent of the data, because something in the pipeline quietly cut the rest off.

This is silent truncation, and if you run unattended automations, you almost certainly have it somewhere right now.

Where truncation hides

Truncation is rarely one big, obvious limit. It is a stack of small ones, each reasonable on its own:

  • Shell output caps. Many agent harnesses clip stdout at a fixed number of bytes or lines. A grep that should return 400 matches returns 200 and a polite ellipsis.
  • API page sizes. A list endpoint returns 50 items by default. The agent reads the first page, sees a tidy JSON array, and never learns there was a next cursor.
  • Row limits in database queries. A LIMIT 100 added “for safety” months ago now silently defines what “all customers” means.
  • Log tailing. tail -n 500 on a noisy day covers twenty minutes instead of twenty-four hours.
  • Context budgets. A file gets summarized or clipped before the model sees it, and the model has no idea a middle section vanished.
  • Response size limits on web fetches. A long page is cut at a byte boundary, sometimes mid-sentence, sometimes mid-table.

None of these are bugs. Each one is a sane default. The bug is that the agent treats the result as complete.

Why it is worse than a crash

A crash gets noticed. A truncated read produces a plausible answer, and plausible answers get acted on.

Some examples of what this looks like in practice:

  • A reporting agent says “no failed jobs overnight” because the failure lines sat past the clipped region of the log.
  • A cleanup agent lists “all stale branches” from a capped result and deletes the visible ones, then reports the repo as clean.
  • A lead-sorting agent scores the first page of a CRM export and ignores the other three, so the pipeline report undercounts by 75 percent.
  • A research agent reads the top of a long document, misses the caveat in the final section, and cites the claim without it.

In every case the output is well formed. Nothing downstream can tell it came from partial input, which is exactly what makes it dangerous.

Rule one: every read declares its own completeness

The core fix is a contract, not a clever prompt. Any tool the agent uses to read data should return two things: the data, and a completeness statement.

A minimal completeness statement looks like this:

returned: 200
total: 412
complete: false
reason: output_cap_200_lines

If the tool cannot know the total, it should say so explicitly: total: unknown, complete: unknown. Unknown is an honest state. “Looks fine” is not.

You can build this with thin wrappers. A wrapper around your log reader that appends a footer with line count and the time range actually covered takes about ten lines of shell. A wrapper around a paginated API that loops until the cursor is empty, and fails loudly if it hits a page ceiling, takes a few more. The effort is small compared to one wrong overnight report.

Rule two: make the cap visible in the result, not the config

Teams often “document” limits in a config file or a README. The agent never reads those at decision time. What the agent sees is the output in front of it.

So put the evidence in the output. Good patterns:

  • A trailing line such as [truncated: showing 200 of 412 lines] that is hard to miss and easy to grep for.
  • A first-line header with the covered range: covers 2026-11-01 22:14 to 2026-11-02 06:00.
  • Exit codes. Return a distinct non-zero code for “partial result” so a script can branch on it without parsing text.

The goal is that a downstream step, whether a model or a plain if, can detect partial input mechanically.

Rule three: a partial read cannot support a negative claim

This is the single most useful policy to write into your agent’s instructions, and it is cheap to enforce.

Positive claims can survive partial data. “I found three failures” is true even if there were ten. Negative and universal claims cannot. “No failures,” “nothing stale,” “all customers processed,” and “the document does not mention X” all require full coverage.

Write it as a rule: if any input to a report was flagged incomplete, the report may not make a claim of absence or totality. It must instead say what range it covered and what it could not see. This one rule would have prevented most of the examples above.

Rule four: count before you read

When you can, ask for the count first. A SELECT COUNT(*), a wc -l, an API call that returns only the total, a file size check before a read. Counts are cheap and rarely truncated.

Then compare. If the agent expected 412 rows and holds 200, the mismatch is the alarm. This turns an invisible failure into an ordinary assertion, the kind of check you already know how to write.

For recurring jobs, store yesterday’s count and flag big swings. A sudden drop from 400 to 200 is more likely a new cap than a real change in the business.

Rule five: fail the run, or split the work

When truncation is detected, you have two honest options.

Fail loudly. Stop the run, record the reason, and let the failure alert do its job. This is right when the result must be complete, like a deletion list or a financial total.

Chunk it. Split the read into windows the tools can handle: one hour of logs at a time, one page at a time, one directory at a time. Process each, merge the results, and verify the chunk counts add up to the declared total. This is right when the job is large but safe to do in pieces.

What you should never do is continue with a partial read and a clean-sounding report. That path combines the cost of an incomplete answer with the false confidence of a complete one.

A quick audit you can run this week

Pick your three most important unattended jobs and ask, for each tool call they make:

  1. What is the largest result this call can return before something clips it?
  2. Does the output say when it hit that ceiling?
  3. Could the agent make a “nothing found” claim from this call?
  4. Does the job compare what it read to a known total?

If the answers are “I do not know,” “no,” “yes,” and “no,” you have found your silent truncation risk. Fix the highest-stakes one first, usually the job that deletes, spends, or reports to someone else.

Then add one test: feed the job an input that is deliberately larger than every cap. A log with ten thousand lines, a table with ten pages, a document with a buried caveat in the last paragraph. A healthy job fails loudly or chunks correctly. A job with silent truncation reports success, and now you know before your customer does.

The takeaway

Reliable agents are not the ones that never hit limits. Limits are a fact of life on small hardware, metered APIs, and finite context windows. Reliable agents are the ones that know when they hit one and say so.

Make completeness a first-class field. Ban absence claims on partial reads. Count before you read. And treat “I saw only part of it” as a result worth reporting, because it is far better than a clean report built on half the data.

More from the build log

Suggested

Want the full MarketMai stack?

Get the core MarketMai guides and operator playbooks in one premium bundle for $49.

View Bundle