1. Unparseable JSON
Models wrap JSON in friendly text or leave trailing commas. Extract the outermost braces and catch parse errors instead of crashing:
2. Unknown tool names
The model invents web_search when your tool is search. Look tools up in a dictionary and return an error message to the model instead of raising.
3. Infinite loops
No step cap means one confused model can burn your whole budget. Set max_steps (5–15 is typical) and stop cleanly.
4. Forgetting to feed results back
If tool output isn’t appended to history, the model repeats the same action forever. Log history length each step.
5. Context overflow
Long runs exceed the context window. Keep the last N steps and a short summary of earlier ones.
6. Wrong argument types
"3" vs 3, a list vs a string. Validate and coerce inputs before calling the tool.
7. Running model output as code
eval() on model output is a security hole. Sandbox it or use a parser. Our guide to sharing AI code safely covers more.
Fix it faster
Paste your agent into CoderFile, run it, and ask the AI assistant "why does this loop forever?" New to agents? Start with the 50-line tutorial or read about Dots, Muse and Grok Bot.