Chapter 4: Reading and debugging

That is enough to read most of what you'll meet. Now for finding things out, starting with the oldest tool there is.

Logging

Also called Print debugging

Making the program write down what it is doing as it runs, with something like console.log. It lets you see inside a run without stopping it, and what comes back is evidence, not a theory about what happened.

Logging suits agents better than almost any other debugging tool, because an agent works by running a command and reading the output. When one starts theorising about a bug, tell it to add logs and report what they said. Then make sure it takes them out.

Say it to your agent

“Don't guess yet. Add a labelled console.log at each step of calculateTotal, printing the values. Run it on the failing input, paste the output, and tell me the first line where a value is wrong. Then remove the logs.”

The workshop

Name a word, or describe what you mean in everyday language.