← Ajit Pandey · Blog

How to Build an AI Agent: 7 Steps for a Small Team

To build an AI agent, you give a language model a goal, a short list of tools it may call, and a loop that runs until the job is done or a limit is reached. Your own code runs the tools and feeds the results back to the model. The work is mostly in choosing a narrow job, writing clear tool definitions and adding limits, not in clever prompts. This guide walks through seven steps for a small team, such as an MSP service desk.

What is an AI agent, in plain terms?

An AI agent is a system in which a language model decides, step by step, which actions to take and which tools to use to reach a goal. Anthropic's engineering team defines agents as "systems where LLMs dynamically direct their own processes and tool usage, maintaining control over how they accomplish tasks." A language model (LLM) is software trained on large amounts of text that can read and write natural language. A tool is a function you define, such as "look up a ticket" or "search the knowledge base", that the model can ask to have run.

If the steps are fixed in advance and the model only fills in one of them, that is a workflow, not an agent. Our guide to what AI workflow automation is covers that difference.

Do you need an agent at all?

Often not. The same Anthropic article advises finding "the simplest solution possible" and only adding complexity when needed, and says that optimising single model calls with retrieval and examples is usually enough. It describes agents as suited to open-ended problems where you cannot predict the number of steps in advance, and notes that they need trust in the model's decisions plus testing in sandboxed environments with guardrails.

A quick test:

If the job is... Use
The same steps every time, one step needs reading text A fixed workflow with one AI step
Answering questions from your own documents A single model call with retrieval
Different steps depending on what the model finds An agent

For most MSP tasks, start with the first row. See what an MSP should automate first.

How do you build an AI agent, step by step?

1. Pick one narrow job and write down "done"

Choose a job a person on your team does today, with a clear end. Example: "Read a new ticket, look up the customer's recent tickets, and suggest a category and a draft reply for a technician to approve." Write the finish line in one sentence. If you cannot, the job is too vague.

2. List the tools it needs, and make most of them read-only

Start with the minimum. For the ticket example:

Notice there is no "send email" or "close ticket" tool. An agent cannot do what you did not give it a tool for. Add write actions later, one at a time.

3. Describe each tool clearly

The model only knows a tool through its name, description and input schema. Anthropic's article recommends investing effort in tool interfaces so that "it is harder to make mistakes", and testing how the model actually uses your tools. In practice: use plain names, say in one sentence when to use the tool, and mark required inputs.

4. Write the loop

Tool use works as a round trip. According to Anthropic's tool use documentation, for client tools the model responds with a tool_use request, "your code runs the operation and sends back a tool_result." Your agent loop is therefore:

  1. Send the goal, the instructions and the tool definitions to the model.
  2. If the model asks to use a tool, run that tool in your code.
  3. Send the result back to the model.
  4. Repeat until the model gives a final answer, or a limit in step 5 is hit.

You can write this loop yourself in about a page of code, or use a framework or workflow tool. For a no-code route, see how n8n describes its AI agent node. Either way, the structure above is what runs underneath.

5. Add limits before the first real run

Anthropic recommends including stopping conditions, such as a maximum number of iterations, and pausing for human feedback at checkpoints or blockers. Set at least these:

6. Test on past cases before live ones

Collect 20 to 30 real, past examples where you know the right answer (remove customer names first). Run the agent on them and mark each as correct, partly right or wrong. Read the logs for the wrong ones: was it the instructions, a vague tool description or missing information? Fix one thing at a time and re-run the same set. The figure of 20 to 30 is a practical suggestion, not a standard; use more if the job is high-stakes.

7. Release it in shadow mode, then widen

First let the agent draft while a technician still does the work as normal, and compare. When its drafts are consistently usable, let technicians start from its drafts. Only then consider giving it a write tool, and keep a person approving. Track what matters, as in what to measure after an AI service desk launch.

What does a small agent cost to run?

We have no fixed figure for you, and any number would depend on your model, ticket length and volume. Model providers charge by tokens (small pieces of text) in and out. Anthropic's documentation lists that tool definitions, tool requests and tool results all count towards input and output tokens, and that tool use adds a small system prompt of its own. Estimate by running your 20 to 30 test cases, reading the token counts in the response usage data, and multiplying by your expected monthly ticket volume at your provider's current price.

What can go wrong?

Frequently asked questions

Do I need to know how to code to build an AI agent?

Not necessarily. Visual workflow tools let you add an AI agent step and connect tools without writing code. You still need to do steps 1, 2, 5 and 6 yourself, because they are about the job and the risks, not the software.

What is the difference between an AI agent and a chatbot?

A chatbot mainly answers messages. An agent can also call tools to look things up or take actions, and decides which to use. A chatbot with no tools is not an agent.

Which language model should I use?

Pick a model that supports tool calling, test two or three on your own past cases, and choose on accuracy and cost for your task. Model lineups change often, so check your provider's current documentation rather than relying on a list in an article.

Is an agent safe to let run unattended?

Not at first. Keep it read-only or draft-only, log everything, and add write access slowly with human approval. Unattended operation is only reasonable for low-risk, well-tested jobs.

Where to go next

If you run an MSP and want help scoping a first agent or workflow, see our services. If you are still deciding what to automate, start with what an AI service desk can do for an MSP.

This guide gives general information based on the sources linked above. It does not cover legal, security or compliance requirements for your business.