TheFocus.AI TheFocus.AI
03 trajectories Lesson 7

Chapter 07: The Harness

Two hundred lines, one tool. Build the smallest possible agent loop and understand why behavior — not knowledge — is what you're training.

TUTOR WITH THEFOCUS.AI

Agent Integration

Copy this prompt into Claude, ChatGPT, or any external AI assistant. It points the assistant to the course instructions and links it to your student profile to track your progress and customize observations.

Please tutor me in this lesson using the following context. First, read the instructions at: https://courses.thefocus.ai/llms.txt My Student ID is: <none> The lesson markdown source is at: https://courses.thefocus.ai/fine-tune-local-agent/03-trajectories/07-the-harness.md

You are not enrolled yet. Enroll to generate a Student ID to track lesson completions and store learning notes.

Chapter 07: The Harness

Objective

Build the smallest possible agent harness, instrument it to record everything, and fine-tune the 1B model until it emits syntactically valid tool calls. Not smart ones. Valid ones.

The Insight This Part Exists For

You are not fine-tuning the model on your code. You are fine-tuning it on the shape of agentic behavior.

Codebase knowledge belongs in context, retrieved at runtime — bake it into weights and you retrain every time the code changes, and it hallucinates moved APIs anyway. What small models are actually bad at, and what is stably trainable, is the loop: take a task, emit a well-formed tool call, read the result, reason, call again, stop when done, report.

That behavior is learnable. That behavior is what we train.

The Harness

Two hundred lines. One tool.

read_file(path) -> string

The loop:

  1. System prompt describing the tool and the output protocol
  2. User task
  3. Model emits a tool call
  4. Harness parses, executes, appends result
  5. Repeat until the model emits a final answer or hits a step cap

Point it at the endpoint you stood up in Chapter 06 — anything speaking the OpenAI chat-completions API works, which is exactly why we built it that way.

Picking a Tool-Call Protocol

Use whatever protocol you like — a JSON block, an XML tag. Small models do better with simple, unambiguous delimiters than with elaborate schemas. You control the protocol; pick one you can parse with a regex and validate with a schema.

One rule that will save you later: the system prompt must be identical between training and inference. A mismatch here silently destroys everything downstream.


← Part 3 Index · Next: Chapter 08 →

Previous Lesson 7 of 16 Next