Skip to main content

อ่านภาษาไทย

agentpath

Learn how AI agents actually work by building a real one, from a single LLM call to a full agent harness.

Who this is for

You can program a little. You have never built anything with a language model, or you have used one through a framework and never understood what it was doing underneath. You do not need to know any machine learning. There is no maths in this course.

Why this exists

There are many tutorials that show you an agent loop. Almost all of them stop there. The tools people actually use every day, such as Claude Code and OpenHands, are not agent loops. They are harnesses, which means an agent loop surrounded by permission checks, saved sessions, context management, error recovery and a plugin protocol. Almost nobody teaches you to build that part.

This course goes all the way. You start by sending one HTTP request to a model and you finish with a harness you could actually use.

Every chapter also has a Thai version, which is rare for material at this depth.

What you will build

Part What it adds Status
1 Foundations An agent that streams, calls tools, loops until the work is done, and can switch model providers Available now
2 Real Tools File reading and editing, running shell commands, searching code, and a small coding agent that works Available now
3 The Harness Permissions, saved sessions, context management, token economy, retrieval, error recovery Available now
4 Advanced An MCP client, subagents, multi agent patterns, evaluation and model choice Available now

All four parts are finished, so the course is complete at 24 chapters.

Quickstart

Install uv, which is the Python installer and environment manager this course uses.

curl -LsSf https://astral.sh/uv/install.sh | sh

On Windows use PowerShell instead.

powershell -c "irm https://astral.sh/uv/install.ps1 | iex"

Then clone the repository and open the first chapter.

git clone https://github.com/Patchanon04/agentpath.git
cd agentpath

Now read lessons/00-setup/README.md. It walks you through choosing where your model runs, which can be free and local if you want, and setting the three environment variables the whole course uses.

The lessons

Lesson What you build
00 setup A working environment and a model you can reach
01 first LLM call One HTTP request to a model, with nothing hiding the wire
02 conversation loop A chat that remembers, and the discovery that models remember nothing
03 tool calling The model asks for a function and you decide whether to run it
04 agent loop Your first real agent, looping until the work is done
05 streaming Answers that appear as they are written, including the hard part where tool arguments arrive in fragments
06 provider abstraction One agent loop that works with two completely different APIs
07 file tools Reading and editing real files, with one gate deciding what may be touched
08 shell tool Running commands, and asking a person first
09 search tools Finding files and text, and why this beats a vector database for code
10 anatomy of a prompt The three places your words reach the model, including the one everyone forgets
11 mini coding agent Everything wired together into an agent that fixes a real bug
12 permissions A gate that remembers your answer, so it does not train you to stop reading it
13 sessions The conversation on disk, which is also the best debugging tool you have
14 context management Trimming a conversation without stranding a tool result, which is the trap everyone hits
15 token economy Why the same conversation costs more every turn, and what actually reduces it
16 retrieval Four questions that tell you whether you need RAG at all, and usually you do not
17 errors and retries Surviving rate limits, stuck models, and a person who changes their mind
18 the harness Everything wired together into a tool you could actually use
19 MCP client Using tools somebody else wrote, and what they cost you on every request
20 subagents Delegating a job to another agent, and the stale view that comes with it
21 multi agent Running several agents at once without their output turning to noise
22 evals Measuring whether a change helped, and choosing a model by evidence
23 ship it Packaging it, publishing it, and what to build next

Using the finished framework

Everything the course builds also ships as a package, so you can install the finished version and read it as a reference.

pip install agentpath-kit

The distribution is called agentpath-kit and the package it installs is called agentpath, so you install one name and import the other. That is not a typo. PyPI refused the bare name because an abandoned package called agent_path is close enough to it to be confusing, and splitting the two names is the ordinary answer, the same one that has you install scikit-learn and import sklearn. Installing plain agentpath gets you somebody else's empty template, so the hyphen matters.

export AGENTPATH_BASE_URL=http://localhost:11434/v1
export AGENTPATH_MODEL=qwen3
agentpath chat

The command now has four subcommands. chat is an interactive session, run does one task and exits, resume carries on from a session you saved earlier, and eval runs a file of tasks and reports which ones passed. An MCP server can be connected with --mcp, so the agent can use tools you did not write.

Using it as a library

The command line is one caller among several. run is a generator that yields events as they happen, so the loop below is the whole integration.

