Skip to content

feat: Optimize code review agent performance: parallel dispatch, token reduction, and skill discovery consolidation #1303

@erikschlegel

Description

@erikschlegel

Issue Description

Description

Full code review runs via the Code Review Full orchestrator were taking 9–16 minutes due to sequential subagent execution, redundant skill file scanning, and excessive file reads. Profiling revealed that the Standards subagent was performing 24 individual file reads for skill discovery because VS Code's native skill loading does not activate inside runSubagent contexts — subagents only see what is explicitly provided in their prompt inputs.

Root Causes Identified Through Profiling

  • Sequential execution: The Functional and Standards subagents were dispatched one after another, doubling wall-clock time unnecessarily.
  • Redundant skill scanning: The Standards subagent manually replicated skill discovery by reading individual SKILL.md files one-by-one across the entire project, even when the diff only contained Python files. No scoping by file extension occurred before the search.
  • Duplicate file reads: Both subagents and the orchestrator re-read the same diff content, instructions files, and templates multiple times across steps. No read-once discipline existed.
  • Token overhead: Inline output format schemas, report skeletons, and persistence rules in the orchestrator consumed tokens without benefiting from model invocation (the orchestrator uses disable-model-invocation: true).
  • Finding overlap: Both subagents produced duplicate findings for the same issues with no lane separation, causing redundant merge logic and inflated finding counts.

Acceptance Criteria

  • Functional and Standards subagents dispatch in a single parallel tool-call block, executing concurrently
  • Skill discovery is scoped to file extensions present in the diff, not a full workspace scan
  • Skill discovery is owned solely by the Standards agent (not duplicated in the orchestrator)
  • Read Discipline enforced: every external file (diff, instructions, findings, templates) read exactly once via a single full-range call, with parallel batching where possible
  • Output format schemas, report skeleton, and persistence rules extracted to a shared template file to reduce orchestrator token load
  • Lane directives prevent Functional and Standards subagents from producing overlapping findings
  • Subagents write structured JSON findings (not markdown) to enable deterministic merge without LLM re-parsing
  • T-shirt size classification gates review strategy (XS-XL) with batching for large diffs
  • Documentation updated to reflect the parallel subagent architecture, lane directives, and skill discovery ownership
  • Full code review completes in under 10 minutes for S-sized diffs (5-19 files, 100-399 lines)

Definition of Done

  • All changes validated through multiple profiling runs (runs 1-9 across the branch)
  • No backward compatibility concerns — breaking changes per repo conventions are acceptable
  • End-to-end validation confirms the code review catches obvious code smells and critical bugs across all severity levels

Open Questions / Risks / Dependencies

  • Subagent skill loading relies on explicit extension-to-skill mapping since VS Code's native skill registry does not activate inside runSubagent contexts — a future platform change could make this optimization unnecessary

Additional Context

No response

Metadata

Metadata

Assignees

Labels

needs-triageRequires triage and prioritization

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions