# restore_panel

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

The CodePanel MCP tool that undoes apply_panel: it puts a panel's earlier reviewers, orchestrator model and per-pull-request limit back.

`restore_panel` undoes an `apply_panel`: you pass its `undo` object, and the panel gets back its earlier reviewers, their models and effort, the orchestrator's model and the per-pull-request limit. It returns `{ "ok": true }` and needs the `panel:write` scope.

## When to call it

- **When an applied panel costs more or finds less** than the one it replaced. Compare [`get_spend`](/docs/mcp-server/get_spend) and [`get_quality`](/docs/mcp-server/get_quality) after some reviews, then restore.
- **Right after a mistaken `apply_panel`.**
- **Only with an `undo` that `apply_panel` returned.** Keep it for as long as you might want it. [`add_reviewer`](/docs/mcp-server/add_reviewer), [`remove_reviewer`](/docs/mcp-server/remove_reviewer) and [`update_panel_member`](/docs/mcp-server/update_panel_member) return no undo.

## Inputs

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `undo` | object | yes |  |
| `undo.panelId` | string | yes |  |
| `undo.reviewerIds` | array of strings | yes |  |
| `undo.reviewerModels` | array of objects | no |  |
| `undo.reviewerModels[].name` | string | no |  |
| `undo.reviewerModels[].agentId` | string | yes |  |
| `undo.reviewerModels[].provider` | string | yes |  |
| `undo.reviewerModels[].modelId` | string | yes |  |
| `undo.reviewerModels[].reasoningEffort` | `none` or `low` or `medium` or `high` or `xhigh` or `max` | no |  |
| `undo.reviewerModels[].followTier` | `economy` or `balanced` or `frontier` | no |  |
| `undo.orchestrator` | object or null | yes |  |
| `undo.orchestrator.provider` | string | yes |  |
| `undo.orchestrator.modelId` | string | yes |  |
| `undo.orchestrator.reasoningEffort` | `none` or `low` or `medium` or `high` or `xhigh` or `max` | no |  |
| `undo.orchestrator.followTier` | `economy` or `balanced` or `frontier` | no |  |
| `undo.budgetUsd` | number or null or `"default"` | yes |  |

It writes: the server marks it `readOnlyHint: false` and `destructiveHint: true` (it can change what is already there), so a client that asks before writes asks here.

`undo` is `apply_panel`'s `undo` object, passed as it came:

- `panelId`: the panel to restore.
- `reviewerIds`: the reviewers the panel should have. Ones that apply took off the panel are brought back.
- `reviewerModels`: optional. For each seat, its `agentId`, `name`, `provider`, `modelId`, `reasoningEffort` and `followTier`, put back as they were.
- `orchestrator`: the model and effort to put back, or `null` to leave the orchestrator alone.
- `budgetUsd`: a positive amount, `null` for no limit, or `"default"` for the default limit.

The restore sets those fields and overwrites the same fields on the panel as they are now. Changes you made since the apply to a seat's model, effort, name or tier following are replaced, and so is the limit. Instructions are not part of an undo, because apply does not change them.

Errors a caller can hit:

| Message | Cause |
| --- | --- |
| `Panel not found` | An unknown `panelId`, or one that is not yours |
| `Reviewer not found` | A reviewer id that does not exist or is not yours |
| `That reviewer belongs to another repository's panel.` | A reviewer that is not on the panel now and is scoped to another repository |
| `A panel needs at least one reviewer.` | `reviewerIds` is empty |
| `A panel can have at most 10 reviewers.` | More than 10 ids |
| `Undo must name each reviewer model at most once.` | A repeated `agentId` in `reviewerModels`, or more entries than `reviewerIds` |
| `Invalid reviewer model in undo.` | A `reviewerModels` entry that is not in `reviewerIds`, or names an unknown provider or an empty model |
| `The undo names an orchestrator model CodePanel does not know.` | An unknown provider or an empty model id |

The orchestrator is not checked against your keys as a new choice would be: an undo puts back what the panel ran before, even on a key that has stopped working. [`get_panel`](/docs/mcp-server/get_panel) shows `callable: false` if so.

## What it returns

`{ "ok": true }`. Read the panel back with `get_panel` to confirm.

The restore does not touch repository settings. If `apply_panel` gave a repository its own panel, the restored panel stays that repository's. To send the repository back to your default panel, call [`update_repo_settings`](/docs/mcp-server/update_repo_settings) with `panelId: null`.

## Examples

These responses come from a test account on a local backend. Model ids are seed values.

### Undo the repository panel from `apply_panel`

The `undo` is the one `apply_panel` returned in its example.

```json title="Call"
{
  "undo": {
    "budgetUsd": 3,
    "orchestrator": {
      "modelId": "claude-opus-5-5",
      "provider": "anthropic",
      "reasoningEffort": "high"
    },
    "panelId": "vs79t2rrpcvekcnsk7n9cq0d598j6jcv",
    "reviewerIds": [
      "k57d5rxa4vmsh7qxnwnyefv6018j6rp3",
      "k57bzxc9gr8xh9wsk0bgg5t4bh8j7dbf",
      "k571gqg6dpptezyyth0fakme6s8j640z",
      "k57228bdncm44ms17e7pvmwr2d8j6j3x"
    ],
    "reviewerModels": [
      {
        "agentId": "k57d5rxa4vmsh7qxnwnyefv6018j6rp3",
        "modelId": "claude-sonnet-5-5",
        "name": "Bugs & Security",
        "provider": "anthropic",
        "reasoningEffort": "medium"
      },
      {
        "agentId": "k57bzxc9gr8xh9wsk0bgg5t4bh8j7dbf",
        "modelId": "gpt-5.4-mini",
        "name": "Tests & Maintainability",
        "provider": "openai",
        "reasoningEffort": "low"
      },
      {
        "agentId": "k571gqg6dpptezyyth0fakme6s8j640z",
        "modelId": "gemini-3.8-flash",
        "name": "Docs & Best Practices",
        "provider": "google",
        "reasoningEffort": "low"
      },
      {
        "agentId": "k57228bdncm44ms17e7pvmwr2d8j6j3x",
        "modelId": "grok-4.7",
        "name": "Design & UX",
        "provider": "xai",
        "reasoningEffort": "low"
      }
    ]
  }
}
```

```json title="Result"
{
  "ok": true
}
```

The four reviewers go back to Sonnet, GPT, Gemini and Grok models at their earlier effort, the orchestrator goes back to `claude-opus-5-5` at `high`, and the limit to $3.

## The same step without MCP

| Surface | Form |
| --- | --- |
| CLI | `codepanel panel restore --file undo.json`, from `panel apply`'s `--json` output or its `undo` object, or `--file -` for stdin ([CLI](/docs/cli#panels-models-and-keys)) |
| HTTP API | [`POST /panels/restore`](/docs/api#post-panelsrestore), with `undo` or its fields at the top level |

## What the server tells your agent

The description your agent reads when it lists the tools:

> Undo apply_panel: pass its undo object to bring back the panel's previous reviewers, orchestrator model and per-PR limit.

## Related

- [`apply_panel`](/docs/mcp-server/apply_panel): returns the `undo` this takes.
- [`get_panel`](/docs/mcp-server/get_panel): check the restored panel.
- [`get_spend`](/docs/mcp-server/get_spend) and [`get_quality`](/docs/mcp-server/get_quality): the evidence for deciding to restore.
- [Ask for a panel by goal](/docs/reviewers#ask-for-a-panel-by-goal): apply and undo from the docs.
- [MCP server](/docs/mcp-server#control-cost-and-check-quality): where it fits in tuning cost.
