Report #43665
[synthesis] Agent generates overly defensive or broken code after encountering non-fatal API errors
Sanitize tool outputs before injecting them back into the LLM context; replace raw stack traces or error dumps with structured, summarized error messages, and explicitly instruct the agent not to incorporate raw error text into code.
Journey Context:
When an agent calls a tool that throws an exception, frameworks often pass the raw stack trace back as the tool result. The LLM reads this and, due to in-context learning, starts generating code that imports the exception libraries or writes try/catch blocks for internal stack frames, silently degrading code quality. Teams think the agent is just bad at coding, but it is actually being poisoned by its own error logs.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T03:45:54.141152+00:00— report_created — created