To build an AI agent for your business, pick one job with a clear finish line, list the data and tools it needs, and check whether a fixed workflow would do. Then choose a model and SDK, give it read-only tools first with every action behind human approval, test it on 20 to 50 real tasks, and launch with logging, spend caps and a hand-off to staff.
An AI agent is a language model that runs in a loop: it calls tools your code exposes, reads each result and decides the next step until the task is done or a stop rule ends it. Anthropic contrasts it with a workflow, where your code fixes the path and the model fills in steps. Most business problems need the workflow, and this guide helps you tell which one yours is.
I read every document quoted here on 3 November 2026. Definitions are in my AI chatbot vs AI agent guide and budgets in how much an AI agent costs, so this page sticks to the build.
Which job should your first AI agent do?
Pick one job that happens often, has a finish line you can check in a system, and has a person who owns it today. Anthropic's Building effective agents says agents add the most value on tasks that need both conversation and action, have clear success criteria, allow feedback loops and keep meaningful human oversight.
Write the finish line as one sentence about the state of a system, not about what the agent says. "Done means a drafted reply and a refund decision are waiting in the helpdesk for approval" can be checked. "Handle customer support" cannot.
Rule out three kinds of job at this stage:
- Jobs where one wrong action moves money or deletes data and nobody can review it first.
- Jobs in systems with no API, where the agent would have to click through screens.
- Jobs nobody owns, because someone has to take the hand-offs and review the logs.
My running example is made up: an online store's refund-request agent. It reads the customer's email, finds the order, checks the refund policy, drafts a reply and proposes refund or no refund. A staff member approves or edits before anything is sent or paid.
What data and tools will the agent need?
List everything the agent must read and every action it might take, and mark each one read or write. That list becomes your tool set and your permission plan. For the refund example:
| What the agent needs | Where it lives | Read or write | Who approves |
|---|---|---|---|
| The customer's email | Helpdesk | Read | No approval needed |
| Order, items, dates, payment | Store database or API | Read | No approval needed |
| Refund policy text | Help center page | Read | No approval needed |
| Draft reply | Helpdesk, as an internal note | Write, low risk | Staff member before sending |
| Refund | Payment provider | Write, moves money | Staff member, every time |
Make each tool narrow. The OWASP entry on Excessive Agency warns against open-ended tools such as "run a shell command" or "fetch a URL", and recommends tools with more granular functionality. A "get order by number" tool is safer than a database query tool, and easier for the model to use correctly.
Describe each tool as if for a new colleague: what it does, what each input means and what comes back. Anthropic makes thorough tool documentation and testing one of its three core principles. If the system already speaks the Model Context Protocol, an open-source standard for connecting AI applications to external systems, the agent can use an MCP server instead of custom tool code. My WHMCS MCP server guide shows what a read-only one looks like.
Do you need an AI agent, or would a workflow do?
Use a workflow when the steps are the same every time, and an agent only when the path depends on what the model finds along the way. Anthropic recommends the simplest solution possible, which "might mean not building agentic systems at all", and notes that agentic systems often trade latency and cost for better task performance.
In words, I ask four questions in order:
- Can one model call with your own content answer it? Then build a single call or a chatbot.
- Are the steps always the same? Then build a workflow: your code runs the steps, with a model call where judgment is needed.
- Is a wrong action costly or hard to undo? Then the agent can plan freely, but every action waits for a person.
- Do you have at least 20 real tasks to test with? If yes, build the agent with logs and spend caps. If not, collect them first.
The refund example is mostly a workflow: read email, find order, check policy, draft. The agent part is small: which order the customer means, and whether a policy exception applies. Anthropic's routing pattern fits too: classify the email first, then send refunds, questions and complaints down different paths.
Do not build an agent when a rule in your existing system would do the job, when nobody will take the hand-offs, or when you cannot say what a correct result looks like.
Which model and framework should you build on?
Pick the framework by who should run the agent loop, and pick the model by testing two candidates on your own test set. OpenAI and Anthropic each document several options, separated by where the loop runs:
| Option | Who runs the loop | What you get, per the docs |
|---|---|---|
| OpenAI Agents SDK | Your application | A runner for the agent loop and handoffs; your app controls deployment, storage and approvals |
| OpenAI Agents API | OpenAI, on a managed Codex harness | Saved sessions, multi-agent orchestration, MCP support, a hosted or self-hosted sandbox |
| OpenAI Responses API | Your application | Direct model calls; you build the agent yourself |
| Claude Agent SDK | A process you operate | Claude Code's tools, agent loop, permissions, sessions and hooks, in Python or TypeScript |
| Claude Client SDK | Your application | Direct API access; you write the tool loop or use the beta tool runner |
| Claude Managed Agents | Anthropic | A hosted agent harness with sessions in an Anthropic-managed or self-hosted sandbox |
For a business agent that calls your own systems, I start with a library that runs inside my application, so approvals, logs and storage stay in code I control. The OpenAI Agents SDK quickstart installs with pip install openai-agents or npm install @openai/agents zod, starts with one focused agent and one turn, and adds capabilities incrementally rather than starting with a large multi-agent design.
Anthropic suggests starting with the model API directly, since many patterns take a few lines of code, and understanding any framework you do use: incorrect assumptions about what is under the hood are, in its words, a common source of customer error. Two more details matter. Unless previously approved, Anthropic does not allow third-party products to offer claude.ai login, so an agent you ship uses an API key. And "Building effective agents" now notes that much of its tooling landscape has changed since December 2024.
Other frameworks exist; I reviewed only these two vendors' docs. When you test two models, compare correct outcomes, cost per task and speed. Anthropic's routing pattern can also send easy requests to a smaller, cheaper model.
How do you give an agent tools without giving it too much power?
Give the agent read-only tools first, put every action behind human approval, and give each tool only the access it needs. OWASP names three root causes of Excessive Agency: excessive functionality, permissions and autonomy.
- Functionality: remove every tool the job does not need.
- Permissions: OWASP's example is a read tool whose database identity can also update, insert and delete. Give it a read-only user.
- Autonomy: a person confirms every high-impact action until the logs justify relaxing that for a specific action.
The OpenAI Agents SDK has this built in. In its guardrails and human review guide, a tool marked as needing approval pauses the run instead of executing:
from agents import Agent, Runner, function_tool
@function_tool(needs_approval=True)
async def cancel_order(order_id: int) -> str:
return f"Cancelled order {order_id}"
The result returns interruptions plus a resumable state; your app approves or rejects each one and resumes the same run, and can serialize and store the state if review takes time. The page also warns that input guardrails run only for the first agent and output guardrails only for the agent producing the final output, so put validation next to the tool that creates the side effect.
The Claude Agent SDK handles this with permission rules and modes. Its documented locked-down setup pre-approves three read tools and denies any other call that would prompt (calls that never need approval, such as read-only Bash commands, still run):
const options = {
allowedTools: ["Read", "Glob", "Grep"],
permissionMode: "dontAsk"
};
Deny rules apply even in bypassPermissions mode, and the docs warn that allowed_tools does not constrain that mode: listing only Read still approves every tool. Whichever SDK you use, also set a stop rule; Anthropic names a maximum number of iterations as a common one.
How do you test an AI agent before customers see it?
Build a test set of 20 to 50 real tasks, define the correct outcome for each, and run the agent against it in a copy of your systems. Anthropic's Demystifying evals for AI agents (January 2026) calls 20 to 50 simple tasks drawn from real failures a great start, taken from your manual checks, bug tracker and support queue.
Grade the outcome, not the words. In Anthropic's example a flight-booking agent may say the flight is booked, but the outcome is whether the reservation exists in the database. For the refund agent, check that the right order was found, the decision matches what staff would decide, and no refund ran without approval.
| Grader type | Good for | Weak spot |
|---|---|---|
| Code-based checks | Right tool called, right parameters, record exists, turn count | Brittle when a valid answer looks different |
| Model-based rubric | Tone, clarity, whether the reply follows the policy text | Not deterministic; needs checking against human grades |
| Human review | The final word, and calibrating the model grader | Expensive and slow |
Run each task more than once, because outputs vary between runs. In Anthropic's numbers, an agent that succeeds 75% of the time per try passes all of three tries only about 42% of the time, which matters for customer-facing agents. Keep two suites: capability tests the agent still struggles with, and regression tests it must keep passing.
OpenAI's agent evals guide suggests starting with trace grading while you are still debugging, then moving to datasets and eval runs when you need repeatable results. Answer quality from documents is its own problem, covered in my RAG chatbot guide.
What does a safe launch look like?
A safe launch logs every model and tool call, caps spend, and hands anything uncertain to a named person with a summary. I start in shadow mode: the agent drafts, staff send, and I compare its drafts with what staff did.
Set the spend cap in the provider's console, not only in your code. Anthropic's rate limits page says the Start, Build and Scale tiers each carry a monthly spend cap, that you can set your own lower limit on the Billing page, and that workspaces can get their own limits. When a limit you set is reached, requests return HTTP 400 with a message starting "You have reached your specified API usage limits" (the tier cap returns HTTP 429), so your code must treat these errors as "hand off to a person", not crash.
Write the hand-off rule before launch: which cases go to whom, through which channel, with what summary. "Refund request, order 1042 found, outside the 30-day window in our policy, draft attached" saves staff the whole lookup.
My launch checklist:
- Every tool marked read or write, with least-privilege credentials.
- Every write action behind approval, tested with an approve and a reject.
- A maximum number of steps per run.
- The test set passing the agreed bar over several runs.
- Traces of every model call, tool call and approval decision.
- Provider and workspace spend limits set, and limit errors handled.
- A named hand-off owner and a weekly log review.
- An off switch that needs no deploy.
How do you improve the agent after launch?
Review the logs every week, turn each failure into a new test task, and change one thing at a time, running the test set after every change. Anthropic's evals article describes the same loop: capability tests with high pass rates graduate into a regression suite that catches drift.
Relax approvals one action at a time, only when the logs show staff approving that action unchanged over a long run, against a bar agreed with the job owner before launch. When a new model comes out, run the test set on it first; Anthropic notes that teams with evals can upgrade in days while teams without face weeks of testing.
If you want help with any step, I build custom AI agents and fixed-scope AI chatbot and agent packages, starting with a free scoping call of about 30 minutes and a written quote within one business day.
What else do people ask about building an AI agent?
Can I build an AI agent without coding?
Yes, for simple jobs: no-code builders let you write instructions, upload documents and connect a few tools. Approvals, least-privilege credentials, test sets and logs usually need code once the agent can change records.
How long does it take to build an AI agent?
A demo can take an afternoon. A business agent takes longer, because the test set, narrow tools, approvals and shadow mode each take real time. The timeline depends on how many systems it touches and how ready their APIs are.
How much does it cost to build an AI agent?
It depends on the number of tools, the approvals and the testing, plus a monthly model bill. I keep the figures in my AI agent development cost guide so they stay current.
Which programming language should I use for an AI agent?
Python, or JavaScript and TypeScript. OpenAI documents its Agents SDK in Python and JavaScript, and Anthropic its Agent SDK in Python and TypeScript, so pick the language your team already maintains.
Do I need a framework to build an AI agent?
No. As covered above, Anthropic suggests starting with the model API directly. A framework earns its place once you need its approvals, sessions or tracing, as long as you understand what it does underneath.
Last reviewed 3 November 2026. Disclosure: I build AI agents and chatbots for clients, so I am not neutral. I am CTO at ElySpace, a freelance developer for Marmaids LLC, and founder of WHMCSPilot and MagizAI. I am not affiliated with OpenAI or Anthropic. SDK names, options, code and limits come from the OpenAI, Anthropic, OWASP and Model Context Protocol pages linked above as I read them on that date.