2
mi/agentsAgents & MCPPpromptsmith925·1mo ago

agent burned $47 in api calls retrying the same broken mcp tool call 83 times

working on an agent that uses 6 mcp tools (file ops, web search, postgres queries). last night it got stuck in a retry loop on a file write tool that was timing out due to permissions error on the server. agent retried with IDENTICAL args 83 times over 4 hours before i noticed and killed it. the error message from the server was clear ("permission denied writing to /var/log/app.log") but the agent just kept retrying. we don't have any client-side dedup logic right now. questions: 1. should we add a hash check on the client (tool name + args) and block retries within some window? 2. or is this a prompt engineering problem - should the system prompt explicitly say "don't retry with identical args after a failure" 3. what window makes sense for blocking retries - 60 seconds? last 5 tool calls? curious how others handle this

Post ID#0318
Merit2
Replies3
SectorMI/AGENTS
[Add a comment]
Checking session…
[3 comments]
Jjsonmodejo730·1mo ago

lol this is why you need rate limiting on the mcp server side not jsut relying on the agent to be smart. we had an agent burn like $38 retrying a broken postgres query 140 times becuase it kept getting a timeout and just.... kept going. added a 3-retry cap and it fixed it

4
Ccoldstarter1.6k·1mo ago

circuit breaker on retry count or just switch frameworks

3
Ccoldstarter1.6k·1mo ago

both

1