Skip to main content
You’ve probably seen this recently: you ask an AI tool, “Write me a Python script that reads this log file and summarizes the errors.” Instead of only returning a code snippet, the tool writes the script, runs it, sees an error, fixes the code, and runs it again until the script works. The first time you see this it feels like magic — but it’s not. It’s the result of a layered stack that combines a model with software that gives it state, tools, and an execution loop. Below we walk through that stack and explain how the pieces fit together.

A concrete request that drives the stack

“Write me a Python script that summarizes the errors in this log file.” This simple request exposes the key responsibilities each layer must handle: generate code, run it, observe outputs and errors, iterate on fixes, and finally produce a reliable summary of the log errors.

What the model (LLM) can and cannot do

At the center of the stack is the model — the component people usually mean when they say “AI.” The model is a probabilistic text generator (tokens → tokens), so it can produce code, comments, and natural language. But by itself it has important limitations:
  • It predicts text; it does not keep long-lived goals or external state beyond the prompt and context window.
  • It cannot read local files or otherwise access your environment.
  • It cannot execute code or observe runtime errors.
  • It cannot decide to run external processes without being wrapped by software that provides that capability.
All the model can do is produce candidate outputs. To turn those outputs into working results, we need software around the model.

The harness: state, rules, and tool interfaces

The harness is the surrounding code that turns a raw model into a practical system. It provides:
  • Memory or a persistent goal store to track progress across steps.
  • Safety and behavior rules (e.g., restrict shell commands or network access).
  • A standardized interface that exposes tools (filesystem, shell, APIs) the model may call.
Think of the model as the engine and the harness as the rest of the car: the engine generates power, but the car (harness) provides steering, brakes, and an interface to the road.
Because harnesses may grant models access to sensitive resources (files, networks, shell), you should design and audit tool permissions carefully. Limit scopes, log tool calls, and require human review for risky actions.

The loop: how agents convert generation into action

The harness typically runs the model in a loop: generate → act → observe → update. That loop is what we call an agent. Example loop for the log-summarizing request:
  1. Model generates an initial summarize.py.
  2. Harness runs python summarize.py in a sandboxed environment.
  3. If the script errors, the harness collects stderr and feeds it back to the model.
  4. The model edits the script and returns a patched version.
  5. Repeat until the script runs successfully and produces a summary.
This write → run → check → fix iteration is what turns text generation into real-world outcomes.

Tools: the agent’s capabilities

An agent is only as capable as the tools the harness exposes. For the log-summary task, useful tools include:
  • Filesystem access (read the log file).
  • Shell or terminal to run scripts and commands.
  • Search or documentation lookup to find API usage or error explanations.
  • Web/API access to fetch external resources or metadata.
  • Specialized debuggers, linters, or IDE integrations.
During execution the agent selects a tool and issues tool calls (for example, “open file /var/log/app.log” or “run python summarize.py”). The tool returns output the model uses to plan the next step.
A presenter stands beside a lightboard diagram titled "The Modern AI Stack." The drawing shows an "Agent" containing "Harness" and "Model" and connected to tools labeled Search, BASH, and Web/APIs.

How the pieces fit together

One user request enters the system. Behind that single interaction, four layers collaborate to produce a working result: If you take away one idea: the model is the engine; the harness, loop, and tools are the car that let the engine do useful work in the real world.
Key takeaway: Models predict text. Harnesses provide memory, policies, and tool interfaces. Agents implement an execution loop that iterates on actions, and tools let agents interact with external systems to complete tasks end-to-end.

Practical notes and next steps

  • Design harnesses with least privilege: only expose the tools the model needs.
  • Log and monitor tool usage to allow auditing and rollback.
  • Use sandboxed environments for running generated code.
  • Consider human-in-the-loop checkpoints for high-risk operations.

Watch Video