How do I stop a tool loop from running forever?
Your code controls the loop, so put limits in it:
- Cap rounds (for example 10 tool rounds per user request).
- Detect repeats: if the same tool is called with the same arguments twice, return a note saying so.
- Budget tokens: stop when a request's total
usagepasses a threshold. - On the cap, send a final message asking the model to answer with what it has, using
tool_choice: "none".
Good to know#
- Retry only
429and 5xx errors, with backoff; honourRetry-Afterwhen it's sent. Which errors to retry - If calls fail unexpectedly, check status.clatterlabs.com before debugging further.
- Every response has an
X-Request-Id; log it so a request can be found later. Why log it
Still need help?#
- General support: support@clatterlabs.com or team@clatterlabs.xyz
- Infrastructure questions, or permanent deletion of your data (your whole account or one service): infrastructure@clatterlabs.xyz
We usually reply within the first hour, and always within 24 hours. A full support team is with you.
Related articles
Still need help?
Tried the steps above and still stuck? Email us. We usually reply within the first hour, and always within 24 hours. A full support team is with you.
Infrastructure questions, or permanent deletion of your data
infrastructure@clatterlabs.xyzFor deleting your whole account or the data of one service.