← Oferty

AI agent keeps looping and won't stop calling tools

Budżet: $30.0 - $60.0 HOURLY / PART_TIME ⭐ 5.00 (7) United States

python, bug-fixes

I run a small B2B lead-gen agency, and to save my team time I built an AI agent that handles inbound leads from our website form. The idea is simple: when a lead comes in, the agent looks them up (it has a few tools — an enrichment API to pull company size, a tool to check our CRM for duplicates, and one to draft a personalized first email), decides if they're a fit, and either drafts the outreach or marks them as not qualified. It's built with LangGraph and OpenAI function calling. It worked fine in testing but now that real leads are flowing in, it's misbehaving. The main problem is the agent gets stuck in a loop — it calls the enrichment tool, gets the result, then calls it again with the exact same arguments, over and over, until it hits the recursion limit and crashes. Sometimes it also ignores the tool output completely and hallucinates a company size instead of using what the tool returned. So it's clearly something in how the agent loop and tool results are being handled, not the tools themselves (I tested those separately and they return correct data). A few guesses, though I could be wrong: - the tool result isn't being appended back to the state/messages correctly, so the agent never "sees" that it already called it - my conditional edge in LangGraph is routing back to the agent node when it should go to end - the function-calling response isn't being parsed right, so it re-triggers the same call The stack is plain Python 3.11, LangGraph, and OpenAI. I just need someone to find why it loops and ignores tool output, fix it so the agent uses tool results and stops when it's done, and add a sane recursion guard. A couple sentences on what was actually broken would be great, since I want to understand it and not reintroduce it. I'll give you the repo, a couple of sample lead payloads, and an env example so you can reproduce it in minutes. Timeline should be a day or two. When you apply, tell me in one line the most common reason a LangGraph agent loops forever on the same tool call — copy-paste proposals are easy to spot. And mention one agent or LangGraph bug you've actually fixed before.
Otwórz na Upwork