An open-source, faster Devin alternative
TypeScript
docs: explain the example's anatomy; cleaner screenshot
Igor Zalutskib0b25e1ba5ab
diff --git a/docs/agents/examples/pr-review.mdx b/docs/agents/examples/pr-review.mdxindex df994060..33bfebfc 100644--- a/docs/agents/examples/pr-review.mdx+++ b/docs/agents/examples/pr-review.mdx@@ -3,25 +3,85 @@ title: "Review pull requests"description: "Fetch a PR through a managed GitHub connection, review it, and post inline comments on request"----The PR review 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. Only-when the request explicitly asks it to post does the agent submit a `COMMENT`-review with inline comments.+The [PR review example](https://github.com/diggerhq/opencomputer-example-pr-review)+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. Only when the request explicitly+asks does it post a `COMMENT` review — a verdict plus findings, with inline+comments anchored to diff lines:<Frame><imgsrc="/images/agents/pr-review-posted-review.png"- alt="A pull request review with numbered findings posted by an OpenComputer agent"+ alt="An inline review comment anchored to a diff line, posted by the agent with a concrete code suggestion"/></Frame>-## How it works+## What the example is made of++Three files carry the whole design.++**The agent function** — `opencomputer/agents/pr-review/agent.ts` — is a+synchronous render that runs before every model step. It reads the current+input and decides what the model gets for that step: the instructions and the+tool set. The write tool exists only when the request asks for a live post:++```tsx+export default function Agent() {+ const input = useInput();+ const live = /\bpost\b.*\breview\b/i.test(input.text ?? "");++ useModel("anthropic/claude-sonnet-4.6");+ useTool(getPullRequest);+ useTool(getDiff);+ if (live) {+ useTool(postReview);+ }++ return live+ ? "…review, then post with post_review and report the review URL."+ : "…review as a dry run. Do not claim to have posted anything.";+}+```++There is no separate permissions system: 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:++```tsx+export const github = defineConnection({+ id: "github-api",+ origin: "https://api.github.com",+ methods: ["GET", "POST"],+ pathPrefix: "/repos/",+ headers: {+ Authorization: bearer(useSecret("GITHUB_TOKEN")),+ "User-Agent": "opencomputer-pr-review-agent",+ },+});+```++The connection is the agent's entire reach: 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](/agents/secrets).++**The managed runtime** supplies everything else: 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.```mermaidflowchart LRInput[Session, playground,<br/>or webhook input]- Render[Agent render:<br/>instructions + tools<br/>for this input]+ Render[Render: instructions +<br/>tools for this input]Read[get_pull_request<br/>get_diff]Conn[Managed connection<br/>api.github.com]Dry[Review as<br/>session output]@@ -35,18 +95,7 @@ flowchart LRPost --> Conn```-The agent function selects capabilities per input: the two read tools on-every turn, `post_review` only when the input asks for a live post. A tool-the render does not select does not exist for that model step, and the-review defaults to a dry run.--All three tools call one declared HTTP connection: `https://api.github.com`,-`GET` and `POST`, path prefix `/repos/`, authorized by a managed-`GITHUB_TOKEN` secret. The platform validates destination, method, and path-before attaching the token at its outbound edge; the value never enters the-agent runtime. See [Secrets and runtime variables](/agents/secrets).--## Start with the example+## Run it<Cardtitle="OpenComputer PR review agent"@@ -71,7 +120,7 @@ Development environment.Create a fine-grained personal access token scoped to the repositories theagent should review, with **Pull requests: read and write** and-**Contents: read**. Then store it as a managed secret:+**Contents: read**. Store it as a managed secret:```bashnpm run opencomputer -- secrets set GITHUB_TOKEN@@ -98,8 +147,7 @@ npm run session -- "Review acme/widgets#42 and post the review on the PR."The agent submits one `COMMENT` review — the verdict and findings as thebody, plus inline comments for findings it can anchor to new-side diff-lines. Anchors GitHub rejects fall back to a summary-only review. The agent-never approves or requests changes.+lines. It never approves or requests changes.## Trigger from another systemdiff --git a/docs/images/agents/pr-review-posted-review.png b/docs/images/agents/pr-review-posted-review.pngindex 318d0560..56fde598 100644Binary files a/docs/images/agents/pr-review-posted-review.png and b/docs/images/agents/pr-review-posted-review.png differ