# Open-source PR reviewer on LangGraph: how would you structure the agent graph?

**URL:** <https://forum.langchain.com/t/open-source-pr-reviewer-on-langgraph-how-would-you-structure-the-agent-graph/5320>\
**Category:** Talking Shop\
**Created:** [November 20, 2026, 3:29am UTC](https://forum.langchain.com/t/open-source-pr-reviewer-on-langgraph-how-would-you-structure-the-agent-graph/5320 "2026-11-20T03:29:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![RameshS](https://avatars.discourse-cdn.com/v4/letter/r/a6a055/32.png) [@RameshS](https://forum.langchain.com/u/RameshS)\
**Post date:** [November 20, 2026, 3:29am UTC](https://forum.langchain.com/t/open-source-pr-reviewer-on-langgraph-how-would-you-structure-the-agent-graph/5320/1 "2026-11-20T03:29:38Z")

</div>

I built **agentic-code-reviewer** , an open-source tool that reviews GitHub pull requests with a LangGraph agent.

**How it works:** a GitHub webhook fires when a PR is opened or updated. The agent analyzes the diff for security issues, performance problems, architecture issues and testing gaps, then comments on the PR with line-specific suggestions. Review history is stored in PostgreSQL.

**Stack:** LangGraph, Node.js + Express, Octokit, PostgreSQL, OpenAI or Claude (configurable).  
**Where I’d like input:**

- _How do you handle diffs that exceed the context window: chunk by file, or summarise first?_

Code: [GitHub - Srameshgitnow/agentic-code-reviewer · GitHub](https://github.com/Srameshgitnow/agentic-code-reviewer)  
It needs a GitHub token, an LLM key and Postgres. Issues with what worked or didn’t are the most useful feedback.

---

<div class="post-metadata">

**Author:** ![AbdulBasit](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/abdulbasit/32/72_2.png) [@AbdulBasit](https://forum.langchain.com/u/AbdulBasit)\
**Post date:** [November 20, 2026, 12:36pm UTC](https://forum.langchain.com/t/open-source-pr-reviewer-on-langgraph-how-would-you-structure-the-agent-graph/5320/2 "2026-11-20T12:36:47Z")

</div>

I’d chunk by file, not summarise first. Your comments are line-specific, and a GitHub review comment needs a file path and a line in the diff, which a summary throws away.

octokit.rest.pulls.listFiles already gives you one patch per file. Fan those out with Send, one reviewer call per file, and concat the findings with a reducer. A last node then dedupes and posts. If one file’s patch is still too big, split it on the @@ hunk headers. Each header carries its own line numbers, so your comments still map.

You can drop lockfiles and generated code first. Also, listFiles returns 30 files per page (use octokit.paginate), stops at 3,000, and some files have no patch.

---

<div class="post-metadata">

**Author:** ![virse\_ai](https://avatars.discourse-cdn.com/v4/letter/v/85f322/32.png) [@virse\_ai](https://forum.langchain.com/u/virse_ai)\
**Post date:** [November 22, 2026, 5:47pm UTC](https://forum.langchain.com/t/open-source-pr-reviewer-on-langgraph-how-would-you-structure-the-agent-graph/5320/3 "2026-11-22T17:47:32Z")

</div>

Chunk-by-file with Send, then split leftover oversized patches on the @@ hunk headers, is the right default for line-specific review comments.

The gap that approach leaves is cross-file breakage: a renamed export, a changed function signature, or a missing test in another file won’t show up in a per-file patch. After the per-file fan-out, a small second pass that only sees the import graph and the exported typings / signatures (not the full file bodies) usually catches those. The reducer can merge that pass with the file-level findings before you dedupe and post.

If the webhook fires on every synchronize, I’d also skip files whose patch has not changed since the last review commit, and keep the previous comments on those files. That keeps the graph cheap and avoids flooding the PR with repeat suggestions.

---

<div class="post-metadata">

**Author:** ![system](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/system/32/1_2.png) [@system](https://forum.langchain.com/u/system)\
**Post date:** [November 23, 2026, 1:18pm UTC](https://forum.langchain.com/t/open-source-pr-reviewer-on-langgraph-how-would-you-structure-the-agent-graph/5320/4 "2026-11-23T13:18:12Z")

</div>

Unlisted on November 23, 2026, 1:18pm UTC



---

<div class="post-metadata">

**Author:** ![system](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/system/32/1_2.png) [@system](https://forum.langchain.com/u/system)\
**Post date:** [November 23, 2026, 1:56pm UTC](https://forum.langchain.com/t/open-source-pr-reviewer-on-langgraph-how-would-you-structure-the-agent-graph/5320/5 "2026-11-23T13:56:33Z")

</div>

Listed on November 23, 2026, 1:56pm UTC



---

<div class="post-metadata">

**Author:** ![press288](https://avatars.discourse-cdn.com/v4/letter/p/d2c977/32.png) [@press288](https://forum.langchain.com/u/press288)\
**Post date:** [November 23, 2026, 1:57pm UTC](https://forum.langchain.com/t/open-source-pr-reviewer-on-langgraph-how-would-you-structure-the-agent-graph/5320/6 "2026-11-23T13:57:36Z")

</div>

One extra step I’d add after the per-file reviewers and before Octokit is a deterministic validation gate. Have each reviewer return structured findings such as `{path, line, side, severity, explanation}`. Validate that the path exists in the fetched PR diff and that the proposed line is actually commentable on the specified diff side. A line inferred from the model’s text alone should never go straight to `createReview`; if it can’t be anchored, put the finding in the overall summary instead.

Also capture the PR’s `head.sha` when you ingest the webhook, then fetch it again immediately before publishing. If the head changed while the graph was reviewing files, discard that run’s comments and review the new revision. Use `(repo, PR number, head SHA, reviewer version)` as an idempotency key for webhook retries and a persisted posting state so `synchronize` events don’t duplicate reviews.

A useful regression test is to push another commit while the per-file reviews are in flight: the old run should post nothing, while the new run should produce comments only on valid changed lines.
