# wait_for_review

URL: https://codepanel.ai/docs/mcp-server/wait_for_review

The CodePanel MCP tool that blocks until a pull request's review finishes: its inputs, each status it returns, and real responses.

`wait_for_review` holds one MCP call open until a pull request's latest review finishes, then returns the review with its findings and the next step. It needs `repo` and `pr`, plus `headSha` after a push. On `timeout` you call it again. It replaces polling `get_review` in a loop, and it needs only the `read` scope.

## When to call it

- **After a push.** Pass the commit you pushed as `headSha` (`git rev-parse HEAD`). Without it, the latest finished review counts, and right after a push that is still the previous commit's.
- **After `trigger_review`.** Or call `trigger_review` with `wait: true`, which triggers and then waits in the same call.
- **When `nextAction` is `wait` on your own disputes.** Pass `disputes: true` instead, to wait for the orchestrator to answer them. Don't dispute again or push to hurry it.

## Inputs

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `repo` | string | yes | Repository as owner/name |
| `pr` | integer | yes | Pull request number |
| `timeoutSeconds` | integer, at most 600 | no | Give up after this many seconds (default 600, max 600). On timeout the result says whether a review is running, and you call again. Each call ends within about 45 seconds whatever you pass, before the usual 60-second client limit (in Claude Code, when it sends a progress token, up to 8 minutes); if your client cancels tool calls sooner, pass a smaller value. |
| `headSha` | string | no | After pushing, the commit to wait for (git rev-parse HEAD). Without it, the latest finished review counts. |
| `disputes` | boolean | no | Wait only for pending disputes (optional; wait_for_review already waits for pending disputes automatically). |
| `detail` | boolean | no | Return the full review: the deprecated top-level findings copy, each finding's fingerprint, models and reviewers, the text of answered findings and held-back suggestions, payload.keys when every key worked, and payload.disputes. Leave it out to act on the review |

It only reads: the server marks it `readOnlyHint: true`, so clients that ask before a write can run it without asking.

`disputes` and `headSha` don't go together. Passing both returns an error and waits for nothing:

```text
CodePanel: disputes waits for disputes, not a commit's review: leave out headSha, or call again without disputes
```

## What it returns

The result is a value, never an error. Branch on `status`:

| `status` | Meaning | Next call |
| --- | --- | --- |
| `finished` | The round ended. `outcome` is `completed`, or `failed` with `session.error` and `session.errorCode` saying why. `review` is what `get_review` returns | Act on `review.payload.nextAction` |
| `timeout`, `running: true` | The review is still running, or a triggered one is queued behind a running round | `wait_for_review` again |
| `timeout`, `running: false` | No review of that commit has started yet. A push takes up to 150 seconds to become a round, because CodePanel waits a minute for further pushes first | `wait_for_review` again |
| `no_review` | Nothing started within 150 seconds | `trigger_review`, or check that the repository is connected and auto-review is on |
| `refused` | CodePanel won't review that commit: a budget, a repository cap, credits, the plan or a key stopped it. `refused` has the `sha` and `reason`, and `message` says what to do | Don't wait again. Review the change locally with `get_review_brief` and `submit_local_review`, then carry on |
| `settled` | With `disputes: true`: your pending disputes were answered. Returns the review as `get_review` does | Act on `nextAction` |
| `aborted` | The client cancelled the call | |

Each call returns within about 45 seconds, whatever `timeoutSeconds` says. Most MCP clients cancel a tool call at 60 seconds, so a longer call would come back as a client error rather than `timeout`. Claude Code can be the exception, since it keeps a call open while progress arrives. When it sends a progress token with the call, a call blocks for up to 8 minutes, usually until the review is done: the local server sends a progress notification on every poll, and the hosted one, for Claude Code signed in with OAuth, answers over an event stream with one every 15 seconds. Without a token the 45-second limit holds. If your client cancels sooner, pass a smaller `timeoutSeconds`. Brief network errors and `5xx` or `429` answers while it polls are retried, and the local server sends MCP progress notifications while it waits when the client asks for them. The local server counts the 150 seconds across calls in a row for the same pull request and commit, so short calls still end in `no_review`. The hosted server may not, so there, once `running: false` answers have gone on for 150 seconds after the push, call `trigger_review`.

## Examples

These responses come from a test account on a local backend, trimmed where marked.

### A finished review that blocks the merge

```json title="Call"
{ "repo": "codepanel-dev/web-app", "pr": 142, "timeoutSeconds": 5 }
```

