Skip to content
AI agents

How to build an AI agent, step by step

Build a working AI agent in eight steps, from one job and its tools to approval, deploy and logs, using a real deal coach agent running in Tray Helix.

Tray Helix team

Product, Tray.ai Updated Nov 30, 2026

To build an AI agent, pick one job with a clear result, give the agent tools, write its instructions, require approval on any tool that changes data, deploy it and read its logs. This tutorial builds a deal coach agent in Tray Helix, which runs the agent with your app, enforces approval and logs every run.

The deal coach lives in a sales app. It reads a deal, finds what puts it at risk and tells the rep what to do next. The screens are from the agent running in Tray Helix. If you want the definition first, read what an AI agent is. If you want the product page, it is Tray Helix Agents.

The build, in order

  1. 1

    Pick one job

    Write it as a result you can check.

  2. 2

    Give it tools

    Each read or action is one tool with typed inputs.

  3. 3

    Write the instructions

    Say what good looks like and what to refuse.

  4. 4

    Choose the model

    Name one, and list fallbacks.

  5. 5

    Add approval and limits

    Writes wait for a person. Runs stop at a limit.

  6. 6

    Deploy

    The agent ships with the app, in one command.

  7. 7

    Read the logs

    Every run and tool call is on record.

  8. 8

    Test, then widen

    Score it on real cases before it does more.

Step 1: Pick one job

The most common reason a first agent fails is that its job is a mood: “help sales.” Write the job as a result.

For this build, it is: given a deal, say what puts it at risk and what the rep should do next, using what the CRM already holds.

That sentence tells you what the agent reads (the deal, its risk signals, the account, the contacts and the recent activity), what it produces (a short brief) and what it must not do (change the deal). Everything later in the build follows from it. If you cannot write your job in one sentence like this, the agent is not ready to build.

Step 2: Start the app the agent will live in

On Tray Helix an agent lives inside an app. The model, instructions and tools are code in that app, and the agent ships with it. So you start with the app, and the agent is one part of it.

You do not type this code from a blank file. You describe it to your AI assistant: Claude Code, Cursor or the Claude desktop app. Every Helix project already teaches the assistant how agents and their tools are written. Setup is a one-time step: install the Helix CLI and run helix login.

Here is the first prompt for the deal coach. It builds the app and the data the agent will read.

Create a Helix app: a CRM for a sales team.

Store accounts, contacts, deals and activities. A deal has a stage,
probability, ARR, close date, owner, next step, competitor and a risk
score from 0 to 100 with the reasons behind it. Seed it with realistic
demo data: about 20 accounts, 3 contacts each, and a pipeline of open deals.

Show the pipeline as a board and each deal as a record page.

Step 3: Give the agent tools

An agent can only act through its tools, so this is the step that decides what it can do. A tool is one operation with a name, a description the model reads, and typed inputs. Keep them narrow. Seven read-only tools beat one tool that can do anything.

The deal coach gets these:

  • find_records finds accounts, deals and contacts by name and returns their ids.
  • read_deal reads one deal: stage, probability, ARR, close date, owner, next step, competitor.
  • read_signals reads a deal’s risk score and the plain-language reasons behind it.
  • read_account, read_contacts and read_activities read the account, its contacts with their buying-committee roles, and the latest logged activity.
  • read_pipeline reads every open deal.
The Agents tab of a Helix app called Customer Relationship Management, on the Tools view. It lists seven tools: find_records, read_account, read_activities, read_contacts, read_deal, read_pipeline and read_signals. Each has a one-line description. A Needs approval column is empty for all seven, and a Used by agents column shows which agents can call each tool: ask-crm, deal-coach, or both.
The Tools view lists every tool in the app, whether it needs approval, and which agents use it. Here two agents share the same read-only tools.
The Agents tab of a Helix app called Customer Relationship Management, on the Tools view. It lists seven tools: find_records, read_account, read_activities, read_contacts, read_deal, read_pipeline and read_signals. Each has a one-line description. A Needs approval column is empty for all seven, and a Used by agents column shows which agents can call each tool: ask-crm, deal-coach, or both.

Notice the Used by agents column. A tool belongs to the app, and any agent in the app can be given it. That is how the app’s second agent, ask-crm, reuses the same reads.

This prompt adds the tools and the agent in one go:

Add an agent called deal-coach to the CRM app.

Give it read-only tools: find_records, read_deal, read_signals,
read_account, read_contacts, read_activities and read_pipeline.
Each tool takes typed inputs, such as a deal id like o-013, and
returns only the fields it needs.

