Overview
Nectr uses Claude Sonnet 4.6 (from Anthropic) to analyze pull requests. The AI layer supports two review modes:- Standard Mode (Agentic): Single Claude instance with 8 MCP-style tools, fetches context on-demand
- Parallel Mode: Three specialized agents (security, performance, style) run concurrently, then a synthesis agent combines findings
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
read_file
read_file
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:
search_project_memory
search_project_memory
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):search_developer_memory
search_developer_memory
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):get_file_history
get_file_history
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):get_issue_details
get_issue_details
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):search_open_issues
search_open_issues
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):get_linked_issues
get_linked_issues
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
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
Security Agent
Security Agent
System Prompt (from Tools:
ai_service.py:181-193):read_file, search_project_memory, get_issue_details, search_open_issuesExample output:Performance Agent
Performance Agent
System Prompt (from Tools:
ai_service.py:195-207):read_file, get_file_history, search_project_memoryExample output:Style Agent
Style Agent
System Prompt (from Tools:
ai_service.py:209-221):read_file, search_developer_memory, search_project_memory, search_open_issuesExample output:Synthesis Agent
Synthesis Agent
System Prompt (from Output: Unified
ai_service.py:867-898):PRReviewResult matching standard modeβs formatParallel Execution
"[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 aPRReviewResult (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 is matched against the diffβs + lines (with whitespace normalization) to resolve the absolute line number.
Semantic Issue Matches
Issues this PR resolves without explicitFixes #N mention. Extracted from <semantic_issues> JSON block.
Example:
"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
Related Files
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)