← Table of Contents · Page 668 of 868
PROJECT ONE - A MINIMAL HARNESS
Part 6 of 11
EXAMPLES
Example 1: The core loop in about fifty lines.
A learner who wants to see the idea with nothing else in the way writes a bare loop of roughly fifty lines.
It calls the model, checks whether the reply asks for a tool, runs the tool and appends the result if so, and repeats until the model says it is done or a step limit is hit.
Nothing in it is clever, which is the point, because this is the smallest thing that deserves the name agent.
The main_loop.py file in this chapter is that same skeleton with logging and error handling wrapped around it.
Example 2: A first registry with two tools.
Before building the lab, a learner might practice in a scratch folder named project_files with a registry holding just read_file and list_directory.
Each tool has a simple name, a one-sentence description, and a handler function, and nothing more.
Keeping the first registry this small makes it easy to see that a registry is only a dictionary of names pointing to functions.
The lab version simply uses three tools instead of two.
Example 3: A single hard-coded permission rule.
The same learner writes one rule, which is that reading is allowed only inside the project_files folder, and enforces it before every read_file call.
Then the learner asks for a path that climbs out with two dots and watches the gate refuse.
In the lab the same idea appears as permission_gate.py, which guards the resumes and reports folders instead.
Example 4: The first observed run.
The learner asks the practice agent what files are in the project.
The agent calls the listing tool once, reads two files, and produces a correct summary.
It is a small result, but it is a satisfying milestone, because every later chapter is built on this loop working.
In the lab your equivalent milestone is the moment five correct reports appear in the reports folder.
Advertisement
Read Aloud:
0:00 / 0:00