The agent must not have any tool that changes a record.

Step 4: Write the instructions

Instructions are where you say what good looks like. Write them like a brief to a new hire, not like a spell.

  • The job. One sentence, the one from step 1.
  • The method. “Read the deal, then its risk signals, then the account, the contacts and the last activities. Cite what you used.”
  • The output. “Three lines: the biggest risk, the evidence, and the next step the rep should take this week.”
  • The limits. “If a fact is not in the data, say so. Never guess a number.”
Instructions for deal-coach: You coach a sales rep on one deal. Read the
deal, its risk signals, the account, its contacts and the recent
activities. Answer in three parts: the biggest risk, the evidence from
the data, and the one next step to take this week. If the data does not
say, write "not in the CRM". Never invent a number or a contact.

Tell the agent what to refuse as clearly as what to do. Anything it reads, such as a note a customer wrote, is untrusted text. Say that in the instructions too.

Step 5: Choose the model

The agent names its model in code and can list fallbacks to try if one errors. The deal coach runs on claude-sonnet-5-5. You can call models on Amazon Bedrock through Tray, or your own provider’s models with your own key. Helix holds the key outside your code, and AI usage shows per app.

Pick the cheapest model that passes your tests in step 8, then move up only if it does not. A read-and-summarize job rarely needs the biggest one.

Step 6: Add approval and limits

This is the step that makes an agent safe to run.

Mark every tool that writes as needing approval. The run pauses before the tool runs, shows a person the tool and the exact input the model proposed, and waits. They approve or decline, and the agent picks up where it left off. Approval can depend on the input, such as refunds over $100. It is off unless you turn it on.

The deal coach has no write tools, which is why the Needs approval column in the screen above is empty. If you later add update_next_step, you would mark it for approval, and the column would show it.

Two limits come with every agent. A run stops at 25 steps or 50 tool calls by default, so a loop cannot run on. And an agent can only use the tools in the app’s code, so it cannot reach anything the app does not already reach.

Add this to the prompt when you give the agent a write:

Add a tool update_next_step that changes a deal's next step.
Mark it as needing approval, so a person sees the exact new text
before it is saved.

Step 7: Deploy it, then read the logs

Deploy from your assistant or the CLI. The agent deploys with the app in the same command. There is no separate agent service to host. Helix runs the model loop, keeps each conversation’s memory and logs every run.

Every deployment is on record, and you can restore a previous one. With deploy approvals on, a change waits for a named approver before it goes live.

The Deployments tab of a Helix app. A list of deployments, each with a Success status, an id, the Production environment, who deployed it and when. The newest is marked Live. A menu on one row offers Restore this version, View build output and Download source.
Every deployment of the app, and so of its agent. The newest is live, and any earlier one can be restored.
The Deployments tab of a Helix app. A list of deployments, each with a Success status, an id, the Production environment, who deployed it and when. The newest is marked Live. A menu on one row offers Restore this version, View build output and Download source.

Then run it. Here the app’s route POST /api/deals/o-013/coach calls the agent, and the Logs tab shows what happened.

The Logs tab of a Helix app with a run open in a side panel. The trigger is an HTTP POST to a deal coach route, in the production environment. Under operations, the deal-coach agent shows status completed on the claude-sonnet-5-5 model, with five tool calls under it: read_deal, read_signals, read_account, read_contacts and read_activities, with the time each took.
One run of the deal coach. The agent, its model and status, and each tool call it made, under the request that started it.
The Logs tab of a Helix app with a run open in a side panel. The trigger is an HTTP POST to a deal coach route, in the production environment. Under operations, the deal-coach agent shows status completed on the claude-sonnet-5-5 model, with five tool calls under it: read_deal, read_signals, read_account, read_contacts and read_activities, with the time each took.

Read a few runs before you trust the agent. Check that it called the tools you expected, in an order that makes sense, and that its answer cites what it read. The Uses AI filter on the Logs tab narrows the list to agent runs. Tray streams agent, workflow and audit logs to Splunk, Datadog or any SIEM or log tool you use.

Step 8: Test it, then widen it

An agent that worked on the case you tried has not been tested. Build a set of real cases with the answer you expect for each, run the agent on all of them, and score the results.

In Helix, the test set is a table in the app’s database. An eval function runs the agent on each case and scores the output, either with rules (“did it name the competitor on the deal?”) or with a model as judge. Run it in CI through Deploy from CI to gate the deploy. For a change that matters, deploy to a staging workspace first and use deploy approvals before it goes live. This is built from Helix parts. It is not a separate eval product.

