When you runDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/goulinkh/code-review-harness/llms.txt
Use this file to discover all available pages before exploring further.
crh review, CRH executes a fixed sequence of phases: it prepares a deterministic workspace, initializes an agent session with a custom tool surface, runs the orchestrator which fans work out to parallel sub-agents, aggregates the resulting findings, and finally emits the review to your chosen sink. Understanding this sequence helps you reason about what the agent can and cannot see at each stage, and what to expect when something goes wrong.
Workspace preparation
prepareWorkspace performs a single parallel network burst against the provider:- Metadata: PR title, body, author, source/target git paths →
metadata.jsonanddescription.md - CI: status checks →
ci.json - Diff rounds: list of all preview diff rounds →
preview-diffs/index.json - Diffs and comments: for each round, raw diff, numbered diff, per-file patches + line maps, general comments, and inline comments are written under
preview-diffs/<id>/ - Agent files:
AGENTS.md/CLAUDE.md/.cursorrules,.cursor/rules/*.md,.clinerules/*, and.crh/skills/*.mdare read from the git object store and materialized intoworkspace/agent/
preview-diffs/latest → <id> points to the most recent round. The entire workspace tree is byte-stable: re-running on the same input produces identical files.The git clone (
noCheckout: true, depth: 50) is cached in gitdir. If the head ref is already present in the object store, the clone is skipped.Session initialization
createReviewSession configures the in-memory runtime:- Settings and resource loader: an in-memory
SettingsManagerand aDefaultResourceLoaderare created. Extensions, skills, prompt templates, themes, and context files are all disabled — only the system prompt is injected. - Tool registration: all custom tools are created and wrapped with timeout enforcement (10,000 ms, exempt:
delegate_review,submit_review) and response size limiting (80,000 chars, truncated with a pagination hint). - Session creation:
createAgentSessionis called with the tool list: built-inread,grep,find,lsplus all custom CRH tools. Mutating built-ins (bash,edit,write) are not included. - Changed file list: the session handle exposes
changedFiles— the list of paths from the latest diff round’smeta.jsonfiles — for use by callers.
The orchestrator’s
cwd is set to the workspace directory. Built-in read/grep/find/ls are therefore scoped to the workspace, not the repository source tree.Orchestrator execution
The orchestrator receives the system prompt and the initial user message (e.g.
"Review merge proposal. Submit final review with submit_review.").It follows a strict sequence with no multi-turn research loops:- Call
mp_metadataanddiff_list_filesin parallel to read the PR description and the list of changed files. - Optionally call
agent_files_listonce if agent rules are likely to exist. - Group files into scopes — related files in the same module or feature go together; each sub-agent has ≥ 250k context, so scopes should be large.
- Call
delegate_reviewexactly once with the fullscopesarray. - Receive the merged
Findingsfrom all sub-agents. - Call
submit_reviewwith the final findings. No further tool calls are permitted after this.
Sub-agent delegation
delegate_review spawns one sub-agent per entry in the scopes array. All sub-agents run concurrently via Promise.all.Each sub-agent:- Receives its own in-memory session with a focused system prompt: inspect only the assigned scope.
- Reads the relevant diffs using
diff_get_fileordiff_numbered. - Optionally calls
repo_readorrepo_grep(at most one extra call per file) to confirm or refute a candidate finding from the diff alone. - Calls
mark_file_reviewedfor each file in scope once the keep/drop decision is final. - Calls
report_findingsexactly once as its terminal action with structured JSON:
report_findings terminates the sub-agent session (terminate: true). If a sub-agent exits without calling it, delegate_review returns empty findings with a warning in the summary.Sub-agent tool responses are also subject to the 80,000-character limit with truncation hints. Use
start/end pagination on diff_numbered and startLine/endLine on repo_read for large files.Finding aggregation
After all sub-agents complete,
delegate_review merges their outputs:findingsarrays are concatenated into a single flat listsummarystrings are joined, prefixed with the slot number and scope label
Findings object as the tool response. It then calls submit_review with the consolidated findings. The orchestrator’s system prompt instructs it to drop speculative or unconfirmed findings and emit only what sub-agents reported with evidence.Sink emission
submit_review calls sink.emit(params, { provider, workspace }) and sets terminate: true, ending the orchestrator session.stdout sink: writes one JSON line to stdout containing the full review payload.Launchpad sink:- Posts inline comments for each finding where
lineis a valid numbered-diff line number. - Posts a summary comment with a verdict vote:
approve→Approveneeds-work→Needs Fixingabstain→Abstain
Error handling
Tool timeouts: if a tool call (other thandelegate_review or submit_review) takes longer than 10,000 ms, the call is rejected with a timeout error surfaced to the agent. The agent’s session continues and it can retry or move on.
Truncated responses: when a tool response exceeds 80,000 characters, the response is cut and a hint is appended:
start/end or startLine/endLine parameters rather than working from incomplete data.
Missing sub-agent report_findings: if a sub-agent exits without calling report_findings (e.g. due to a model error or context exhaustion), delegate_review returns { findings: [], summary: "sub-agent ended without calling report_findings" } for that slot. Other slots are unaffected.
Workspace errors: if prepareWorkspace cannot resolve the git head ref, it throws a WorkspaceError. The session never starts and no sink is called.