CHAPTER 17 · Building the Full Mini-Harness · 3 / 10
Step 1: the model seam
Everything depends on one function. This is the only place that talks to a real model, so it is the only place you change to go from toy to real.
# minharness/model.py
"""The single seam between the harness and a real model.
Swap the body of call_model for an Anthropic / OpenAI / local call.
It must return one of:
{"type": "text", "content": "..."} -> turn ends
{"type": "tool_calls", "calls": [{"call_id","name","args"}, ...]}
"""
def call_model(request: dict) -> dict:
# request has keys: instructions (str), tools (list), input (list) [Chapter 3]
#
# REAL VERSION (Anthropic example, pseudocode):
# resp = anthropic.messages.create(
# system=request["instructions"], tools=request["tools"],
# messages=to_messages(request["input"]), model="claude-sonnet-4-6")
# return parse(resp)
#
# For a runnable demo without an API key, we script a tiny behavior:
history = request["input"]
ran_tool = any(it.get("type") == "tool_result" for it in history)
if not ran_tool:
return {"type": "tool_calls", "calls": [
{"call_id": "c1", "name": "shell", "args": {"command": "ls"}}]}
return {"type": "text", "content": "Done. I listed the directory."}