Skip to main content
The Pull Request Reviewer example reviews a GitHub pull request on demand. The agent fetches the PR metadata and diff through a declared GitHub connection, reviews the change for correctness, and returns the review as session output. When the request explicitly asks, it posts a COMMENT review: a verdict plus findings, with inline comments anchored to diff lines:
An inline review comment anchored to a diff line, posted by the agent with a code suggestion

Structure

The agent function (opencomputer/agents/pr-review/agent.ts) is a synchronous render, called before every model step. It reads the current input and selects the instructions and tool set for that step. The write tool is attached only when the request asks for a live post:
There is no separate permission layer: dry-run-by-default is one if statement, and a tool the render does not select does not exist for that model step. The tools module (opencomputer/agents/pr-review/tools/github-tools.ts) declares one HTTP connection and three typed tools that use it. get_pull_request and get_diff read; post_review writes one COMMENT review and falls back to summary-only when GitHub rejects an inline anchor:
The connection defines all outbound access: tools call github.fetch("/repos/…"), and the platform validates origin, method, and path prefix before attaching the token at its outbound edge. The token never enters the agent runtime, so a prompt-injected model step cannot read or exfiltrate it. See Secrets and runtime variables. The managed runtime provides the rest: the durable session and turn queue, the model/tool loop that calls the render before each step, and deployments. npm run deploy -- --watch builds an immutable content-addressed deployment on every save and advances the Development alias; sessions stay pinned to the deployment they started on.

Run it

OpenComputer Pull Request Reviewer

Clone the complete agent, tools, and tests from GitHub.
Keep the watch command running while testing; it deploys changes to the Development environment.

Configure the GitHub token

Create a fine-grained personal access token scoped to the repositories the agent should review, with Pull requests: read and write and Contents: read. Store it as a managed secret:
The agent’s repository access equals the token’s grant: it can read and review only the repositories selected when the token was created.

Review a pull request

The dry-run review is a verdict paragraph plus numbered findings anchored to files and lines from the diff. Nothing is posted. To post the review:
The agent submits one COMMENT review — the verdict and findings as the body, plus inline comments for findings it can anchor to new-side diff lines. It never approves or requests changes.

Trigger from another system

Each authenticated delivery starts a fresh durable session against the active deployment and returns HTTP 202 with the session URL; a repeated Idempotency-Key returns the original session instead of starting a second review. See Agent webhooks. GitHub webhooks sign with an HMAC header and cannot supply the bearer token, so reviewing PRs on open requires a relay — for example a GitHub Actions pull_request job holding the webhook URL and token as repository secrets.

Safety properties

  • The GitHub token is write-only, attached outside the agent runtime, and constrained to declared origin, method, and path prefix.
  • The agent’s toolset is exactly what the render selects; posting requires an explicit request, and dry run is the default.
  • Reviews are COMMENT events only; the agent cannot approve, request changes, merge, or push.
  • Diffs above 150,000 characters are truncated, and the tool result reports the truncation and full size.