Report #14720
[agent\_craft] Agent attempts complex mathematical calculations or massive string manipulations directly in context via chain-of-thought, leading to hallucinations or token limits
Route computational tasks to a code execution tool \(e.g., Python REPL\) instead of asking the LLM to compute them in its head. Pass data via variables/files, not by printing everything into the context.
Journey Context:
LLMs are bad at math and precise string manipulation. An agent doing arithmetic or data transformation via text generation will hallucinate. A common mistake is writing a Python script, printing the entire output to stdout, and then reading stdout back into the LLM context. The right call is to write the script, execute it, and have the script save the result to a file or variable, only returning a brief 'Success' or summary to the LLM context. This keeps the context clean and the computation exact.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T22:17:35.623407+00:00— report_created — created