Skip to content

    Agent Loop

    Reading time: 3 min.Editorially reviewed on:

    Definition

    The documentation of the OpenAI Agents SDK refers to the repeated process of model call, possible tool calls, and subsequent model call until a final output is available as an "agent loop."

    An agent loop calls a model, performs requested actions, and returns their results to the model. This repeats until a final output is produced. Some systems can hand over the task to another agent within this process.

    Simply explained

    The agent does not think just once: it can act, observe the result, and then choose the next step. The comparison to human thinking is imperfect, as the loop is a program flow that repeatedly calls the model.

    Why it matters in practice

    The loop determines when an agent run ends. The SDK provides an upper limit on iterations, error handlers, and resumption of a run for this purpose.

    Example from business

    Possible example: A research agent searches for a source, evaluates the result, starts a second search for gaps and ends according to fulfilled quality criteria.

    Limits and pitfalls

    • Without limited iterations, the loop can run too long. Exceeded limits and inappropriate output formats lead to termination without configured error handling; both cases must be anticipated.

    Origin & history

    The ReAct method (Yao et al., preprint of October 6, 2022) alternates reasoning steps and actions. No claim is made about the origin year of the term agent loop.

    Use in mid-sized companies

    • Potential applications: multi-stage research, document processing, support and automation, where interim results determine the next step.

    Frequently asked questions

    Do multiple tool calls run concurrently in one round?

    By default, the SDK starts all requested local function tools; max_function_tool_concurrency limits the number of concurrent calls.

    Can a run be interrupted and resumed?

    Yes, the runner can be resumed with a RunState, for example after a pause or after cancel(mode="after_turn").

    Does an error handler for invalid outputs repeat the model call?

    No, according to documentation it neither repeats the model call nor side effects of tools.

    Sources

    Sources checked on 14.10.2026. Editorial application examples are hypothetical; no evidence of real customer results.

    Editorially reviewed on:

    On this page

    Next step

    Put knowledge into practice