Review Agents
Optio can automatically launch a code review agent as a subtask of any coding task. The review agent examines the PR, checks for issues, and posts a GitHub review. This provides an automated first pass before human reviewers look at the code.
How It Works
- A coding task opens a PR and transitions to
pr_opened - The PR watcher detects the trigger condition (CI pass or PR open, depending on config)
- A review subtask is created with
taskType: "review"andblocksParent: true - The review agent runs in the same repo pod, scoped to the PR branch
- The review agent posts its findings as a GitHub PR review
- The parent coding task waits for the review subtask to complete before advancing
Enabling Reviews
Reviews are configured per repository. Navigate to Repos → (select repo) → Settings.
| Setting | Default | Description |
|---|---|---|
| reviewEnabled | false | Enable automatic code review for this repo |
| reviewTrigger | on_ci_pass | When to launch the review agent |
| reviewModel | sonnet | Which model to use for reviews |
| reviewPromptTemplate | null | Custom review prompt template |
Trigger Options
The reviewTrigger setting controls when the review agent is launched:
on_ci_pass (default)
The review agent launches after CI checks pass on the PR. This ensures the review focuses on code quality rather than catching build errors. Recommended for most repos.
on_pr
The review agent launches as soon as the PR is first detected, without waiting for CI. This is faster but means the review may flag issues that CI would have caught. Useful for repos without CI or where review speed is critical.
Review Model
The reviewModel setting allows you to use a different (often cheaper) model for reviews. Since reviews are primarily reading and commenting on code rather than writing it, a lighter model often works well.
Tip
sonnet for reviews and opus for coding is a common cost-effective configuration. You can also use haiku for fast, inexpensive reviews on simpler repos.Custom Review Prompts
Override the default review prompt to match your team's review standards. The prompt template supports the same variable syntax as coding prompts, plus review-specific variables.
Review Variables
| Variable | Description |
|---|---|
| {{PR_NUMBER}} | The PR number to review |
| {{TASK_FILE}} | Path to the task description markdown file |
| {{REPO_NAME}} | Repository name (owner/repo) |
| {{TASK_TITLE}} | Title of the original coding task |
| {{TEST_COMMAND}} | Auto-detected test command for the repo |
Example Custom Review Prompt
You are reviewing PR #{{PR_NUMBER}} in {{REPO_NAME}}.
Read the original task description from {{TASK_FILE}} to understand
what was requested.
Review the PR diff and check for:
1. Correctness — does the implementation match the task requirements?
2. Security — any SQL injection, XSS, or auth bypass risks?
3. Performance — any N+1 queries, unnecessary re-renders, or memory leaks?
4. Testing — are there adequate tests? Run "{{TEST_COMMAND}}" to verify.
5. Code style — does it follow the existing patterns in the codebase?
Post a GitHub review with your findings. If everything looks good,
approve the PR. If there are issues, request changes with specific,
actionable feedback.Manual Review Trigger
You can manually trigger a review for any task that has an open PR, regardless of the automatic review settings:
curl -X POST https://optio.example.com/api/tasks/{taskId}/review \
-H "Cookie: optio_session=YOUR_SESSION_TOKEN"This is also available as a button in the task detail view when the task is in pr_opened state.
Review as a Subtask
Reviews are implemented as subtasks of the parent coding task. This means:
- The review appears in the subtask list (
GET /api/tasks/:id/subtasks) - It has
blocksParent: true, so the parent waits for it to finish - It runs in the same repo pod, sharing the cloned repository
- It has its own logs, state transitions, and cost tracking
- When the review subtask completes,
onSubtaskComplete()checks if the parent can advance
Auto-Resume on Review
When a review (human or agent) requests changes, Optio can automatically resume the coding agent to address the feedback. This is controlled by the per-repo autoResume setting (enabled by default).
The flow:
- PR watcher detects a "changes requested" review
- Task transitions to
needs_attention - The review comments are extracted and used as the resume prompt
- Task is re-queued and the agent picks up the review feedback
- Agent pushes fixes and the cycle repeats
Info
Cost Considerations
Review tasks have their own cost tracking. To control review costs:
- Use a lighter model for reviews (e.g.,
sonnetorhaiku) - Set
maxTurnsReviewper-repo to limit the number of agent turns - Use
on_ci_passtrigger to avoid reviewing code that won't build - Monitor costs in the Costs dashboard, which breaks down spending by task type (coding vs review)