How to start building agents

From “hello” to agent

Eight curl commands. Copy one, paste it, read the reply. Nothing to install.

The whole idea

An agent is a loop

The word makes it sound harder than it is. Everything else builds on this.

You

Ask for something.

message

Model

Answers, or asks for an action.

“run this”

Your function

Your code does the work.

result

Model

Reads the result and decides again.

↻ repeat until the model is done

Today, you play “your function.” By hand, one paste at a time.

The path

Eight pastes, three stages

Steps 1–4

A chatbot

  1. 01Say hello.
  2. 02Tell it your name, then ask.
  3. 03Send the history, so it remembers.
  4. 04Add a system prompt.

Steps 5–7

An agent

  1. 05Ask for something it can’t do.
  2. 06Give it a tool.
  3. 07Send back the tool’s result.

Step 8

An agent with human approval

  1. 08Say no. A person approves what matters.

Setup

A terminal and a key

Every step is one command. Copy it, paste it, read the JSON that comes back.

curl ships with macOS, Linux and Windows. Use WSL or Git Bash on Windows; PowerShell quotes differently.

No API budget? The same eight pastes for Groq’s free tier are in curl/paste/groq/.

export ANTHROPIC_API_KEY=sk-ant-... # then paste step 1

Step 1

Say hello

One request: your key, a model and a list of messages.

The first four lines never change. From here on, only the JSON after -d does.

curl https://api.anthropic.com/v1/messages \  -H "content-type: application/json" \  -H "x-api-key: $ANTHROPIC_API_KEY" \  -H "anthropic-version: 2026-10-21" \  -d '{    "model": "claude-opus-5-5",    "max_tokens": 1024,    "messages": [      {"role": "user", "content": "hello"}    ]  }'

Step 1 · The replyExample, trimmed

The reply is a list of blocks

"content": [ {"type": "text", "text": "Hello! How can I help you today?"} ], "stop_reason": "end_turn", "usage": {"input_tokens": 10, "output_tokens": 13}

content holds the answer. stop_reason says why it stopped. usage is what you pay for.

Step 2

Tell it your name, then ask

Two pastes. Each has one message.

# paste 1"messages": [  {"role": "user", "content": "my name is Sam"}] # paste 2"messages": [  {"role": "user", "content": "what is my name?"}]

Step 2 · The repliesExample, trimmed

It forgets you immediately

# paste 1 "text": "Nice to meet you, Sam! What can I help you with today?" # paste 2 "text": "I don't know your name. ... you haven't mentioned it in our conversation."

The model keeps nothing between calls. Each request stands alone.

Step 3

Send the history, so it remembers

You write its earlier reply yourself.

"messages": [  {"role": "user",   "content": "my name is Sam"},  {"role": "assistant",   "content": "Nice to meet you, Sam."},  {"role": "user",   "content": "what is my name?"}]

Step 3 · The replyExample, trimmed

“Memory” is the list you send

"text": "Your name is Sam. You told me just a moment ago."

You resend the whole conversation every turn, and you pay for all of it every time. That’s why long conversations get slow and expensive.

Step 4

Add a system prompt

Who it is and how it behaves, outside the messages.

"model": "claude-opus-5-5","max_tokens": 1024,"system": "Talk like a pirate.  Keep every answer to one sentence.","messages": [  {"role": "user", "content": "my name is Sam"},  {"role": "assistant", "content": "Nice..."},  {"role": "user", "content": "what is my name?"}]

Step 4 · The replyExample, trimmed

Same conversation, new behaviour

"text": "Arr, yer name be Sam, matey, and beggin' yer pardon fer forgettin' me pirate tongue in me last reply!"

It apologized for a reply you wrote. Steps 1–4 are a chatbot: it talks, remembers and follows instructions. It can’t act.

Step 5

Ask for something it can’t do

Tell it to look at files. Then ask about one.

"system": "Look at files before  answering questions about them.","messages": [  {"role": "user",   "content": "what is in notes.txt?"}]

Step 5 · The replyExample, trimmed

It knows what to do. It can’t do it.

"text": "... I don't have a way to open files on your computer or system, so I can't tell you what's in it.", "stop_reason": "end_turn"

This is where most chatbots stop.

Step 6

Give it a tool

A name, a description and the arguments it takes.

The model reads the description to decide when to use it.

"system": "Look at files before ...","tools": [{  "name": "read_file",  "description": "Read a text file    and return its contents.",  "input_schema": {    "type": "object",    "properties": {      "path": {"type": "string"}},    "required": ["path"]}}],"messages": [ ...same question... ]

Step 6 · The replyExample, trimmed

The model asks. Nothing happens.

"content": [ {"type": "tool_use", "id": "toolu_01VE4tmo...", "name": "read_file", "input": {"path": "notes.txt"}} ], "stop_reason": "tool_use"

