One agent run, two invocations
Step through
Invocation 1
process
1
user submits task
2
agent loop runs
3
ask_user fires
4
serialize messages
5
process exits
write
pause state
in PostgreSQL
messages
pending tool_use_id
question
options
read
Invocation 2
process
1
user responds
2
restore messages, append answer as tool_result
3
agent loop resumes
4
task completes
5
process exits
The agent loop isn’t a long-lived process — it’s a series of short function invocations separated by checkpoints in the database.