Build & Deploy AI Agents

Exercise 4

Build: HITL & Scheduling

Add an approval gate before posting, and scheduled rechecks.

Build Module 4 on top of your Module 3 work (or checkpoint-3-workflows).

The goal

Make REVIEWBOT deliberate:

  • postReview flips a review to posted, but only after human approval,
  • scheduleRecheck wakes the agent later to re-review a PR.

Approval gate

Add postReview as a tool with needsApproval returning true. The chat will render Approve / Reject before execute runs. Guard it so only a ready review can be posted, and have it call patchReview(id, { status: "posted" }).

Scheduled recheck

Add scheduleRecheck, which calls this.schedule(delaySeconds, "recheckReview", reviewId). Implement recheckReview on the agent to re-create the ReviewWorkflow. Broadcast status to the UI rather than injecting a chat message.

Stuck?

git checkout checkpoint-4-hitl-schedule -- src/

Done when

  • “Post it” shows an approve/reject prompt, and approving flips the status to posted.
  • “Check this PR again in 30 seconds” schedules a recheck that fires.
  • You can explain why scheduling survives hibernation (Durable Object alarm + SQL, no compute while waiting).