CodePanel
switch_model

switch_model

The CodePanel MCP tool that moves an agent app run to another model, or a cheaper one, at its next turn, keeping its history.

On this page›

switch_model moves a run to another model without losing its place. The run finishes the turn it is in, and its next turn goes to the new model with the same history. It needs the tasks:write scope.

When to call it

  • When a run spends too fast: cheaper: true picks your agent one step cheaper for the same work.
  • When a run is stuck on what one model does badly: name another agent with codingAgentId.

Inputs

Input Type Required Description
runId string yes Id of a run, from get_task's runs or start_task's task
codingAgentId string no The agent whose model to switch to
cheaper boolean no Pick the agent one step cheaper instead
reason string no Why, kept with the switch (up to 200 characters)

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.

runId, and either codingAgentId of an agent on CodePanel's loop or cheaper: true, with an optional reason. An ended run is refused with reason: run_ended. A run on an external agent CLI is refused with reason: switch_unsupported.

What it returns

{ before, after }, each the run. after.switchTo names the model the next turn uses. Once the runner has made the switch, the run's provider and modelId change and lastSwitch keeps the models before and after, with the reason. The run's log notes it too. The run's cap still holds. Reasoning the old model wrote is not sent to the new one. A team run switches its orchestrator only; each subagent keeps its own model.

The same step without MCP

Surface Form
HTTP API POST /tasks/runs/switch with the tasks:write scope
CLI codepanel run switch <runId> <agentId>, or --cheaper
Desktop app Fleet, select runs, Cheaper model

What the server tells your agent

The description your agent reads when it lists the tools:

Use it to move a run to another model without losing its place, such as when it is spending too fast. Give runId and either codingAgentId (an agent on CodePanel's loop, from list_coding_agents) or cheaper: true, which picks your agent one step cheaper for the same work. The runner switches at the run's next turn: the history carries over, reasoning the old model wrote is not sent to the new one, and the run's caps still hold. switchTo shows the switch asked for; lastSwitch, once made, the models before and after and the reason. A team run switches its orchestrator; subagents keep their own. An ended run is refused (run_ended), and so is an external agent CLI (switch_unsupported). Needs tasks:write. Returns { before, after }.

Last updated