Let a language model call your functions to get real work done: tool calling, the agent loop, well-designed tools, memory and planning, the Model Context Protocol (MCP), and the safety rules that keep an agent from doing harm.
ជំពូកនេះមិនទាន់ត្រូវបានបកប្រែជាភាសាខ្មែរនៅឡើយទេ — សូមអានជាភាសាអង់គ្លេសខាងក្រោម។
A chatbot talks. An agent acts. Give a language model a set of tools (functions you wrote: look up a record, read a file, send a message, run a query) and let it decide which tool to call, read the result, and decide what to do next. Repeat until the job is done. That loop is what people mean by an AI agent, and it is the idea behind coding assistants, support bots that can really issue a refund, and assistants that work across your calendar and files.
This series teaches the idea from the inside. You will learn how a model asks for a tool call (it never runs anything itself; your code does), how to write the agent loop with step limits and a trace you can read, how to design tools a model can use reliably, and how agents keep notes and plan longer tasks. Then you meet the Model Context Protocol (MCP), an open standard that lets one tool server work with many agents and applications. You will build a tiny MCP server and client yourself, over the same plain messages the real ones use, and connect an agent to it.
Because an agent can act, safety is half of this series. You will see, safely and on your own machine, how text hidden inside a tool result can hijack a gullible model (prompt injection), why a file tool must be locked inside a folder, why risky actions need a human to approve them, and why untrusted tools should run in a sandbox. That is where this series connects to Docker Sandboxes Crash Course.
You build agentlab: a tool registry, an agent loop, an MCP server
and client, guards and a test harness, with zero dependencies. It runs
against a mock model that supports tool calling (including a sloppy
one that sends broken JSON and a gullible one for the security demos),
so everything is free and works without an account or API key. The mock
follows simple rules and is not intelligent, and the chapters say so
plainly; real models choose tools far better, but the messages, the
loop, the protocol and the risks are the same.
You should have finished Build a Chatbot with an LLM API, and it helps to have read RAG: Chat with Your Own Documents and the prompt-injection section of How LLMs Work. You need Node.js (the LTS version) and a code editor.
A final project chapter puts it all together: a shop assistant for a small business that checks stock, looks up orders and drafts replies, and can issue a refund only with a person's approval, a cap and an audit log. It doubles as a 45-minute workshop plan.
Every chapter ends with Quick Review: Common Questions: short, honest answers to what students and developers most often ask about agents.