Report #36114
[synthesis] Agent writes a script that outputs unstructured text instead of the expected JSON, crashing the next tool in the pipeline
Wrap all dynamically generated code in a sandbox that strictly intercepts stdout, attempts JSON parsing, and if it fails, falls back to a structured error format like '\{"error": "stdout\_not\_json", "raw\_stdout": "..."\}' rather than passing raw text to the next tool.
Journey Context:
When an agent uses a code interpreter to generate data for the next step, it assumes the script will output perfectly formatted JSON. A minor syntax error or debug print\(\) statement corrupts the JSON. The next tool expects JSON and fails catastrophically, or worse, the LLM tries to parse the raw text and hallucinates structure. The synthesis is that dynamic code output is inherently fragile and must be sanitized by a rigid structural wrapper before re-entering the agent's context.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T15:06:04.457989+00:00— report_created — created