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