import os

from agentpath import Agent, OpenAICompatProvider, TextDelta, TurnDone, file_tools
from agentpath.tools.base import ToolRegistry

agent = Agent(
    provider=OpenAICompatProvider(),
    tools=ToolRegistry(file_tools(os.getcwd())),
)

for event in agent.run("Summarise what this project does, in two sentences."):
    if isinstance(event, TextDelta):
        print(event.text, end="", flush=True)
    elif isinstance(event, TurnDone):
        print()

agent.run yields four kinds of event. TextDelta is a piece of the reply as it arrives, ToolCallRequest says a tool is about to run, ToolResult carries what it returned, and TurnDone means the turn is over. Ignoring an event you do not care about is the normal thing to do, which is why the loop above only names two of them.

Everything above is also importable from the module it lives in, and the deeper path is the better one to read. from agentpath.tools.base import ToolRegistry tells you where a thing is, and the chapters build the layout in that order for a reason.

The book

The chapters teach you to build it. There is also a book that explains why it is built that way, and how to think when you want to design your own. It is written in Thai, with the technical terms kept in English.

book/ has eleven chapters in two parts. The first seven are the theory behind the course. The last four are about taking an idea and working out what to build, with a long worked example of a LINE health assistant and three shorter ones that reach different answers.

How this repository is laid out

lessons/ holds one folder per chapter. Each folder is self contained, so you can open any chapter and run its code without having done the others. The code is duplicated between chapters on purpose, because a course where chapter four silently depends on an edit you made in chapter two is a course people abandon.

src/agentpath/ holds the finished framework, which is the same ideas written once and properly, with tests.

ci/ holds the script that runs every chapter check and the prose style check. The fake model server it runs against lives in src/agentpath/testing/.

docs/ holds the design document, the implementation plans and the topic ideas kept back for a second version.

Running the checks yourself

Every chapter has a check.py that proves the code you wrote actually works. You can run all of them at once against a fake model server, which costs nothing and needs no API key.

uv pip install -e ".[dev]"
python ci/run_lessons.py

This is the same script the project runs in continuous integration, so if it passes for you it passes for everyone.

Contributing

Issues and pull requests are welcome. Two rules matter more than the rest.

The course is frozen at 24 chapters. New topic ideas belong in docs/v2-ideas.md, not in a new chapter. If you want to add a chapter you have to argue for removing one.

Prose has a house style. No em dash, no emoji, and no colon in ordinary sentences. A check in continuous integration enforces the first two.

License

MIT. See LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agentpath_kit-1.0.6.tar.gz (48.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agentpath_kit-1.0.6-py3-none-any.whl (59.7 kB view details)

Uploaded Python 3

File details

Details for the file agentpath_kit-1.0.6.tar.gz.

File metadata

  • Download URL: agentpath_kit-1.0.6.tar.gz
  • Upload date:
  • Size: 48.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for agentpath_kit-1.0.6.tar.gz
Algorithm Hash digest
SHA256 d4aa4dcd55b64b7b102bc9e49a8fecd362f73d862ad96912a89ee1a5ccb41f52
MD5 6b046e4264bdfb29f99887a83eeee631
BLAKE2b-256 e4f6b5559df9352ecbd1e7130704f295c9e250672bfe3315deaaaaef60ded60f

See more details on using hashes here.

Provenance

The following attestation bundles were made for agentpath_kit-1.0.6.tar.gz:

Publisher: publish.yml on Patchanon04/agentpath

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file agentpath_kit-1.0.6-py3-none-any.whl.

File metadata

  • Download URL: agentpath_kit-1.0.6-py3-none-any.whl
  • Upload date:
  • Size: 59.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for agentpath_kit-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 78df799e55e57f355b465b2f27884baea92172be2d07ca9f9e93afe960648866
MD5 ed3097ad8bc6d46242d4028fc87c815c
BLAKE2b-256 7dcf3ed4bba7c2c58cbc860254896b3a7d6f4ea729d94a9ac876a0b77655eb84

See more details on using hashes here.

Provenance

The following attestation bundles were made for agentpath_kit-1.0.6-py3-none-any.whl:

Publisher: publish.yml on Patchanon04/agentpath

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

1.0.7

2 files

This release

1.0.6 This release

2 files

1.0.5

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page