Open Code Review (OCR) — Review agent

docs / modules / agent

← all docs

Open Code Review (OCR) — Review agent

flowchart LR IN["Input\nagent.Args (repo dir, From/To/Commit, template, rules, LLM client, tool registry)"] --> ACT["Review agent\nRuns ocr review end to end: load diffs, filter, dispatch one goroutine per file, finalize the manifest."] ACT --> OUT["Output\n[]model.LlmComment + a persisted session with a coverage manifest"]

Runs ocr review end to end: load diffs, filter, dispatch one goroutine per file, finalize the manifest. Package: internal/agent/.

What flows through it

flowchart LR IN["agent.Args (repo dir, From/To/Commit, template, rules, LLM client, tool registry)"] --> MOD["Review agent"] MOD --> OUT["[]model.LlmComment + a persisted session with a coverage manifest"]

Technical details

Package: internal/agent/ Depends on: diff, config_rules, llmloop, tool, session, llm Depended on by: CLI, Scan agent

What actually happens here

Agent.Run (agent.go) parses diffs via internal/diff, builds a read-only DiffMap tool input, filters by rule/size/budget, then dispatchSubtasks fans out to up to MaxConcurrency (default 8) goroutines, each calling executeSubtask (plan phase, then llmloop.Runner.RunPerFile for the main loop). A per-run token budget (MaxTokensBudget) is checked before each new file is scheduled, so an in-flight batch can overrun the cap by at most the concurrency limit, never a whole extra batch.

How the LLM / model version is chosen

Model/provider come from Args.Model/Args.Provider, set once by the CLI layer from the resolved LLM endpoint — every request in a run (plan, main loop, memory compression, re-location, review filter) uses that same value; there is no per-phase override.

Deterministic (non-LLM) work in this module

Diff loading/filtering, concurrency and per-file token-budget gating, manifest coverage registration (registerCoverage/Mark*), resume matching by content fingerprint (SHA-256 of mode+paths+diff text), and all error classification are deterministic; only the plan phase and the main tool-use loop inside each subtask are AI-driven (see llmloop).


Part of the module docs index. Full interactive version, with every module side by side: architecture.html §7. Cross-cutting mechanisms this module participates in (retry, compression, manifest, resume, hashing): LLD.