Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat(mcp): agents can pick a scheduled task's model, effort and Fast tier #30808

ClosedMezzle(GitHub profile, opens in a new tab)wants to merge 17 commits intomain fromrefs/pull/30808/headopened View on GitHub

Mezzle(GitHub profile, opens in a new tab)commented

Problem

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 code delegate_task uses. 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 new model starts 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 to approval-required and wait. The saved mode now steps down to the broadest mode that provider offers, with delegate_task's rule for an inherited mode. Without a target the mode is unchanged.
  • A caller outside a thread can pass a complete target (providerInstanceId and model) 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 pass bindToCurrentThread: false. An update can unbind and set a target in the same call.
  • The task summary returned by schedule_task and list_scheduled_tasks now includes target for 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_task passes its parent's the same way.
  • The MCP tool-list byte budget goes up by 414 bytes (59052 to 59466). That's the target field's structure with no descriptions. The first version carried delegate_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 the agent-context-increase label.

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 modelSelection with options and launch runs with it. The web and mobile forms let users set it. schedule_task is the agent's way in, and delegate_task and create_threads already accept this same target and validate it the same way.
  • What it controls. Only the stored modelSelection of an unbound task. Nothing about how or when tasks run changes. Omitting target keeps 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:

CaseModelNo target (main)target, no descriptions (this PR)target with descriptions
scheduled-task-picks-modelSonnet 5.501010
scheduled-task-picks-modelOpus 5.501010
scheduled-task-changes-modelSonnet 5.501010
scheduled-task-changes-modelOpus 5.501010
scheduled-task-keeps-modelSonnet 5.5101010
scheduled-task-keeps-modelOpus 5.5101010
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: false says "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. Pushed6b95186

    2. Pushed9b9eee2

    3. Mezzle(GitHub profile, opens in a new tab)commented

      Note

      🤖 Claude Fable 5.2 responding on behalf of Mezzle

      The target descriptions on schedule_task did 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.

      SchemaTool-list bytes vs mainModel cases passedControl passed
      No target field+00/4020/20
      target with no descriptions+41440/4020/20
      target with delegate_task's descriptions+60540/4020/20

      The 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_task call of every sample carried the right model, and serviceTier: priority where 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: false asks 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-increase label for the remaining 414 bytes.

      Reproduce

      Setup, once:

      1. Check out this branch at 9b9eee2729 and run vp i.
      2. Put ANTHROPIC_API_KEY in the repo root .env. It pays for the Claude models and the Haiku shell simulator.
      3. For the GPT models, run CLIProxyAPI and point [model_providers.vibeproxy] in ~/.codex/config.toml at it, as evals/mcp-tool-use/README.md describes.

      The three schemas differ only in packages/contracts/src/orchestratorMcp.ts. Pick one:

      # No descriptions: the branch as it is
      git checkout 9b9eee2729 -- packages/contracts/src/orchestratorMcp.ts
      # With descriptions: the commit before I removed them
      git checkout 6b95186763 -- packages/contracts/src/orchestratorMcp.ts
      # No target field: main's copy
      git checkout 1cedd4b4ed -- packages/contracts/src/orchestratorMcp.ts

      Check which schema is in place. This needs no key:

      cd evals
      pnpm mcp-tool-use --context
      # full tool schemas: 60432 chars with no target, 60846 with no descriptions, 61037 with descriptions

      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-astra and gpt-6-luna:

      pnpm mcp-tool-use --model claude-sonnet-5-5 \
        --case scheduled-task-picks-model \
        --case scheduled-task-changes-model \
        --case scheduled-task-keeps-model \
        --samples 10 --out runs/<schema>-<model>

      I added --concurrency 4 to the GPT runs to keep the proxy under 12 samples in flight.

      Read the results:

      # pass rate per case, cost, errored samples
      cat runs/<schema>-<model>/summary.md
      # the target each sample sent on its first schedule_task call
      jq -c 'select(.id != "scheduled-task-keeps-model")
        | [.id, .pass, ([.calls[] | select(.tool == "schedule_task")][0].input.target)]' \
        runs/<schema>-<model>/results.jsonl

      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:

      cd apps/server
      vp test run src/provider/AgentContextBudget.test.ts
      # mcpToolListJsonBytes: 59052 with no target, 59466 with no descriptions, 59657 with descriptions

      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 was claude-haiku-5-5.

      SchemaModelTool schema charspicks-modelchanges-modelkeeps-modelErrored samplesModel calls per sampleCost
      No targetSonnet 5.5604320/100/1010/1003.4$0.98
      No targetOpus 5.5604320/100/1010/1003.2$2.32
      No descriptionsSonnet 5.56084610/1010/1010/1003.5$0.92
      No descriptionsOpus 5.56084610/1010/1010/1004.0$1.62
      With descriptionsSonnet 5.56103710/1010/1010/1003.5$0.91
      With descriptionsOpus 5.56103710/1010/1010/1004.1$1.64

      First schedule_task call of each sample. "Right" means it had the model the user asked for, plus serviceTier: priority in changes-model.

      SchemaModelCaseFirst call rightschedule_task calls in 10 samples
      No descriptionsSonnet 5.5scheduled-task-picks-model10/1010
      No descriptionsSonnet 5.5scheduled-task-changes-model10/1010
      No descriptionsOpus 5.5scheduled-task-picks-model10/1010
      No descriptionsOpus 5.5scheduled-task-changes-model10/1010
      With descriptionsSonnet 5.5scheduled-task-picks-model10/1010
      With descriptionsSonnet 5.5scheduled-task-changes-model10/1010
      With descriptionsOpus 5.5scheduled-task-picks-model10/1011
      With descriptionsOpus 5.5scheduled-task-changes-model10/1010
    4. Note

      🤖 Claude Fable 5.2 responding on behalf of Mezzle

      Closing in favour of #35002. It fixes the same bug, #16833, with the same target field, 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.

Sign in to join this conversation.