BroadRouter
Get started

AI agent

Updated

An AI agent is a system in which a language model directs its own steps toward a goal: it decides which tools to call, reads the results and repeats until it produces a final answer or hits a limit. A fixed script that calls a model at set points is usually called a workflow instead.

Also called: LLM agent, agentic AI, autonomous agent, agent loop, AI agents

An agent is a model in a loop: ask, act with a tool, read the result, decide again.

How it works

Anthropic separates two designs. Workflows are “systems where LLMs and tools are orchestrated through predefined code paths.” Agents are systems where “LLMs dynamically direct their own processes and tool usage.”

The OpenAI Agents SDK documents the loop itself. The runner calls the model. If the reply is a final answer, the run ends. If it contains tool calls, the runner executes them, appends the results and calls the model again. A max_turns setting caps the loop and raises MaxTurnsExceeded when it is passed.

A worked example: a coding agent asked to fix a failing test might take four turns.

Turn 1  model -> tool call: run_tests()
Turn 2  model -> tool call: read_file("src/dates.py")
Turn 3  model -> tool call: edit_file("src/dates.py", ...)
Turn 4  model -> final answer: "Fixed the timezone bug; tests pass."

Each turn is a separate API request. If the system prompt and tool definitions come to 5,000 tokens, they are sent 4 times: 20,000 input tokens before any history or tool output is counted.

Tools can be your own functions or come from MCP servers, which let one agent plug into file systems, databases and SaaS APIs through a shared protocol.

Why it matters

  • Cost grows with turns. Every turn is a new request that resends the conversation. The agent token budget post breaks down where those tokens go. Cached input lowers the bill for the repeated prefix.
  • Context fills up. Long runs push against the context window and get worse before they hit it. See context management for long-running agents.
  • Errors compound. Anthropic notes that autonomy brings “higher costs, and the potential for compounding errors.” Add stopping conditions, guardrails and human approval for actions that change data or spend money.
  • Parallelism. Several agents mean several requests in flight. Your provider’s concurrency limit decides how many can run at once. Multi-agent cost compares per-token and flat pricing for that case.

On BroadNet Inference

Any agent framework that accepts an OpenAI-compatible base URL can call BroadNet; the OpenAI Agents SDK guide shows the setup. BroadNet’s docs list tool calling for GLM 5.3 and Qwen3.8 27B. BroadNet’s docs set a pay-as-you-go key at 30 requests per minute and 4 in flight.

The flat-rate plans (Full Moon, Orbit, Meteor) cover DeepSeek V4.1 Flash with no token meter. One session runs one request at a time, the way a single agent works, so you buy one session per agent you run in parallel. BroadNet’s docs do not list tool calling for DeepSeek V4.1 Flash, so test your agent’s tool calls on it before you rely on a plan; documented tool calling means GLM 5.3 or Qwen3.8 27B on pay-as-you-go.

Questions

What is the difference between an agent and a workflow?

In a workflow, your code fixes the order of model and tool calls. In an agent, the model chooses the next step each turn. Anthropic's guide uses exactly this split.

Why are agents expensive to run on per-token pricing?

Each turn resends the system prompt, tool definitions and the growing history as input tokens. A 50-turn task can bill the same prefix 50 times, which is why cached input and flat plans matter.

How do I stop an agent from looping forever?

Set a maximum number of turns and a token or time budget. The OpenAI Agents SDK, for example, raises MaxTurnsExceeded when a run passes its max_turns limit.

Read as MarkdownAsk ChatGPTAsk ClaudeAsk Perplexity