October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

What an AI Agent Actually Is, With a TypeScript Loop

An AI agent is more than a prompt: see how the OpenAI Agents SDK runner calls a model, executes requested tools or handoffs, and returns a final answer.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

An AI agent is a model-driven system that can respond to instructions and, when equipped with tools or handoffs, take actions and continue working through a task. In the OpenAI Agents SDK for TypeScript, a runner calls the agent, handles its requested actions or transfers, and repeats until it receives a final answer or reaches a configured stop condition. That is an implementation-oriented explanation of this SDK—not a universal formal definition of every system described as an agent.

What makes an AI agent more than a prompt?

A prompt supplies directions; an agent is the configured model-and-control setup that acts on those directions. The OpenAI Agents SDK describes its framing this way: “An agent is an LLM equipped with instructions, tools and handoffs.” Those capabilities are possible parts of an agent, not a checklist every agent must satisfy. A simple agent may have instructions and no tools; another may use tools or pass work to a specialist.

Instructions are the directions attached to an agent definition. The SDK guide describes them as the agent’s system prompt. A tool is a callable capability the agent can use to take an action. A handoff transfers control of the run to another agent. Together, these concepts distinguish an agent from a single model response: the model can request work, while the surrounding runner determines what happens next.

How does the agent loop work?

The loop is iterative. The runner invokes the current agent with the conversation, examines the model’s response, and either returns a final answer or handles a requested action before calling a model again. The OpenAI Agents SDK puts it simply: “Agents do nothing by themselves – you run them with the Runner class or the run() utility.”

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Start with the configured agent and the user’s input.
  2. Call the current agent with the conversation.
  3. If the response is final output, return it.
  4. If the response requests a tool, execute the tool, add its result to the conversation, and call the agent again.
  5. If the response hands off control, switch to the receiving agent and continue the run.

This is a conceptual outline of the SDK runner’s flow, not a claim about a hand-written implementation. The exact response handling depends on whether the model produced final output, tool calls, or a handoff. The runner can also stop with an exception if a configured maximum turn count is exceeded; that is SDK control behavior, not a requirement shared by all agent architectures.

A minimal TypeScript agent

The official OpenAI Agents SDK for TypeScript uses this concise pattern to define an agent, run it with a string input, and print its final output:

import { Agent, run } from '@openai/agents';

const agent = new Agent({
  name: 'Assistant',
  instructions: 'You are a helpful assistant',
});

const result = await run(agent, 'Write a haiku about recursion in programming.');
console.log(result.finalOutput);

The string passed to run() is treated as a user message. The runner invokes the starting agent and returns when it has final output; if the response instead requests a tool or hands control to another agent, the runner handles that outcome and continues. A maximum-turn limit can raise an exception rather than allowing the run to continue indefinitely.

The snippet shows the agent-and-runner structure, not a standalone application setup. The SDK quickstart describes using an existing TypeScript app with an index.ts entry point. Consult the official TypeScript quickstart for setup steps, and the running agents guide for the run lifecycle.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What happens when an agent calls a tool?

A tool call is an action requested by the model, not the tool executing itself. The runner receives the request, invokes the corresponding capability, adds the tool’s result to the interaction, and calls the model again. The model can then use that result to decide what to do next or produce its final answer.

The SDK groups several kinds of capabilities under tools, including hosted tools, built-in execution tools, function tools, agents used as tools, MCP servers, and sandbox capabilities. Which kind is appropriate depends on the task; an agent does not need every tool category. See the SDK tools guide for the documented options.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

How is a handoff different from an agent used as a tool?

Both patterns let one agent involve another, but they differ in who keeps control of the conversation. A handoff transfers control to a receiving agent, which continues with the conversation context unless filtering changes what it receives. In a manager pattern, the central agent remains in charge and calls a specialist exposed as a tool.

Pattern Who controls the run? How the specialist participates Who produces the final response?
Manager with agents as tools The manager stays in control. The specialist performs a bounded callable task and returns a result to the manager. The manager remains responsible for the user-facing response.
Handoff Control transfers to the receiving agent. The receiving agent takes over the conversation, retaining context unless it is filtered. The receiving agent can continue the run and produce the response.

Use the manager pattern when one agent should coordinate specialists and retain responsibility for the overall answer. Use a handoff when the next agent should take over the conversation. The agent orchestration guide describes both patterns.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What the SDK example does—and does not—imply

This loop is a practical way to understand one SDK’s agent model, not a rule that every AI agent must follow. The SDK documentation supports optional tools and handoffs; it does not establish that every agent needs multiple tools, multiple agents, persistent memory, planning, or long-running autonomous execution. Those are design choices that depend on the job. For the SDK’s own overview and agent definition, see OpenAI Agents SDK for TypeScript and its agents guide.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.