Unit 11: Agents and automated actions

32 min
DEVELOPMENT REVIEW DEPLOYMENT - NOT READY FOR RELEASE

Video

Media Pending: Unit Video

Intended content: Full narrated video presentation, including visual assets, caption file, and transcript.

Learning purpose: Establish that the single thing which changes when a system acts is that

Planned form & duration: Video, ~6 minutes.

Accessible text alternative: Move an action into a reversible band before the run, rather The written material below covers the same complete learning path.

Watch what changes

An agent trace printing one line at a time: plan, call, result, plan, call, result, report. Once the whole run is visible each line is labelled for what it is worth — the plans and the final report as generated, the results as records, the tool calls as checkable. Two of them are boxed as places a check goes: the arguments before a call, and the result rather than the exit status. A third line is then added below the trace, marked as yours rather than the agent's — reading the file back to see whether the world is as intended, which the run never does.

Reading time: about 12 minutes. Activity: about 14 minutes.

What changes

Everything so far has been about an answer: something you read, check, and then either use or discard. Discarding is cheap, and it is the reason the whole method works. You can take as long as you like over a claim, because until you act on it, nothing has happened.

An agent is a system that acts. It calls tools in a loop — plan, act, look at the result, act again, and some of those actions change something outside the conversation. A file is written. A message is sent. A row is deleted. A booking is made.

The method does not change. What changes is one thing, and everything in this unit follows from it:

An action can change the world before you have looked at it.

Some actions are cheap to take back — a draft, a preview, a file in your own bin. Some are not, and a few cannot be taken back at all. The next section separates those, because the difference decides how much checking has to happen before rather than after.

Checking after the fact is still worth doing, because you need to know what happened. But it is no longer verification in the sense the rest of this module uses: it cannot prevent the error, only describe it, and what it leaves you is a remedy rather than a correction.

The loop, and where you are in it

A single-shot answer has one place a check can go: after the output, before you use it. An agent run has many, and by default you are in none of them.

A typical run:

  1. The system produces a plan. This is generated text.
  2. It selects a tool and arguments. This selection is generated.
  3. The tool executes, under its own semantics and against the state of the world at that moment.
  4. A result is recorded.
  5. The system reads the result and decides what to do next. Generated.
  6. Repeat, possibly many times.
  7. It reports what it did. This report is generated text about the run.

Step 3 is not the safe step. It is tempting to say that the generated parts are the risky ones and the tool merely does as it is told, but that is only true of a tool with no outside world in it — a calculator, say. Most tools have one. A search returns what the index holds today. A file operation depends on what is on disk, on permissions, and on what else is writing at the same time. A network call can time out, half-finish, or succeed after the system has given up waiting. A tool can carry its own bug. And a tool can do exactly what it was told while doing the wrong thing, because what it was told came from step 2.

So there are three distinct places a run goes wrong, and they need different checks:

Where What goes wrong What checks it
Selection (step 2) The right tool with the wrong arguments; the wrong tool Read the arguments before the call, or approve them
Execution (step 3) Timeout, partial write, stale data, permission failure, a bug Look at the result, not just the exit status
Postcondition (step 4) The call reported success and the world is not as intended Read back the state: a diff, a re-read, a receipt

ok is a claim about a call, not about the world. A write that returns success may have written to the wrong path; a delete that returns success may have matched nothing. The check for step 4 is to look at what is actually there afterwards.

This is Unit 4's tool-calling split, run repeatedly, with the consequences compounding: an error at step 2 produces a result at step 3 that the system then reasons from at step 5.

Reversibility is the axis

Unit 3 sorted outputs by what kind of check they need. For actions, that is the wrong first question. The first question is:

If this is wrong, can it be undone, by whom, and at what cost?

Four rough bands, and they are not about how likely an error is:

Band Example What it changes
Free to undo A draft file written to your own machine Check afterwards; the loop is fine unattended
Undoable with effort A commit, a scheduled job, a change to a shared document Check afterwards, but budget for the undo
Undoable only by someone else A message sent, a form submitted, a ticket raised Confirm before, because the remedy is somebody's time
Not undoable A payment, a deletion without backup, anything a third party has now seen Confirm before, every time, without exception

"Undo" is doing a lot of work in that table, and it is worth separating four things it can mean, because they cost different amounts:

A message sent to the wrong person is not undoable and is usually correctable. A disclosure of someone else's personal data is neither, and containment is all there is. Ask which of the four you would actually be reaching for.

