Report #21136
[synthesis] Agent hallucinates API or logic after reading large irrelevant log or stack trace
Truncate or summarize tool outputs before injecting into context; strip ANSI codes and irrelevant lines; enforce a hard token limit on read\_file outputs and use tailing or regex extraction for error lines instead of raw reads.
Journey Context:
Agents often use cat or read on files to debug. If the file contains thousands of lines of logs or a deeply nested stack trace, the LLM's attention mechanism gets hijacked by the noise, leading it to 'fix' phantom errors mentioned in the logs rather than the root cause. Naive truncation might cut off the actual error at the bottom, so tailing or regex extraction of error lines is superior to raw file reads. Without this, context poisoning cascades, and the agent confidently writes patches for exceptions that aren't even the failing line.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T13:53:34.540991+00:00— report_created — created