The Agency debugger
Still a work in progress
Agency has a very good built-in debugger. Lets try using it. Put the following code in a file called test.agency:
ts
node main() {
const name = "world"
const greeting = llm("Say hello to ${name}!")
print(greeting)
}and then invoke the debugger using
agency debug test.agencyHere are some things you may want to do with the debugger:
- Step forward: Press
sor the down arrow. - Continue until you hit a
debuggerstatement: Presscorspace. - Rewind or step backwards: Press the up arrow, or press
rto see a list of checkpoints. Press up/down to scroll and you'll see the line each checkpoint is for. - Override the value of a variable: Enter
:set varName=newValue. Then when you presss, the next statement will execute with the variable's value overwritten. - Cycle between all the different panels:
tabandshift+tab. Once a panel has focus, you can press the up or down arrow keys to scroll, or presszto zoom, temporarily making that panel full screen. - In the threads panel, you can press
[or]to cycle between the different threads.
Options
--node <name>— node to execute (defaults tomain).--rewind-size <n>— size of the rolling checkpoint window. Defaults to 30. Larger values let you rewind further at the cost of memory.--trace <file>— load and inspect an existing.tracefile instead of running the program live.--checkpoint <file>— load a saved checkpoint file and start the debugger from that point.--dist-dir <dir>— import pre-compiled JS from this directory instead of compiling the.agencyfile on the fly. Useful when you've already built your project and want to skip the compile step.