Note what is missing from that table: any assessment of how reliable the system is. That is deliberate. Reliability changes how often you will need the remedy; it does not change what the remedy costs. Repeat a bottom-row action often enough with a system that is usually right, and the question stops being whether an unrecoverable error is likely on this run and becomes whether you are willing to carry one at all. How soon depends on the error rate and on whether the failures are independent, neither of which you know, which is the point. You are choosing an exposure, not calculating a date.

What a trace does and does not tell you

Agent products commonly show you a trace: the plan, the tool calls, the results, the summary. Read it — it is far more than a single-shot answer gives you.

Then keep two distinctions.

The tool calls and their results are records — if what you are reading is the system's own log. A call was made with these arguments and returned this. That is an artefact of what happened, and it is the most checkable thing in the run.

That "if" matters, because three different things can look identical on screen:

What you are looking at What it is worth
The execution log the system wrote as it ran A record. This is the evidence.
A chat window's rendering of the calls Usually faithful, but it is a display: it may condense, reorder or omit
The system's account of what it did Generated text, like any other

The third is the one to watch, because it is written in the same voice as the first. If you cannot tell which you have, that is worth finding out before you rely on it: a product's documentation says whether it shows you the log or a summary of it.

The plan and the summary are generated text about the run. They can be accurate. They are not a transcript, and a summary can describe a run that did not happen that way, not by deception, which would require intent, but because the summary is produced by the same process as everything else and nothing checks it against the log.

So: check the tool calls, not the narration. If a report says "I checked the existing entries before adding the new one", the question is whether a call that would have done that appears in the trace.

And note what is often missing. Intermediate steps may be summarised or hidden; a long run may show you a condensed version. The absence of a step from a displayed trace is not evidence that it did not happen, and its presence in a summary is not evidence that it did.

A worked trace, with the checkable points marked

The task: "Find the duplicate entries in my references file and remove them."

[1] PLAN    "I will read the file, identify duplicates by title,
             and delete the later occurrence of each."   <- generated
[2] CALL    read_file("references.bib")                  <- checkable
[3] RESULT  412 lines returned                           <- record
[4] PLAN    "I found 6 duplicate titles."                <- generated
[5] CALL    write_file("references.bib", 380 lines)      <- checkable
[6] RESULT  ok                                           <- record
[7] REPORT  "Removed 6 duplicate entries."               <- generated

Six things are worth checking, and they are not evenly important.

The right intervention is not more scrutiny at step 7. It is a copy of the file before step 5, which converts the bottom row of the table into the top row, and is the single most useful habit in this unit.

Working with agents, practically

Move actions up the table before you start. Work on a copy. Use a branch. Send to yourself first. Almost every irreversible action has a reversible rehearsal, and arranging one is cheaper than checking carefully.

Bound the run. A loop with a stopping condition you set is a different object from one that runs until it decides it is finished. Say how many steps, which tools, and what it must not touch.

Ask for the plan before the actions. Approving a plan is not verification, and it will not catch an error at step 4. But it catches the wrong-file class of error at the point where it is still free.

Give it the least it needs. An agent can only do what its credentials and its tool list allow. A key that can read but not write, a tool list without the destructive operation, a path or domain it is confined to — each of these turns a class of bottom-row action into one that cannot happen at all. This is worth more than any amount of checking, because it removes the possibility rather than detecting the result.

Ask for a dry run. Many operations have a mode that reports what they would do without doing it. Where one exists, the run becomes free to undo.

Check the calls, not the story. Every time.

None of which is an argument against agents. They do real work, and much of it sits in the top two rows of the table, where letting the loop run unattended is exactly right. Nor is a trace worthless — it is the most inspectable thing any of these systems gives you, which is why it is worth learning to read. The claim is narrower: the record part is evidence, the narration part is not, and the two arrive looking identical.

Summary

Then answer cp11-reversibility and cp11-trace-evidence at the foot of this page.

Timings: video 6 min, reading 12 min, activity 14 min.

Check yourself

This unit has 2 checkpoints, answered here. A wrong answer says which misunderstanding it matches. Nothing is uploaded.

Local progress is available in a supported browser.

Manage or delete this record

Prefer a terminal?

The same questions, from course/lab/:

python3 selfcheck.py run --unit 11

Your progress, and every checkpoint in the module