
Automate Code Reviews with a Durable Eve.dev GitHub Agent
Learn how to build an autonomous AI code reviewer using Eve.dev that listens to GitHub webhooks, analyzes pull requests, and posts detailed inline comments.
Summary
TL;DR: Reviewing massive Pull Requests takes hours. In this guide, we use Eve.dev to build a durable GitHub agent that clones repositories, reviews code line-by-line, and posts inline comments automatically.
AI coding assistants like GitHub Copilot are great for writing code, but what about reviewing it?
Building an automated Pull Request (PR) reviewer requires an agent that can handle long, complex tasks. A large PR might contain 50 files. Analyzing this takes time, multiple LLM tool calls, and robust error handling. If your Vercel serverless function times out after 10 seconds, your code reviewer dies halfway through.
Eve.dev provides the perfect infrastructure for this. Its durable execution model allows the agent to run for as long as it needs—even hours—without worrying about server timeouts or memory leaks.
Designing the Code Review Agent
We'll structure our Eve.dev workspace specifically for GitHub operations:
/eve
/agents
/reviewer
instructions.md
/tools
get_pr_diff.ts
post_inline_comment.ts
Step 1: The Agent Instructions
The instructions define the "personality" of our senior engineer agent. In /eve/agents/reviewer/instructions.md:
# Senior Code Reviewer
You are a strict but helpful senior software engineer. Your job is to review GitHub Pull Requests.
## Review Guidelines
1. Look for security vulnerabilities, memory leaks, and performance bottlenecks.
2. Ignore formatting issues (we have Prettier for that).
3. If you find a bug, use the `post_inline_comment` tool to comment exactly on the line where the issue exists. Provide a code snippet fixing the issue.
4. Be concise. Do not nitpick.
Step 2: Extracting the Diff
The agent needs a way to read the code changes. We create /eve/agents/reviewer/tools/get_pr_diff.ts:
import { tool } from '@eve/core';
import { z } from 'zod';
import { Octokit } from 'octokit';
const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN });
export default tool({
name: 'get_pr_diff',
description: 'Fetches the file differences for a specific Pull Request.',
schema: z.object({
owner: z.string(),
repo: z.string(),
pull_number: z.number()
}),
execute: async ({ owner, repo, pull_number }) => {
const { data } = await octokit.rest.pulls.listFiles({
owner,
repo,
pull_number,
});
// Format the diff nicely for the LLM
const formattedDiff = data.map(file => `
File: ${file.filename}
Status: ${file.status}
Patch:
${file.patch}
`).join('\n\n');
return formattedDiff;
}
});
Step 3: Posting Feedback
Next, we give the agent the ability to write comments directly onto the PR. Create /eve/agents/reviewer/tools/post_inline_comment.ts:
import { tool } from '@eve/core';
import { z } from 'zod';
import { Octokit } from 'octokit';
const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN });
export default tool({
name: 'post_inline_comment',
description: 'Posts a comment on a specific line of code in the Pull Request.',
schema: z.object({
owner: z.string(),
repo: z.string(),
pull_number: z.number(),
commit_id: z.string(),
path: z.string(),
line: z.number(),
body: z.string()
}),
execute: async (params) => {
await octokit.rest.pulls.createReviewComment({
owner: params.owner,
repo: params.repo,
pull_number: params.pull_number,
commit_id: params.commit_id,
path: params.path,
line: params.line,
body: params.body
});
return { success: true };
}
});
Step 4: Webhook Integration
Now, how do we trigger this agent? We set up a GitHub Webhook that calls our Next.js API route whenever a PR is opened.
Because Eve.dev agents are durable, we can acknowledge the webhook immediately (preventing GitHub from timing out) while the agent does its work in the background.
// app/api/webhook/github/route.ts
import { Eve } from '@eve/core';
import { NextResponse } from 'next/server';
const eve = new Eve({ workspace: './eve' });
export async function POST(req: Request) {
const payload = await req.json();
// Only trigger on PR opened or synchronized (updated)
if (payload.action === 'opened' || payload.action === 'synchronize') {
const pr = payload.pull_request;
const repo = payload.repository;
const agent = await eve.getAgent('reviewer');
// We start the agent workflow asynchronously.
// Even if this takes 10 minutes, Eve.dev manages the state securely.
agent.run({
id: `pr_review_${pr.id}_${pr.head.sha}`, // Unique ID for durability
input: `Please review PR #${pr.number} in ${repo.owner.login}/${repo.name}. The latest commit is ${pr.head.sha}.`
});
}
// Immediately return 200 OK to GitHub
return NextResponse.json({ received: true });
}
Conclusion
By combining GitHub webhooks with Eve.dev's durable architecture, you can build powerful CI/CD agents. The LLM can take its time analyzing complex diffs, formulating suggestions, and making multiple API calls to post comments, all without you worrying about serverless timeouts or fragile state management.
FAQ
Why do serverless timeouts matter for AI Code Review? LLMs are slow. Reviewing a large PR might require reading 10 files and generating 5 different comments. This can easily take 3-5 minutes, which will crash standard Vercel or AWS Lambda functions. Eve.dev's checkpointing allows the process to run durably across multiple invocations if necessary.
How does the agent know which line to comment on?
We feed the git patch (the diff) to the LLM. Modern models (like GPT-4o or Claude 3.5 Sonnet) are excellent at understanding diff syntax and can accurately identify the line numbers where vulnerabilities exist, which they then pass to the post_inline_comment tool.
Related reading
Our monthly client reports followed a 40-line prompt nobody dared touch. I moved the whole playbook into an uploaded skill using the new uploadSkill API in Vercel AI SDK v7.
Build an AIOps on-call agent with Eve.dev that triages alerts, runs diagnostics, and gates risky remediation behind human approval—surviving restarts.
Use Eve.dev's multi-agent orchestration to build an accounts-payable pipeline: a supervisor delegates invoice extraction, 3-way matching, and durable approvals.
Let's build something great.
Have a project in mind? We are an elite software and AI development studio ready to bring your ideas to production. Let's talk about your roadmap.