Agent goes into infinite tool calling loop.
Hey everyone, I could really use some help with this issue I’ve been stuck on for the past few hours.
I’m building a simple agent that:
  1. Collects information from the user via chat
  2. Passes that information to a sub-agent, which updates a CRM (HubSpot in this case)
I decided to use a sub-agent approach because I plan to add more tools later, and I didn’t want the main prompt to become bloated. The idea was to keep things modular and dynamic.
The problem:Whenever I provide the last required detail, the sub-agent successfully calls the HubSpot tool and gets an “ok” response. At that point, I’d expect the agent to stop and return the confirmation message back to me in the chat.
Instead, it enters an infinite loop:
  • It keeps calling the same tool over and over, even though the first attempt already succeeded.
  • Eventually, it crashes with “agent stopped due to max iterations”.
  • Looking at the logs, I can see that the tool succeeds in the first iteration, and the main agent even produces a valid response that could have been returned to me—but instead, it just restarts the process and re-executes the tool.
Question: Has anyone else run into this looping behavior with sub-agents and tool calls? Is there a known fix or a pattern I should be following to make sure the agent stops after a successful call?
I’ve attached a snippet of the logs below for context. You can see the sub-agent succeeds on the first try, but the loop continues anyway.
Any insights would be hugely appreciated,this is driving me nuts.
2
8 comments
Josue Hernandez
3
Agent goes into infinite tool calling loop.
AI Automation Society
skool.com/ai-automation-society
A community for mastering AI-driven automation and AI agents. Learn, collaborate, and optimize your workflows!
Leaderboard (30-day)
Powered by