AI Agents

Build an AI Agent From Scratch

Build a working AI agent from bare HTTP calls - no frameworks, no SDKs. You write the loop that lets a model use tools, make its output machine-readable, stream it live, and keep it alive when providers fail. Finish and you have an agent you built entirely yourself - and nothing inside LangChain will ever look like magic again.

linux-cliLinux CLI
Read the AI Agents overview
Module 1

Tool Calling & Agent Loop

The heart of every agent: the loop that sends messages, runs the tools the model asks for, and feeds results back until an answer. You build it piece by piece - dispatch that survives malformed calls, assembly of streamed fragments, a guard against endless loops, parallel execution - then prove it on hidden tasks against a live model.

6
About this challenge

Build the agent loop that runs the tools the model asks for until it answers.

About this challenge

Build the dispatcher that turns bad tool calls into error results instead of crashes.

About this challenge

Assemble complete tool calls from streamed fragments before anything runs.

About this challenge

Add the stop conditions that end a conversation the model never would.

About this challenge

Run a turn's tool calls in parallel so one hanging tool cannot stall the rest.

About this challenge

Run your full agent against a live model on unseen multi tool tasks.

Module 2

Structured Output

The bridge from model text to data your system trusts: a schema that rejects junk with errors the model can act on, a cleaner that strips fences and stray commas without touching the payload, a repair loop that feeds validation errors back until the output is valid, and a salvager that recovers what truly arrived when a stream dies - then prove the full stack extracting real documents against a live model.

5
About this challenge

Define the record schema and the validator that keeps junk out of the database.

About this challenge

Clean fenced, comma broken model responses into parseable JSON.

About this challenge

Feed validation errors back to the model until its output passes.

About this challenge

Recover every complete field from JSON cut off mid stream.

About this challenge

Run your full extraction stack on real documents against a live model.

Module 3

Streaming Agents

The pipe that makes tokens appear live: an SSE gateway between the model's messy stream and the user's browser. You build it failure by failure - framing the browser actually accepts, text flowing while tool calls assemble, multibyte characters split across chunks, upstream deaths turned into clean error frames, reconnects that resume from the right word - then compose it all into one drop-proof gateway.

6
About this challenge

Build the endpoint that streams tokens to the browser as they are generated.

About this challenge

Stream text to the user while assembling tool calls from the same stream.

About this challenge

Handle multibyte characters split across network chunks so every script renders clean.

About this challenge

Turn an upstream failure into a clean error message instead of a spinner.

About this challenge

Let a dropped client reconnect and continue from the exact word it left off.

About this challenge

Compose everything into one gateway that survives splits, failures, and disconnects.

Module 4

Resilience & Rate Limiting

What separates a demo from a product: the client that survives the provider's worst day. You build it policy by policy - retry with backoff and jitter, timeouts that cut hangs, recovery of streams that die mid-answer, a circuit breaker that stops hammering a dead endpoint, fallback to a secondary without ever billing twice - then run it all against a scripted storm.

6
About this challenge

Retry rate limited requests with exponential backoff and jitter instead of failing the user.

About this challenge

Bound every request with a timeout so hangs become clean, retryable failures instead of stalls.

About this challenge

Stop hammering a dead provider: open a breaker on a failure burst and probe it back closed.

About this challenge

Serve requests from the secondary provider when the primary fails, without ever billing twice.

About this challenge

Detect responses cut off mid stream and retry them instead of delivering half an answer.

About this challenge

One resilient client against a scripted bad day: rate limits, hangs, a 500 storm, an outage, and dying streams, with every request billed exactly once.

About this path

This path has you build an AI agent from plain HTTP calls, without a framework or SDK: the tool-calling loop, structured output, streaming, and resilience. You should be comfortable writing code that sends HTTP requests and handles JSON. No earlier experience with agents or LLM APIs is needed. The resilience module keeps your agent running when a provider fails, with retries, timeouts, a circuit breaker and a fallback provider.

From the blog

1
Model Context Protocol Update: Stateless MCP Is HereModel Context Protocol’s latest update replaces session-bound transport with a stateless core, MRTR, routing headers, and sharper migration boundaries.

Frequently asked questions

4

What will I practice in this path?

4 modules: Tool Calling & Agent Loop, Structured Output, Streaming Agents and Resilience & Rate Limiting.

How many challenges are there, and how hard are they?

23 challenges, all easy.

What does this path run on?

Challenges run on Linux CLI.

Do I need to install anything?

No. Every challenge runs in a browser-based IDE with everything already set up, and your code is graded automatically against a test suite.

We use cookies that are necessary to run Staffcoder, and optional analytics cookies to see which pages get used. Analytics stays off unless you accept. Read our Cookie Policy.