To build an AI agent you need five parts: a language model that decides what to do next, tools it can call to act in other systems, written instructions for the job, somewhere to keep what it learns, and a rule for which actions wait for a person. Wire those into a loop, test it on real work, and log every step. The model is the easy part. The tools, the approval rule and the upkeep are where the time goes.
That's the short answer to how to build an AI agent. The question most people are really asking is whether they should. If you are an engineer who wants to learn how agents work, building one is the best way there is. If you run a business and want the inbox handled or the leads followed up, building is one of two options, and it is often the slower one.
This post walks through the build step by step, including the parts tutorials leave out, then what it costs to keep one alive, and ends with a plain test for when to build your own AI agent and when to hire an AI employee that already does the job. Outside facts are quoted from the page they link to, read on 3 October 2026.
What is an AI agent, in one paragraph?
An AI agent is software that uses a language model to decide its own next step, takes that step through a tool, looks at the result and decides again, until the task is done or it needs help. Anthropic draws the line well in its engineering guide, Building effective agents: "Workflows are systems where LLMs and tools are orchestrated through predefined code paths. Agents, on the other hand, are systems where LLMs dynamically direct their own processes and tool usage, maintaining control over how they accomplish tasks."
So an agent is a loop with a model in the driver's seat. A chatbot only answers, and an automation follows the path someone drew for it, while an agent picks its own route through the tools. If that distinction is new, our post on AI agents vs. chatbots, assistants and automation goes through it slowly, and what agentic AI means covers the wider term.
How to build an AI agent in seven steps
A lot of tutorials on how to create an AI agent stop once the tools work. These are all seven, in the order you'll meet them.
1. Pick one job, and write down what done looks like
Start narrower than feels useful. "Handle customer email" is a department. "Read new messages in the support inbox, answer the ones our help articles cover, and pass the rest to a person with a one-line summary" is a job.
Write the finish line too. An agent with no definition of done either stops too early or keeps going and spends money. Anthropic's advice applies from the first hour: "we recommend finding the simplest solution possible, and only increasing complexity when needed." If a fixed sequence of steps would do the job, build that instead. It will be cheaper and easier to debug.
2. Choose the model
The model reads the situation and picks the next action. Larger models plan better and cost more per call. Smaller ones are fast and cheap and fine for sorting and short replies. Many production agents use both: a small model for routine turns and a larger one when the task gets hard.
Don't marry one provider. Models change every few months, and the agent you build should let you swap the model without rewriting everything around it.
3. Give it tools
A model without tools can only talk. Tools are how it reads the inbox, looks up the customer, books the slot or drafts the invoice. Each tool is a function with a name, a description the model reads, the inputs it takes, and code that calls a real system.
This is where the Model Context Protocol comes in, and it's why "what is MCP" is one of the most searched questions in this space. The official introduction describes it as "an open-source standard for connecting AI applications to external systems," and offers a comparison: "Think of MCP like a USB-C port for AI applications." In practice it means you can plug in tools other people already wrote instead of writing every connection yourself.
Tools are also where the real work hides. Each one needs authentication, a way to refresh expired sign-ins, sensible errors, and limits on what it can touch. An agent with write access to your whole CRM because the token was easier to set up that way is a problem waiting for a bad day.
4. Write the instructions
The instructions are the agent's job description. They say what the job is, what good work looks like, what it must never do, and when to stop and ask. Write them the way you'd brief a capable new hire on their first day: specific, with examples, and with the edge cases you already know about.
Expect to rewrite them many times. Most of an agent's quality comes from here, and you only find the gaps by watching it work.
5. Decide what it remembers
Out of the box, a model remembers nothing between conversations. AI agent memory is what you add so it knows your prices, your customers and the correction you gave it last Tuesday. The simple version is a notes file it reads at the start of each task. The serious version is a store it can search and update, with each memory saying where it came from so you can find and fix a wrong one.
Memory is easy to add and hard to keep honest. If the agent writes something wrong into memory, it will repeat the mistake confidently until somebody notices.
6. Put a person in the loop for anything it can't undo
Human in the loop is the step builders skip, and it's the one that decides whether you can trust the agent with anything real. The rule is simple to state: every action is sorted by whether it can be undone. Reading, searching and drafting can run on their own. Sending, paying, deleting and anything a customer sees should wait for a yes until the agent has earned more room.
Anthropic is direct about why: "The autonomous nature of agents means higher costs, and the potential for compounding errors. We recommend extensive testing in sandboxed environments, along with the appropriate guardrails." Building the approval gate properly means a place where requests wait, a way to approve from where your team already works, and a check that the agent can't route around the gate when it's in a hurry.
7. Log everything, then test on real work
Keep a record of every step: what it saw, what it decided, which tool it called and what came back. When something goes wrong, and it will, the log is the only way to find out why. It is also how you'll convince a colleague the agent can be trusted with more.
Then test it on last month's real cases, the messy ones included. Run it alongside a person for a week. Compare. Fix the instructions. Repeat until the gaps are small and boring.
What the tutorials leave out
If you follow the steps above, you'll have a working agent in a few days. Keeping it working is the bigger job, and it doesn't show up in a weekend demo.
- Sign-ins expire. Every connected app has tokens that lapse, permissions that change and APIs that get versioned. Someone has to notice and fix it.
- Models change. A new model version can make the agent better at one thing and quietly worse at another. You need tests you can rerun.
- Costs drift. An agent that loops on a hard task can spend in an hour what it usually spends in a week. You need limits and a way to see the spend.
- People change the process. The business adds a product, changes a price or moves to a new tool. The instructions and the memory have to follow.
- Someone has to own it. When the person who built it leaves, the agent tends to become the thing nobody wants to touch.
Frameworks help with some of this. They also add their own weight. Anthropic's guide notes that agent frameworks "often create extra layers of abstraction that can obscure the underlying prompts and responses, making them harder to debug." Our roundup of open source AI agents looks at the main frameworks and what running each one takes.
How much does it cost to build an AI agent?
Any single number you read online is a guess about someone else's job. The honest answer is a list of the costs, so you can price your own:
- Engineering time to build it. The seven steps above, plus connecting each app. This is the biggest line for most teams.
- Model usage. You pay per token, every time the agent thinks. A busy agent on a large model adds up.
- Hosting. Somewhere for the loop to run, for jobs on a schedule, and for long tasks that outlive a single request.
- Maintenance. The list in the section above, every month, for as long as the agent runs.
- The cost of its mistakes, which a good approval gate lowers and nothing removes.
The first line is a one-off. The other four are rent. When people compare building and buying, they usually compare the one-off against the subscription and forget the rent.
What about no-code AI agent builders?
A no-code AI agent builder takes away step 3's plumbing and much of the hosting. You drag tools onto a canvas, write instructions in a box, and the platform runs it. For a technical-minded operator this is a real middle path, and it's why "no code ai agent builder" gets thousands of searches a month.
What it doesn't take away is steps 1, 4, 5 and 6. You still design the job, write and rewrite the instructions, decide what it remembers and set the approval rules. You still own it when it breaks, so an AI agent builder makes building faster without changing who maintains the result. We compare the main ones in the best no-code AI agent builders.
Build vs. buy: when to build your own AI agent
The build vs buy question has a fairly clean answer once you look at what's special about the job.
Build when the job is your product, or close to it. If the agent is what you sell, or it touches data and systems nobody else could connect to, or you need control over every prompt and model choice, build it. The same goes if your team wants to learn how agents work from the inside, because there's no better teacher than shipping one.
Hire when the job is ordinary business work: the inbox, lead follow-up, booking, invoicing, the weekly report. These jobs look the same in most companies. Building your own agent for them means paying engineering time to reinvent something that already exists, then paying rent on it forever.
There's a simple question that settles most cases. Would you write the software for this job if a person were doing it? Most companies wouldn't build their own payroll system or email client. The same instinct applies to ordinary jobs done by AI.
What hiring an AI employee looks like instead
An AI employee is the build above, already done for a job, and run for you. At Sanaf the hire works in your Slack or Microsoft Teams, and you give it jobs from a roster that already knows the work, such as lead qualification, scheduling or invoicing.
Here is how the seven steps map, using what the product does today:
- The job and the instructions come with the roster entry. You adjust them in plain words instead of writing them from scratch.
- The tools are the apps you already run. You connect each one with a sign-in scoped to the job, and you can revoke any of them one app at a time. Your own systems can be added as an MCP server or a REST API, and every tool from one of them asks before it acts until you say otherwise.
- Memory keeps how your business works, and every memory says where it came from. You can question it, correct it and see the version history.
- The approval gate is set per kind of action: do it, ask first, or never. It drafts before it sends and asks before anything it cannot undo.
- The log is a work record your team can read in the thread.
What you give up is control over the internals. You don't pick each prompt, and you can't fork it into a product. For ordinary business work that's usually the right trade. For anything that is your product, it's the wrong one.
Pricing is the other half of the comparison. Sanaf starts with $120 of free credit and no card. After that you buy credits from $20 as you need them, they never expire, and you pay for the work rather than per seat. The pricing page has the details, and what an AI employee costs sets it against the cost of building.
Questions people ask before they build an AI agent
How do I build an AI agent from scratch?
Pick one narrow job, choose a model, give it tools to act in your systems, write clear instructions, add memory, put a person in the loop for actions it can't undo, and log every step. Test it on real past work before you trust it with live work.
Can I build an AI agent without coding?
Yes, with a no-code AI agent builder. The builder handles the plumbing and the hosting. You'll still design the job, write the instructions, set the approval rules and keep the thing running.
How long does it take to build an AI agent?
A demo takes days. A version you'd trust with customers takes longer, because most of the work is testing on real cases, tightening the instructions and building the approval step. After that it needs regular maintenance.
What is the difference between building an AI agent and hiring an AI employee?
Building means you own every part: the model, tools, instructions, memory, approvals and upkeep. Hiring an AI employee means those parts already exist for a known job, and you set the rules and review the work.
Are AI agents for business safe to use?
They're as safe as their approval rules. An agent that can send, pay or delete without asking is a risk. One that drafts and waits for a yes on anything it can't undo, and keeps a record you can read, is one you can actually supervise.
Should a small team build or buy?
If the job is ordinary business work and nobody on the team wants to maintain an agent, hiring is usually faster and cheaper over a year. If the agent is the product, or the team has engineers who want to own it, building makes sense.
Where to start
If you're building, start with step 1 and the simplest thing that could work. Write down what done looks like before you write any code.
If you'd rather the job just got done, read how Sanaf works, look through the jobs it can hold, or start free and give it one job this week.