fix(server): agents can choose the model for a scheduled task #19143
Closedspadaval(GitHub profile, opens in a new tab)wants to merge 6 commits into
main fromrefs/pull/19143/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- apps/server/src/mcp/OrchestratorMcpService.test.ts line 2235OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -2171,0 +2215,21 @@2215+ NodeServices.layer,2216+ Layer.mock(ThreadManagementService.ThreadManagementService)({2217+ getThreadRecords: () => Effect.succeed(parentProjection([], callerSelection)),2218+ isProviderInstanceEnabledForProject: () => Effect.succeed(enabledForProject),2219+ }),2220+ providerRegistryLayer([2221+ {2222+ ...codex,2223+ models: [2224+ ...codex.models,2225+ { slug: miniModel, name: miniModel, isCustom: false, capabilities: null },2226+ ],2227+ },2228+ ]),2229+ adapterRegistryLayer([codexInstanceId]),2230+ Layer.mock(ProjectService.ProjectService)({2231+ getById: () => Effect.succeedSome({ id: projectId } as never),2232+ }),2233+ Layer.mock(SecretRequests.SecretRequests)({}),2234+ Layer.mock(ScheduledTaskService.ScheduledTaskService)({2235+ list: () => Effect.succeed({ tasks: [stored] }),apps/server/src/mcp/OrchestratorMcpService.ts line 1766OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -1711,3 +1760,7 @@17111760 : input.bindToCurrentThread && parent !== undefined17121761 ? parent.thread.id17131762 : null;1763+ const modelSelection =1764+ input.target === undefined1765+ ? existing.modelSelection1766+ : yield* resolveScheduledTaskModelSelection({apps/server/src/mcp/toolkits/orchestrator/tools.ts line 119OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -116,4 +116,4 @@116116117117 export const ScheduleTaskTool = Tool.make("schedule_task", {118118 description:119- "Create persistent work in the app scheduler that runs even when no turn is active. Pass schedule as a STRUCTURED OBJECT, never JSON text. Timers: {type:'interval', everyMs:3600000} is hourly; {type:'fixed_time', timeOfDay:'09:00', weekdays:[1,2,3,4,5]} is weekday mornings; report the returned nextRunAt. Webhooks: {type:'webhook'} runs once per request to a generated URL. The run sees the request ONLY through prompt placeholders: {{body.path}} (e.g. {{body.action}}, {{body.release.tag_name}}), {{headers.name}}, {{query.name}}, {{body}}, or {{request}} (method, headers with credentials redacted, and body). For a sender that signs requests, first call request_secret so the user enters the secret privately (never ask for it in chat or invent one), then set signature with the returned secretRef, e.g. GitHub: {type:'webhook', signature:{header:'x-hub-signature-256', encoding:'hex', prefix:'sha256=', secretRef}}. The result's webhookUrl is the public URL to give the user; if it is absent119+ "Create persistent work in the app scheduler that runs even when no turn is active. Pass schedule as a STRUCTURED OBJECT, never JSON text. Timers: {type:'interval', everyMs:3600000} is hourly; {type:'fixed_time', timeOfDay:'09:00', weekdays:[1,2,3,4,5]} is weekday mornings; report the returned nextRunAt. Webhooks: {type:'webhook'} runs once per request to a generated URL. The run sees the request ONLY through prompt placeholders: {{body.path}} (e.g. {{body.action}}, {{body.release.tag_name}}), {{headers.name}}, {{query.name}}, {{body}}, or {{request}} (method, headers with credentials redacted, and body). For a sender that signs requests, first call request_secret so the user enters the secret privately (never ask for it in chat or invent one), then set signature with the returned secretRef, e.g. GitHub: {type:'webhook', signature:{header:'x-hub-signature-256', encoding:'hex', prefix:'sha256=', secretRef}}. The result's webhookUrl is the public URL to give the user; if it is absent
- packages/contracts/src/orchestratorMcp.ts lines 608 to 609OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -592,3 +603,7 @@592603 schedule: Schema.optional(OrchestratorMcpSchedule),593604 enabled: Schema.optional(Schema.Boolean),594605 bindToCurrentThread: Schema.optional(Schema.Boolean),606+ /**607+ * Changes the provider, model, or options the task's runs use. Resolved608+ * like a delegated task's target, against the task's stored selection: a609+ * field left out keeps its stored value while the provider stays the same.
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:M
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
juliusmarminge assignedjuliusmarminge
juliusmarminge closed this
Sign in to join this conversation.
Warning
Review limit reached#
Only developers with an assigned seat can use this organization's usage-based review budget, and seats here are assigned manually. Ask an admin to assign a seat, or change the review continuation mode in Billing.
Next included review available in 2 minutes.
Check out review usage here.
View limit details
Limit details: You’ve used all 10 included reviews currently available.
Learn how review limits work.
Review configuration:
⚙️ Run configuration
4b3ae550-c773-42d8-a0d4-9b57ff204811📥 Commits
Reviewing files that changed from the base of the PR and between 734ebbeb24358a74f51dc55c6fc37d4d9a8bd952 and e1ad4391f91f2dd20a6283b8fa132ed7e74633dd.
📒 Files selected for processing: 4
apps/server/src/mcp/OrchestratorMcpService.test.tsapps/server/src/mcp/OrchestratorMcpService.tsapps/server/src/mcp/toolkits/orchestrator/tools.tspackages/contracts/src/orchestratorMcp.ts📝 Walkthrough
MCP scheduled-task creation and updates now accept an optional provider and model target. Scheduled-task results include provider, model, options, runtime mode, and interaction mode. Tests cover inherited and explicit selections, updates, and target-resolution failures.
Changes: Scheduled-task model selection
packages/contracts/src/orchestratorMcp.ts,apps/server/src/mcp/toolkits/orchestrator/tools.tsapps/server/src/mcp/OrchestratorMcpService.ts,apps/server/src/mcp/OrchestratorMcpService.test.tsPriority: ➖ Normal
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix · Severity of issue fixed: Medium
Sequence Diagram(s)#
Suggested reviewers:
t3dotgg,juliusmarmingeMerge Risk: 🔵 Low · up to
734ebA provider-only update can leave a task with a model the provider does not advertise, and the MCP description can lead agents to expect a different model than the task will use. These issues are bounded, but should be corrected to avoid misconfigured tasks.
Security architecture risk: 🔵 Low · up to
734ebThe new execution choices remain subject to existing permission limits and project restrictions. No introduced security bypass was verified, but configuration edge cases and incomplete downstream coverage leave limited uncertainty.
Retained concerns No architecture-level concerns identified.
Security review details
Security Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
Pre-merge checks:
4
#16833requires MCP control of a scheduled task's provider, model, and options, plus visible selection data. The contract adds optionaltargetfields to create and update. The service resolves…#16833. The PR does not change thread-bo…Full details: Linked Issues check
Explanation
Issue
#16833requires MCP control of a scheduled task's provider, model, and options, plus visible selection data. The contract adds optionaltargetfields to create and update. The service resolves targets, checks provider enablement and model availability, preserves existing behavior whentargetis omitted, and returns provider, model, options, runtime mode, and interaction mode in all scheduled-task summaries. The reported tests cover inheritance, retargeting, summaries, and rejection cases. Unknown-key rejection is optional and is explicitly excluded.Full details: Out of Scope Changes check
Explanation
The changes are limited to scheduled-task MCP contracts, target resolution and persistence, tool descriptions, and focused tests. These changes implement issue
#16833. The PR does not change thread-bound run behavior or add runtime or interaction mode setters. No unrelated change is demonstrated.Full details: Description check
Explanation
The description explains the problem, implementation, scope, linked issue, verification results, limitations, and agent involvement. It does not use the template headings and does not provide a direct maintainer-approval comment link, but the required information is otherwise substantially covered.
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment `@coderabbitai help` to get the list of available commands.