A tool request is just another block. The model proposes. You decide what happens next.

Step 7

Send back the result

Add its request to the history, then your result with the same id.

You are the code now. Nobody read a file. You wrote what it “contained.”

"system": ..., "tools": [ ...read_file... ],"messages": [  {"role": "user",   "content": "what is in notes.txt?"},  {"role": "assistant", "content": [    {"type": "tool_use", "id": "toolu_01",     "name": "read_file",     "input": {"path": "notes.txt"}}]},  {"role": "user", "content": [    {"type": "tool_result",     "tool_use_id": "toolu_01",     "content": "Rehearse the talk. Check       the Wi-Fi. Bring an HDMI adapter."}]}]

Step 7 · The replyExample, trimmed

It answers from what you sent

"text": "notes.txt is a short to-do list with three items: 1. Rehearse the talk. 2. Check the Wi-Fi. 3. Bring an HDMI adapter.", "stop_reason": "end_turn"

You just did one turn of the loop by hand. That’s what an agent is. It also believes whatever a tool returns.

Step 8

Say no

Same request. This time you decline instead of running the tool.

"messages": [  {"role": "user",   "content": "what is in notes.txt?"},  {"role": "assistant", "content": [    {"type": "tool_use", "id": "toolu_01",     "name": "read_file",     "input": {"path": "notes.txt"}}]},  {"role": "user", "content": [    {"type": "tool_result",     "tool_use_id": "toolu_01",     "content": "The user declined       to share this file."}]}]

Step 8 · The replyExample, trimmed

“No” is an answer it can work with

"text": "I couldn't read notes.txt because access to that file was declined, so I can't tell you what's in it."

A declined action isn’t an error. The step people skip, and the one that matters most.

What you just did

You were the loop

01Send the messages.
02Read stop_reason. If it’s end_turn, you’re done.
03If it’s tool_use, ask a person, then run the tool or say no.
04Add the request and the result to the messages. Go to 01.

Do that in code, with a limit on rounds, and you’ve built an agent.

Next

Let code do the pasting

The same four rules, in bash, with a real read_file.

curl/step1.sh to step8.sh build it up a few lines at a time. About 60 lines in all.

for ((i = 1; i <= 10; i++)); do  ask; remember  [ "$(stop_reason)" = tool_use ] || break  file=$(tool_arg path)  read -r -p "allow read_file $file? " ok  if [ "$ok" = y ]; then    read_file "$file" | answer  else    echo "The user declined." | answer  fidone

What you just built

Three things in one loop

1–4

A chatbot

It talks, remembers the conversation and follows instructions.

5–7

An agent

It asks for actions, reads the results and decides what to do next.

8

An agent with human approval

It stops, and a person approves what matters.

Autonomous execution, not autonomous approval.

Next · from AlwaysBuilt

Route before you loop

Not every request needs every tool, the longest instructions and the biggest model.

Add one small, cheap call first that decides what kind of request this is. Then run the same loop with only what that request needs.

kind=$(classify "$msg")   # one small call case "$kind" in  question) fresh read-only.json  ;;  change)   fresh read-write.json ;;esac # each file sets its own model,# tools and instructions# ...then the same loop

What AlwaysBuilt’s router taught me

The router is the easy part to get wrong

Route on what it is

Not on keywords

“Build a Jira clone with auth” went to the backend route on 26 of 26 turns, because of the word “auth.” No design guidance ever shipped. Each route now says what it’s for, what it’s not for, and gives examples.

Test it like code

Real requests are the test cases

Every misroute became a test. I changed the route descriptions until every case was classified correctly, and the tests keep it that way.

Rules go in code

The model classifies. Code decides.

Anything that changes the page gets at least the mid-tier model, whatever the classifier says. If the classifier is down, it says so instead of guessing.

Next: the same loop in Python

Same loop, real code

The messages you pastedbecome a list: messages = []
Each pastebecomes client.messages.create(...)
The result you wrotebecomes a tool_result your code appends
while True:    reply = client.messages.create(        model="claude-opus-5-5",        max_tokens=4096, tools=TOOLS,        messages=messages)    messages.append({"role": "assistant",                     "content": reply.content})    if reply.stop_reason != "tool_use":        break    messages.append(run_tools(reply))

Try it this week

Be the loop once

01Paste all eight. It takes ten minutes.
02In step 7, send back something untrue. Watch it believe you.
03Run step8.sh, and let code do the pasting on a real file.

An agent is a loop, a function and a human who says yes.

Start with “hello.” You’re eight pastes away.

fullstackclouddeveloper.com/talks/from-hello-to-agent

© 2026 Joseph Cava. Licensed under CC BY 4.0.

Speaker notes
WalkthroughCarousel