Skip to main content

Overview

Nectr uses Claude Sonnet 4.6 (from Anthropic) to analyze pull requests. The AI layer supports two review modes:
  1. Standard Mode (Agentic): Single Claude instance with 8 MCP-style tools, fetches context on-demand
  2. Parallel Mode: Three specialized agents (security, performance, style) run concurrently, then a synthesis agent combines findings
Both modes produce the same output format: a structured review with verdict, prose summary, inline suggestions, and semantic issue matches.
Set PARALLEL_REVIEW_AGENTS=true to enable parallel mode. Standard mode is default.

Standard Mode (Agentic)

Architecture

Claude receives only the PR diff + file list, then calls tools to fetch exactly the context it needs.

Available Tools

Description: Read the complete source code of a file at the PR’s head commitUse case: When the diff alone doesn’t show enough context (e.g., the full class a method belongs to, imports, or a callee)Input:
Output:
Description: Search the project’s accumulated knowledge for patterns, past decisions, and known risksUse case: When the diff touches an area you want to cross-check against historical contextInput:
Output:
Implementation (from pr_review_service.py:302-309):
Description: Search what Nectr has learned about a specific developer β€” their recurring patterns, known strengths, and past issuesUse case: When the PR author is known and you want to tailor feedbackInput:
Output:
Implementation (from pr_review_service.py:311-318):
Description: Get (1) which developers have the most commits touching these files, and (2) past PRs that modified the same filesUse case: To spot patterns like β€œthis file keeps getting bug-fixed”Input:
Output:
Implementation (from pr_review_service.py:320-338):
Description: Fetch title, state, and description of specific GitHub issues (e.g., those mentioned in the PR body with β€˜Fixes #N’)Input:
Output:
Implementation (from pr_review_service.py:340-354):
Description: Search open GitHub issues to find ones this PR might resolve even without an explicit β€˜Fixes #N’ mentionUse case: When you want to find semantic matches (issues resolved by behavior, not explicit reference)Input:
Output:
Implementation (from pr_review_service.py:356-365):
Description: Fetch Linear or GitHub issues linked to this PR’s feature area via MCPUse case: When you want to understand what user problem the PR is solvingInput:
Output:
Implementation (from pr_review_service.py:368-406):

Agentic Loop Implementation

Safety cap: 8 rounds maximum to prevent infinite tool-call loops.

Advantages

Efficient Context

Claude fetches only what it needsNo wasted tokens on irrelevant context

Targeted Analysis

Each tool call is motivated by reasoningSharper, less noisy reviews

Reasoning Thread

Claude follows its own logical flowread_file β†’ check_history β†’ search_memory

Graceful Degradation

If a tool fails, Claude adaptsReview completes with available data

Parallel Mode

Architecture

Three specialized agents run concurrently, then a synthesis agent combines their findings into one unified review.

Specialized Agents

System Prompt (from ai_service.py:181-193):
Tools: read_file, search_project_memory, get_issue_details, search_open_issuesExample output:
System Prompt (from ai_service.py:195-207):
Tools: read_file, get_file_history, search_project_memoryExample output:
System Prompt (from ai_service.py:209-221):
Tools: read_file, search_developer_memory, search_project_memory, search_open_issuesExample output:
System Prompt (from ai_service.py:867-898):
Output: Unified PRReviewResult matching standard mode’s format

Parallel Execution

Error handling: If any agent fails, synthesis continues with "[agent_name] agent error: ..."

Advantages

Faster Reviews

3 agents run in parallel10-20 seconds vs 15-30 seconds

Domain Expertise

Each agent focuses on its specialtyMore thorough in each domain

Deduplication

Synthesis agent merges findingsNo repeated issues from multiple agents

Graceful Degradation

If one agent fails, others continuePartial review better than no review

Output Format

Both modes produce a PRReviewResult (from ai_service.py:232-241):

Prose Summary

Markdown-formatted review with sections:

Inline Suggestions

GitHub suggested-change format. Extracted from <suggestions> JSON block in Claude’s response. Example (from ai_service.py:378-401):
Line hint resolution: line_hint is matched against the diff’s + lines (with whitespace normalization) to resolve the absolute line number.

Semantic Issue Matches

Issues this PR resolves without explicit Fixes #N mention. Extracted from <semantic_issues> JSON block. Example:
Confidence filter: Only "high" and "medium" matches are included (low-confidence matches are dropped).

Configuration

Model Selection

Mode Toggle

Token Limits

  • Standard mode: 4000 max tokens per response
  • Parallel mode agents: 2048 max tokens per agent
  • Synthesis agent: 3000 max tokens

Performance Comparison

Standard Mode

Average: 15-30 secondsTool calls: 2-4 per reviewContext size: 8-12 kB (diff + tool results)

Parallel Mode

Average: 10-20 secondsTotal tokens: ~60% more (3 agents + synthesis)Context size: 12 kB per agent (diff only)

When to Use Each Mode

Use Standard Mode When:

  • Small to medium PRs (<500 lines): Context depth matters more than speed
  • Context-heavy reviews: PR needs deep cross-referencing of past decisions
  • Exploratory changes: PR touches unfamiliar code that needs research
  • Cost-sensitive: Fewer tokens used per review

Use Parallel Mode When:

  • Large PRs (>500 lines): Parallel execution saves time
  • Security-critical repos: Want thorough security review every time
  • High-traffic repos: Speed matters (10-20s vs 15-30s)
  • Clear domains: PR has distinct security/performance/style concerns
  • app/services/ai_service.py β€” Claude integration + agentic + parallel modes (view source)
  • app/services/pr_review_service.py β€” Tool executor implementation (view source)
  • app/core/config.py β€” Environment variable config (view source)