# set_team_routing

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

The CodePanel MCP tool that overrides how a team picks a subtask's member: routing by record on or off, and members pinned per role.

`set_team_routing` overrides how a team picks the member that runs each subtask. It needs the `agents:write` scope. A run reads its team once, when it starts, so a change applies to the next run.

By default a team routes by record: a subtask goes to the cheapest member of its role (worker, tester, fixer or researcher) whose record on the repository clears the bar, at least 8 first tries and 8 changes with a first-try pass rate whose lower 95% bound is at least 0.5. With no such member it goes to the member the team's own configuration names: a delegation rule, the planner's pick, then the team's order. A subtask that fails a check, is blocked in review or stalls moves one step up the team's order at once.

## When to call it

- **To keep a member on a role whatever its record says:** pin it.
- **To turn routing by record off for a team:** set `mode` to `configured`, and only the team's rules, the planner's pick and its order decide.

## Inputs

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `teamId` | string | yes | Id of a team, from list_teams |
| `mode` | `record` or `configured` | no | record (default) or configured |
| `pins` | array of objects | no | Replaces the pins whole; each agent a member of the team with that role |
| `pins[].role` | `orchestrator` or `worker` or `tester` or `fixer` or `researcher` | yes |  |
| `pins[].agentId` | string | 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.

Pass `teamId` and what changes. `pins` replaces the pins whole, one member per role, each a member of the team with that role; `[]` clears them.

## What it returns

`{ teamId, before, after }`, each `{ mode, pins }`. A second call with the values from `before` undoes it. Every run records the member and the reason it was picked: `get_run` answers each subagent's `route` (`reason` such as `record`, `pinned` or `escalated`, a `cause` for an escalation, and a `note`).

## The same step without MCP

| Surface | Form |
| --- | --- |
| HTTP API | `POST /autopilot/teams/routing` with the `agents:write` scope |
| CLI | `codepanel teams routing <teamId> [--mode record\|configured] [--pin worker=<id>,tester=<id>\|--no-pins]` |

## What the server tells your agent

The description your agent reads when it lists the tools:

> Use it to override how a team picks the member for a subtask. By default (mode record) a subtask goes to the cheapest member of its role whose record on the repository clears the bar (enough first tries and changes, a first-try lower bound of at least 0.5), else to the team's configured member; mode configured turns the record off and keeps delegation rules, the planner's pick and the team's order. pins: one member per role (worker, tester, fixer, researcher) that always runs that role; [] clears them. Every run records the member and the reason (get_run's agents, the run's subtask events). Applies to the next run. Needs the agents:write scope. Returns { teamId, before, after }: a second call with before undoes it.

## Related

- [`list_teams`](/docs/mcp-server/list_teams): read the teams, their members' ids and their `routing`.
- [`get_run`](/docs/mcp-server/get_run): read why each subagent ran on its member.
- [MCP server](/docs/mcp-server): install, sign-in and every other tool.
