Back to articlesHands-on

Build your first AI agent: from idea to a working tool

What separates a chat from an agent, and how to build a simple agent that uses real tools, step by step.

By Bader Alsaqr··1 min readSample

This is sample content that shows how the platform looks. It is not real news.

A chat answers a question. An agent takes a goal, decides the steps, uses tools to carry them out, then checks the result.

The parts of any agent

  • A model that reasons and decides.
  • Tools: functions it can call, such as search, reading a file or sending a request.
  • A loop: it repeats “think → act → observe” until it is done.
  • Limits: a maximum number of steps and clear permissions.

A simple example

const tools = {
  weather: async (city) => fetch(`/api/weather?city=${city}`).then(r => r.json()),
};

for (let step = 0; step < 5; step++) {
  const reply = await model.ask({ goal, history, tools: Object.keys(tools) });
  if (reply.done) break;
  const result = await tools[reply.tool](reply.input);
  history.push({ tool: reply.tool, result });
}

Golden rules

  1. Start with a single tool and make sure it works.
  2. Log every step the agent takes so you can see where it went wrong.
  3. Never let it delete or pay for anything without human approval.

A good agent is not the smartest one. It is the one with the clearest limits.

#Hands-on#Agents

Read next

All articles