Build & Deploy AI Agents

Exercise 2

Build: Tools & AI

Add fetchPullRequest, reviewDiff, Workers AI, and AI Gateway.

Build Module 2 on top of your Module 1 work (or checkpoint-1-foundations).

The goal

REVIEWBOT should look at real code and form an opinion:

  • a fetchPullRequest tool that pulls and noise-filters a PR diff,
  • a reviewDiff tool that sends the diff to a model on Workers AI and parses structured findings,
  • both routed through AI Gateway via AI_GATEWAY_ID.

Getting started

Have your agent scaffold the tools. Remember each tool needs a description, a Zod inputSchema, and an execute. Then register them in the tools map inside onChatMessage, or the model cannot see them.

Watch out

  • Unauthenticated GitHub is limited to 60 requests/hour. Set a GITHUB_TOKEN secret to raise it.

Stuck?

git checkout checkpoint-2-tools-ai -- src/

Done when

  • REVIEWBOT fetches a real public PR and returns a structured finding with a file reference.
  • You can explain the three parts of a tool.