```json title="Result (trimmed)"
{
  "status": "finished",
  "outcome": "completed",
  "sessionId": "w978gv05cp2hat1hhf11vhymn98j5rw2",
  "waitedMs": 25,
  "review": {
    "gate": { "blocking": true, "level": "warning", "status": "posted", "unanswered": ["F1", "F4"] },
    "open": { "critical": 1, "warning": 1, "suggestion": 0 },
    "rounds": { "completed": 2, "limit": 3, "limitReached": false, "running": false, "capped": false, "perPr": true },
    "payload": {
      "verdict": "blocked",
      "blockedBy": ["F1", "F4"],
      "nextRound": "will-run-on-push",
      "nextAction": {
        "action": "fix",
        "reason": "fix each, or answer it with rate_finding and a verdict; the next push is reviewed automatically",
        "refs": ["F1", "F4"]
      },
      "findings": [
        {
          "ref": "F1",
          "severity": "critical",
          "file": "src/server/auth/rateLimit.ts",
          "line": 48,
          "message": "The limiter keys on the first X-Forwarded-For entry, which the client controls. Sending a new value with each request puts every attempt in a fresh bucket, so the limit never applies.",
          "verify": "Send 20 failed sign-ins with different X-Forwarded-For values: all return 401 and none 429."
        }
      ]
    }
  }
}
```

`gate.blocking: true` holds the `CodePanel` commit status at failing until F1 and F4 are fixed or answered with [`rate_finding`](/docs/mcp-server/rate_finding).

### A review still running

```json title="Result (trimmed)"
{
  "status": "timeout",
  "waitedMs": 3002,
  "running": true,
  "session": { "status": "reviewing", "activity": "Three reviewers are still reading the change.", "finished": false },
  "message": "The review had not finished after 3s. Last status: reviewing. It is still running: call wait_for_review again."
}
```

### A pushed commit with no round yet

With `headSha` set to a commit CodePanel has not started on:

```json title="Result"
{
  "status": "timeout",
  "waitedMs": 4004,
  "running": false,
  "message": "No review of 1111111 is running: it has not started after 4s (one can take up to 150s to appear after a push). The latest finished review is of b7d204e19c3f5a8b2e6d0c4f7a9b1e3d5c8f2a64. Calls made one after another count together: after 150s with none started, wait_for_review answers no_review. Or trigger one with trigger_review."
}
```

### Waiting on a dispute

```json title="Call"
{ "repo": "codepanel-dev/web-app", "pr": 142, "disputes": true, "timeoutSeconds": 4 }
```

```json title="Result"
{
  "status": "timeout",
  "waitedMs": 4003,
  "disputes": { "pending": 1, "retryAt": 1794613321708, "countsAt": 1794613741708 },
  "message": "1 dispute is still pending. The orchestrator is asked at 2026-11-13T23:42:01Z. They count as answers by 2026-11-13T23:49:01Z whatever the outcome. Call wait_for_review with disputes: true again; do not dispute again or push to hurry them."
}
```

`countsAt` is 4 minutes after the dispute was made. By then the dispute answers the merge gate even if the orchestrator never ruled.

## The same step without MCP

| Surface | Form |
| --- | --- |
| CLI | `codepanel review owner/name#123 --wait --sha "$(git rev-parse HEAD)"`. Exit `0` means the review completed and the gate passes, `3` a timeout, `4` the gate still blocks, and `5` a refusal ([CLI](/docs/cli)) |
| HTTP API | Poll [`GET /reviews/status`](/docs/api#get-reviewsstatus), then read [`GET /review`](/docs/api#get-review). The tool does this for you, backing off from 2 to 15 seconds |
| Pull request | Nothing to call: the review comment and the `CodePanel` commit status update when the round ends |

## What the server tells your agent

The description your agent reads when it lists the tools:

> Wait until the pull request's review round AND any pending disputes reach a terminal verdict, then return the review with a `steer` next step. Pass `headSha` after pushing so an earlier commit's review does not count. On `status: timeout`, call again instead of pushing or polling.

## Related

- [`rate_finding`](/docs/mcp-server/rate_finding): answer the findings this returns.
- [The review loop](/docs/agents): where waiting fits between pushes.
- [Merge gate](/docs/merge-gate): what `gate.blocking` holds back.
- [MCP server](/docs/mcp-server): install, sign-in and every other tool.

The review it returns is compact, as [`get_review`](/docs/mcp-server/get_review) describes; pass `detail: true` for the full one.
