Blog

Inside run(): how the tool-calling loop works

Making a tool available is not the same as calling it. A walk through one run() request: the model, the instructions, the tools, and the loop Agent200 executes until the answer is ready.

2 min read

A closed ceramic loop track with white spheres and one green sphere in motion

Agent200 is not a passive API proxy. Inside a single run() request it invokes the model you chose, hands it the tools you allowed, executes the tool calls the model makes, and keeps going until the request is complete. Here is what happens inside that loop.

One request, five inputs

A request names the end user, the model, the instructions, the task and the tools the model may use.

Conceptual example.

const result = await agent200
  .user("user_123")
  .run({
    model: "openai/gpt-5.6-sol",
    instructions: "You are a productivity assistant. Use the available tools when necessary.",
    input: "Retrieve the latest LinkedIn post from XYZ. If today is Sunday, also prepare my brief.",
    tools: ["brief", "linkedin"],
  });
Input What it decides
user Whose authorized connections the tools use
model Which AI model processes the request and drives the loop
instructions How the model should behave for this request
input The actual task
tools Which configured capabilities the model may call

The loop

  1. Agent200 gives the model the definitions of the tools you allowed.
  2. The model reads the task and decides whether it needs a tool.
  3. When it asks for one, Agent200 executes the operation through the connector or workflow behind it, for the user you named.
  4. The result goes back to the model.
  5. The model reasons further, calls another tool, or writes its final answer.

Your application receives the finished result and carries on with it, inside whatever larger workflow your agent runs.

Available is not the same as called

Look at the request again. Both linkedin and brief are available, but the input only asks for the brief on Sundays. On a Sunday the model may call both tools. On a Tuesday it calls only the LinkedIn capability.

Listing a tool makes it possible. The model decides, during execution, whether it is needed.

One practical note: a decision like this depends on the date. Give the model the current date in the instructions or the input, and it can make the call reliably.

Tools inside tools

A single tool call can run a whole workflow. When the model calls brief, Agent200 runs every operation configured inside it and returns one combined result:

run()
 └─ model calls: brief
     └─ workflow
         ├─ chat messages
         └─ recent email
     └─ combined result → model → final answer

The model never needs to know the endpoints inside brief. It only needs to understand what the capability does and which inputs it takes.

The right model for each request

Different requests can use different models: a fast one for a simple lookup, a stronger one for a multi-step task. The model you select for a request is the one that runs its loop.

See the full execution path on the Platform page.

Stacks of envelopes being organised into an index card cabinet with green tabs
Product

iGPT: your agent’s email context in one request

iGPT is a premium connector on Agent200. It indexes your users' email, threads and attachments, and answers your agent with cited, structured context in…

1 min read

Five frosted glass lenses of different shapes in a row, one with a green edge
Guides

Choosing a web search API for your agent

Tavily, Exa, Brave Search, Perplexity and Firecrawl each lean toward a different part of search. How to pick for your agent, and why you…

2 min read

200 OK

Build the agent.
Access everything it needs.

Bring the agent you already have. Agent200 provides and executes its external capabilities.

Book a demo.
See it in action.

Tell us who you are, then pick a time for a 1:1 session with an expert from our team.

We use your details only to email you about Agent200. See the Privacy Policy.

Pick a time. We'll take it from there.

A 1:1 session with an expert from our team, about what you are building.

Open in Calendly (opens in a new tab)