OpenAI Agents SDK documentation
Official documentation and guidance for orchestrating model-driven tools with application controls.
Compute College
Control repeated model and tool steps with explicit limits, progress checks, and cost budgets.
An agent loop is the repeat cycle in which a model observes the current state, chooses a step, uses a tool, and checks what happened next. In production, the loop needs limits on steps, time, tokens, tool calls, and cost, plus a clear way to stop when it is stuck.
Memory trick: A loop without a budget is an open-ended bill.
A loop that works on a demo can repeat indefinitely when a tool fails, context grows, or the model misunderstands the goal. Budgets protect users, provider capacity, and system reliability while making failure recoverable.
A research agent may run for at most eight model steps, three searches per source, 60 seconds, and a defined token budget. It stops early when the evidence checklist is complete and escalates when the same search or error repeats.
Example figures are illustrative calculations, not current quoted market prices.
Current example
This source explains the method or risk boundary. It does not replace testing the actual model, data, provider, and workload conditions in production.
Official documentation and guidance for orchestrating model-driven tools with application controls.
Source discipline: examples on this page are illustrative; measure the real workload before making a release or capacity decision.
A maximum step count is only one limit. A short loop can still consume large contexts or expensive tools, and a long loop can repeat the same failed action.
Practical takeaway
Set step, time, token, tool, and cost limits. Add progress detection for repeated states and a user-visible fallback when the loop stops.
Decision check: what happens to the user, state, and partial work when the agent reaches its budget?
Compute College learning path
Step 31 of 48: Agent loops, stopping conditions, and budgets