Shows the components of a PR review agent (findings tool, guardrailsThe checks around a model that block bad inputs and outputs — filters, validators, and permission rules the model itself can't override.Full definition →, audit hooks, guidelines file, two-pass false-positive filtering) so you can build one on an agent SDK instead of buying a review product.
Key takeaways · AI-distilled
The read-only guard is a beforeTool agent hookA script the harness runs automatically at a fixed point in an agent's loop — before a tool call, after an edit, on session start.Full definition → that skips editing tools outright and checks run_commands against a regex denylist (git push/commit, gh pr writes, gh api POST, sudo, curl piped to sh), returning a reason so the model can adjust.
Because run_commands input can arrive as a string, an array, or an object with command, commands, or cmd fields, the guard flattens every shape into a list of command strings before matching the denylist.
The posting step is deterministic code, not the AI agentAn AI system that doesn't just answer once but works toward a goal in a loop — taking actions, reading the results, and deciding what to do next.Full definition →: it sorts kept findings by severity and sends one batched GitHub review as a COMMENT event, dry run by default, falling back to a summary-only post if inline comments fall outside the diff hunk.
Findings and kept indices live in module-scope arrays, so the driver clears them before each run; otherwise a second run in the same process would still see the previous run's findings.
In the sample run with Kimi K3 via OpenRouter, the review pass cost about $0.083 and the judge pass about $0.053, with the judge keeping all 3 findings.
Terms in this piece · Glossary
AI agent — An AI system that doesn't just answer once but works toward a goal in a loop — taking actions, reading the results, and deciding what to do next.
guardrails — The checks around a model that block bad inputs and outputs — filters, validators, and permission rules the model itself can't override.
tool use — A model's ability to call external functions — run code, search the web, edit files — instead of only generating text.
agent hook — A script the harness runs automatically at a fixed point in an agent's loop — before a tool call, after an edit, on session start.