# Agent loops

> Every coding agent is the same small machine: a model, a set of tools, and a loop that runs until the job is done

The model never touches your filesystem; it can only emit text and read what
comes back. Some of that text is tool calls --- requests the harness carries out
on its behalf: read this file, apply this edit, run this command. Remember that
mechanism. Nearly everything covered in the course concerns the loop: what
enters it, and which checks reject bad output.

The tool set isn't mysterious, either --- you can just ask:

```
$ claude -p "list the tools you have available, one per line,
  as 'Name --- one-line description'. no preamble"
Bash --- Execute a shell command, with optional background execution
Edit --- Perform an exact string replacement in a file you've already read
Read --- Read a file from the local filesystem (text, images, PDFs, notebooks)
Write --- Write a file to the local filesystem, overwriting if it exists
Agent --- Launch a subagent to handle complex, multi-step tasks
Skill --- Invoke a packaged skill (slash command) by name
WebFetch --- Fetch and process the contents of a URL
...
```

That's an abridged snapshot, and yours will differ across releases and installed
plugins. Ask your agent for its current tool list. The loop consists of these
basic operations: reading and writing files, then running commands.

## Read, edit, run

Take a small task you might actually hand over: "make the headings bigger and
the font purple". Here is what happens, turn by turn.

The agent starts by **reading**. Nothing about your repo is in the model's
training data, so its first moves are searches and file reads: find the
headings, work out where they get their size and colour. Each result is appended
to the conversation, and that growing transcript is the agent's entire working
memory of your project. What fills it, and in what order, matters enough to get
its own week later in the course.

Then it **edits**: the model proposes a change, and the harness applies it to
the file on disk. That division of labour matters. The "agent" editing your repo
is really the harness, acting at the model's request. The harness also enforces
permissions. It can require your sign-off before any write or shell command;
Claude Code requires that sign-off by default.

Then it **runs** something: the dev server, the build, the test suite. This is
the step that separates an agent from autocomplete, because the output indicates
whether the edit worked. A failing build or headings still rendering stubbornly
black are recorded in the transcript. The agent can then read the error, edit
the file and run the check again.

The loop stops when the model decides the job is done. That is a claim, not a
fact. The agent saying "done!" and the headings actually being bigger and purple
are different events. Much of this course is about checking the claim.

## Model vs harness

Two words you'll use all semester. The **model** is the thing that generates:
weights on someone else's GPU[^local-models], turning a context window into the
next chunk of text. The **harness** is everything else: the tools, the system
prompt, what makes it into context, the permission rules, and the loop itself.

Claude Code, the studio's default, is a polished harness tied largely to one
vendor's models. [pi](https://github.com/badlogic/pi-mono) takes a different
approach to the same mechanism: deliberately minimal and model-agnostic, with a
codebase you can actually read. You're not being told to switch --- pi is one
alternative among many, and the
[tool catalogue](https://comp.anu.edu.au/courses/comp4020-agentic-coding-studio/topics/agentic-tool-catalogue/) has the fuller tour. It's
named because comparing two harnesses makes the distinction clear: they offer
many of the same models but behave differently.

The distinction becomes clearer the first time an agent does something dumb in
your repo. The reflex is to blame the model, and sometimes the model really is
the problem. But on any given afternoon the model is fixed, and the harness is
yours. Check what context the agent had, which tools were available and which
checks reported errors. These are harness questions with concrete answers.
Asking them is part of moving beyond vibecoding.

Both halves of that phrase belong to the field rather than to this course.
Andrej Karpathy named **vibe coding** in February 2025 --- prompt, accept, run,
see whether it works, without reading what came back --- and a year later
nominated **agentic engineering** for its disciplined opposite: people using the
same tools to amplify expertise they already have. Simon Willison's
[Agentic Engineering Patterns](https://simonwillison.net/guides/agentic-engineering-patterns/)
is built on that pair, and he has since written that the two are getting closer
than he would like, because what separates them is daily discipline rather than
tooling. Vibe coding is a perfectly good way to build something only you will
ever run. This course teaches agentic engineering.

## Where feedback enters

Look back at the loop and notice where evidence enters: **run**. Reading and
editing change the repository; running a check produces an exit code, a type
error, a failing test, or a rendered page. Each check result adds evidence to
the transcript. Fast, specific feedback usually improves the agent's work.

Give the agent a check it can run. "Make `pnpm test` pass" gives every turn a
verdict; "improve the code" provides no testable criterion, so the model must
rely on its own confidence. Week 3's [backpressure topic](https://comp.anu.edu.au/courses/comp4020-agentic-coding-studio/topics/backpressure/)
covers how to design this feedback. For now, watch which turns produce evidence
and which rely on confidence alone.

[^local-models]:
    Or, increasingly, on your own hardware: open-weight models you can run
    locally are real and improving fast. They're outside this course's scope ---
    the studio runs on hosted frontier models --- but the same loop and harness
    principles apply if you swap one in.

Source: <https://comp.anu.edu.au/courses/comp4020-agentic-coding-studio/topics/agent-loops/>\
Licence: [CC-BY-NC-SA-4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/)\
Cite as: Swift, B. (2026). _COMP4020/COMP8020 Agentic Coding Studio_ [Course materials]. ANU School of Computing. https://doi.org/10.5281/zenodo.21395760
