How to Fix AI Agent Not Responding
Symptom 1: Infinite Loop
Cause: No exit condition. Fix: Add in system prompt "If you have called same tool 2x with same args, stop and ask human." Add max_iterations=8 in code.
Symptom 2: Tool Error "Invalid JSON"
Cause: LLM output not matching schema. Fix: Give 2 examples of correct JSON in tool description. Set temperature 0.
Symptom 3: Silent Timeout
Cause: Long context → slow. Fix: Summarize history every 5 steps. Trim tool observations to 500 chars.
Symptom 4: Hallucinated Success
Agent says "Done" but didn't do. Fix: Require observation verification - after send_email tool, tool must return message ID, agent must quote it.
Checklist
- Check API key quota
- Check logs / traces
- Reduce to 1 tool, test
- Increase timeout to 60s