Then widen. Give the agent one more tool, or a second job, and rerun the tests. Add one thing at a time.

What should you build after your first agent?

Once the first agent works, the same pattern covers most of the agents teams build:

  • Triggered by an event. An app route, a webhook, any app event through a Tray iPaaS trigger, or a schedule can start the agent.
  • Reachable where people work. A Slack or Teams message can call the agent’s route with a Helix API token, and your front end shows the answer in your brand.
  • Running as the user. When an agent’s tools run through Agent Gateway, a tool’s authentication can be set to the asking user’s own credentials, so the call runs as that user when the call should.
  • Measured. Each run can write its outcome, tool calls and model to the app’s database, and a dashboard app reports deflection, approval rate and cost per outcome.

Each of those is a guide with prompts you can copy on the Tray Helix Agents page. A real example of where this leads: Apollo’s IT agent, built with Tray, deflected 40% of IT tickets in its first two weeks. Read the story.

How much does it cost to build an AI agent?

You can build and run your first agent on Tray Free, $0 with no time limit. An agent has no fee of its own. Its model calls count toward its app’s usage in HCUs, on the same balance as the rest of Tray, with no per-user fees. Current rates are on the pricing page.

What mistakes do first AI agents make?

  • A job that is a mood. “Help sales” has no finish line. Write the result.
  • One tool that can do anything. Narrow tools are easier to approve, test and log.
  • Approval nowhere, or everywhere. Put it on every write, and nowhere on reads, or approvers stop looking.
  • No test set. Trying three cases by hand is not a test.
  • Trusting what the agent reads. A ticket, an email or a note can contain instructions. Keep write tools behind approval.
  • AI agents
  • Tutorial
  • Agent development

Frequently asked questions

How do I build an AI agent?

Pick one job with a clear result, give the agent the tools it needs to do it, choose a model, write its instructions, mark which tools need a person's approval, test it on real cases, then deploy it and read its logs. On Tray Helix you describe the agent to your AI assistant, and it deploys with the app in one command.

Do I need to code to build an AI agent?

Not by typing it. On Tray Helix you describe the agent to an AI assistant such as Claude Code, Cursor or the Claude desktop app, and the assistant writes the agent and its tools as code in your app. You read and approve what it writes. A one-time setup installs the Helix CLI and signs you in.

What do I need before I build my first AI agent?

One job you can describe as a result, such as "tell the rep what puts this deal at risk and what to do next". Then the systems the agent must read or change, access to them, and a person who owns the agent. You do not need a data science team or a model of your own.

How do I build a custom AI agent for my business?

Start from your own process, not a template. Write the one job, list the data it reads and the actions it takes, and build those as tools. A custom agent is mostly the right tools and clear instructions. In Tray Helix each tool is code in your app, so it can call any of the 12,000+ apps, databases, APIs, and services Tray connects to.

Do I need a framework like LangChain or CrewAI to build an AI agent?

No. Frameworks such as LangChain, LangGraph and CrewAI are libraries for writing the agent loop yourself, and you then choose where it runs and how it is secured. On Tray Helix the loop, conversation memory, approval on tools and run logs come with the app the agent lives in, so you write the job, the tools and the instructions.

Does an AI agent need memory?

Only for the parts of a job that span turns or days. Tray Helix keeps each conversation's memory for the agent. Longer-running work, such as a case the agent picks up again tomorrow, keeps its state in the app's own database, and a scheduled function picks it up.

How long does it take to build an AI agent?

A first agent that reads data and drafts an answer is a short build once the job and tools are clear. The slower parts are testing it on real cases and deciding who approves what. Budget your time for those, not for the model call.

How do I keep an AI agent from doing something it should not?

Give it narrow tools, mark every tool that writes as needing approval, and treat the text it reads as untrusted. In Tray Helix an agent can only use the tools in the app's code, a run stops at 25 steps or 50 tool calls by default, and every run and tool call is logged.

How do I test an AI agent before it goes live?

Keep a set of real cases with the answers you expect, run the agent on them, and score the results with rules or a model as judge. In Tray Helix the test set lives in the app's database, an eval function runs the agent and scores it, and the same check can run in CI to gate the deploy. It is built from Helix parts, not a separate eval product.

What does it cost to build an AI agent on Tray Helix?

You can start on Tray Free, $0 with no time limit. An agent has no fee of its own: its model calls count toward its app's usage in HCUs, on the same balance as the rest of Tray, with no per-user fees. Current rates are on the pricing page.

Put your next AI-built app into production.

Deploy it to Tray Helix with one command, behind company sign-in, with a named owner and an audit trail.