feat(mcp): agents can pick a scheduled task's model, effort and Fast tier #30808
main fromrefs/pull/30808/head·opened View on GitHubProblem#
An agent can't choose a scheduled task's model through MCP. schedule_task has no model input. Create copies the calling thread's modelSelection (or the project default), and update always keeps the stored one. So when a user says "run this nightly on Haiku" or "switch that task to Sol with Fast on", the agent can't do it. The same user can do it in the web and mobile scheduled-task forms.
Change#
schedule_task takes an optional target, the same shape delegate_task and create_threads already use, minus environmentId and projectId. A task runs in its own project's environment, and schedule_task already names both at the top level.
schedule_task(input)
create:
- modelSelection = callerThread.modelSelection ?? project.defaultModelSelection
+ base = callerThread.modelSelection ?? project.defaultModelSelection ?? complete target
+ modelSelection = target ? resolveTargetRechecking(base, target) : base
+ runtimeMode = target ? stepped down to a mode the target's provider offers : callerMode
update:
- modelSelection = existing.modelSelection
+ modelSelection = target ? resolveTargetRechecking(existing.modelSelection, target) : existing.modelSelection
+ runtimeMode = target ? stepped down as above : existing.runtimeMode
+ target on a task that ends up thread-bound -> invalid_request
- The target resolves through
resolveTargetRechecking, the same codedelegate_taskuses. It checks the same things: provider instance, model, option ids and values. It also refuses a provider instance the project has disabled, since launch would reject it on every run. Partial targets merge the same way.{options: {serviceTier: "priority"}}keeps the stored model and its other options, and a newmodelstarts from that model's defaults. - A target can pick a provider that lacks the task's runtime mode (Pi has no
auto). Runs would then fall back toapproval-requiredand wait. The saved mode now steps down to the broadest mode that provider offers, withdelegate_task's rule for an inherited mode. Without a target the mode is unchanged. - A caller outside a thread can pass a complete target (
providerInstanceIdandmodel) on a project with no default model. Before, it was refused because there was nothing to inherit from. - Thread-bound tasks refuse a
target. Bound runs follow the thread's current model on purpose (#18467), so a stored target would never run. The error tells the agent to passbindToCurrentThread: false. An update can unbind and set a target in the same call. - The task summary returned by
schedule_taskandlist_scheduled_tasksnow includestargetfor unbound tasks, so the agent can see what it set. Bound tasks leave it out, since the stored selection doesn't decide their model. - The resolver gets the project's workspace root. Main's resolver now needs it to see models that exist only in a workspace, and
delegate_taskpasses its parent's the same way. - The MCP tool-list byte budget goes up by 414 bytes (59052 to 59466). That's the
targetfield's structure with no descriptions. The first version carrieddelegate_task's descriptions and cost 605. The evals below show agents fill the field in correctly without them, so I dropped them. The Agent context budget check stays red until a maintainer adds theagent-context-increaselabel.
Scope and approval#
There is no issue or discussion. I'm filing this as focused configuration of an established capability:
- What exists. Scheduled tasks already store a
modelSelectionwith options and launch runs with it. The web and mobile forms let users set it.schedule_taskis the agent's way in, anddelegate_taskandcreate_threadsalready accept this sametargetand validate it the same way. - What it controls. Only the stored
modelSelectionof an unbound task. Nothing about how or when tasks run changes. Omittingtargetkeeps today's behaviour on both create and update. - Why it stays inside that capability. No new workflow and no changed default. It's parity between the agent and the user for a field both can already see. Bound-task behaviour from #18467 is unchanged; this PR refuses the input there instead of storing something that would mislead.
The web picker's handling of these options is a separate PR, #30729. This PR touches only the MCP path.
Verification#
Server tests in apps/server/src/mcp/OrchestratorMcpService.test.ts, new block "the model of a scheduled task":
- create with a target that has options saves that model and options
- update with a target merges into the stored selection
- update without a target keeps the stored selection
- the summary reports the saved target
- a bound task refuses a target and its summary omits
target - one update can unbind a task and set a target
- an unknown model (
model_unavailable) and an unknown option value (invalid_request) are refused on create and update, and nothing is saved - a provider instance the project disables is refused (
provider_unavailable) - a target steps the runtime mode down to one its provider offers, on create and update; an update without a target keeps the stored mode
- a complete target works on a project with no default model
vp test run src/mcp/OrchestratorMcpService.test.ts -t "the model of a scheduled task" with upstream/main's contracts, service and handler: 7 failed, 1 passed. The disabled-provider, runtime-mode and no-default-model tests were added after CodeRabbit's reviews; each fails without its fix. The one that passes is "update without a target keeps the stored selection", which is today's behaviour. With this branch all 68 tests in the file pass. vp run check:changed passes (format, lint, knip, typecheck, tests).
Runtime transcript. I started a dev server from this worktree with its own .t3 (empty DB, not seeded). A throwaway project pointed at a scratch git repo, Codex default model. I called the tools over /mcp with an MCP client session issued the way t3 thread does it:
$ schedule_task {projectId, schedule: daily, enabled: false, bindToCurrentThread: false,
target: {model: "gpt-6-luna", options: {reasoningEffort: "low", serviceTier: "priority"}}}
target {"providerInstanceId": "codex", "model": "gpt-6-luna", "options": [{"id": "reasoningEffort", "value": "low"}, {"id": "serviceTier", "value": "priority"}]}
$ schedule_task {scheduledTaskId, target: {options: {reasoningEffort: "medium"}}}
{"providerInstanceId": "codex", "model": "gpt-6-luna", "options": [{"id": "reasoningEffort", "value": "medium"}, {"id": "serviceTier", "value": "priority"}]}
$ schedule_task {scheduledTaskId, title: "Proof task 2b"} # no target
{"providerInstanceId": "codex", "model": "gpt-6-luna", "options": [{"id": "reasoningEffort", "value": "medium"}, {"id": "serviceTier", "value": "priority"}]}
$ schedule_task {scheduledTaskId, target: {options: {serviceTier: "turbo"}}}
invalid_request: Model gpt-6-luna on provider codex rejected options: Option serviceTier must be one of: default, priority.
$ schedule_task {scheduledTaskId, target: {model: "gpt-0"}}
model_unavailable: Model gpt-0 is not advertised by provider codex.
# scheduled_tasks row, read-only
('Proof task 2b', 0, '{"instanceId":"codex","model":"gpt-6-luna","options":[{"id":"reasoningEffort","value":"medium"},{"id":"serviceTier","value":"priority"}]}')
$ run_scheduled_task_now {taskId}
lastRunStatus succeeded
# provider event log, <worktree>/.t3/userdata/logs/provider/
turn/start {"model": "gpt-6-luna", "effort": "medium", "serviceTier": "priority"}
Evals. Three new cases in evals/mcp-tool-use/cases/orchestration.ndjson: pick a model for a new task (bad), switch an existing task to Sol with Fast on (bad), and move a task's time without touching its model (control).
I ran them on three versions of the schedule_task schema, all on current main, 10 samples per case and model. Passes out of 10:
| Case | Model | No target (main) | target, no descriptions (this PR) | target with descriptions |
|---|---|---|---|---|
| scheduled-task-picks-model | Sonnet 5.5 | 0 | 10 | 10 |
| scheduled-task-picks-model | Opus 5.5 | 0 | 10 | 10 |
| scheduled-task-changes-model | Sonnet 5.5 | 0 | 10 | 10 |
| scheduled-task-changes-model | Opus 5.5 | 0 | 10 | 10 |
| scheduled-task-keeps-model | Sonnet 5.5 | 10 | 10 | 10 |
| scheduled-task-keeps-model | Opus 5.5 | 10 | 10 | 10 |
| Tool-list bytes vs main | +0 | +414 | +605 |
With or without descriptions, the first schedule_task call in every sample carried the right model, and serviceTier: priority where the user asked for Fast. No sample errored. The 180 samples cost $8.39. The commands, each run's numbers and the first-call check are in this comment.
Earlier runs used the first version of the text, with descriptions, on an older main. On Codex (GPT-6.1 Sol and GPT-6 Astra, through CLIProxyAPI) the results were partial, because the eval's Haiku shell simulator hit an Anthropic spend limit. Graded samples: Sol 3/3 picks-model, 1/1 changes-model, 3/3 keeps-model; Astra 2/2 picks-model, 2/2 keeps-model. One full-suite run per Claude model was also partial for the same reason. Sonnet graded 223 of 299 samples and Opus 134 of 300 ($23.32). Every existing schedule case Sonnet reached passed. The graded misses were control-link-means-url (Sonnet 0/2), DEL-02 (Sonnet 2/3), DISC-01 (Opus 0/2) and delegates-then-new-thread-with-model (Opus 2/3). None of those samples loaded or called schedule_task, and I have no main baseline for them.
Not checked:
- A bound-task refusal over a real MCP call. My client session isn't attached to a thread, so it can't create a bound task. The unit tests cover this path.
- Codex models and the full suite on the final text. The three-arm run above is Claude only.
- Whether agents know a target needs an unbound task. The one case that needs
bindToCurrentThread: falsesays "a fresh thread each run" in its prompt, and the eval's mock never refuses. The server's refusal names the fix. - A target naming a workspace-only model. The resolver gets the workspace root, but no test here uses such a model.
- The runtime-mode step-down over a real MCP call. The unit test covers it.
Reviewed with review-loop: 3 rounds with GPT-6.1 Sol. Verdict: approved. Round 1 found that bound tasks ignore a stored target. The fix is the bound-task refusal above, not a change to #18467. Round 3 covered the disabled-provider check. A further round on the runtime-mode and no-default-model fixes: 1 round with GPT-6.1 Sol, verdict approved.
Created with Claude Opus 5.5 and Claude Fable 5.2 in Claude Code (T3 Code).
🤖 Generated with Claude Code
- 1
- 2
Pushed6b95186
Pushed9b9eee2
Note
🤖 Claude Fable 5.2 responding on behalf of Mezzle
Closing in favour of #35002. It fixes the same bug, #16833, with the same
targetfield, and it needs no context budget increase.I left the eval results from this PR on #35002, along with the two cases it does not cover yet: a provider instance the project has disabled, and a runtime mode the target's provider lacks.
Mezzle(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Note
🤖 Claude Fable 5.2 responding on behalf of Mezzle
The
targetdescriptions onschedule_taskdid not earn their bytes, so I removed them. The increase is now 414 bytes instead of 605.I ran three versions of the schema on current main. Same three cases, 10 samples per case, on Sonnet 5.5 and Opus 5.5.
targetfieldtargetwith no descriptionstargetwithdelegate_task's descriptionsThe field is needed. Without it both models fail every sample that asks for a model. The descriptions are not. In both versions that have the field, the first
schedule_taskcall of every sample carried the right model, andserviceTier: prioritywhere the user asked for Fast. No sample errored. The runs cost $8.39.Two limits. The cases only weakly test whether an agent knows a target needs an unbound task, since the one prompt that needs
bindToCurrentThread: falseasks for a fresh thread each run. And these are Claude models only.9b9eee2729 has the change. I also merged main, which cleared the conflict. The Agent context budget check still needs the
agent-context-increaselabel for the remaining 414 bytes.Reproduce
Setup, once:
9b9eee2729and runvp i.ANTHROPIC_API_KEYin the repo root.env. It pays for the Claude models and the Haiku shell simulator.[model_providers.vibeproxy]in~/.codex/config.tomlat it, asevals/mcp-tool-use/README.mddescribes.The three schemas differ only in
packages/contracts/src/orchestratorMcp.ts. Pick one:Check which schema is in place. This needs no key:
Run the three cases. Repeat for each schema and each of
claude-sonnet-5-5,claude-opus-5-5,gpt-6.1-sol,gpt-6-astraandgpt-6-luna:I added
--concurrency 4to the GPT runs to keep the proxy under 12 samples in flight.Read the results:
The byte counts in the table come from the budget test. On the two schemas that are not this branch's, it fails and prints the measured value:
Put the file back when done:
git checkout HEAD -- packages/contracts/src/orchestratorMcp.ts.Each Claude run
All runs are on the merge of main into this branch. Only the one file differs, so the run summaries record the commit as
6b95186763-dirty. The shell simulator wasclaude-haiku-5-5.targettargetFirst
schedule_taskcall of each sample. "Right" means it had the model the user asked for, plusserviceTier: priorityin changes-model.schedule_taskcalls in 10 samples