π€― LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
π fix(task): let a run replace the task's pinned model (#22021)
Lobehub Coderdff86f9cdf6e
diff --git a/apps/cli/src/commands/task/lifecycle.test.ts b/apps/cli/src/commands/task/lifecycle.test.tsindex 8920147405c..69d616145b5 100644--- a/apps/cli/src/commands/task/lifecycle.test.ts+++ b/apps/cli/src/commands/task/lifecycle.test.ts@@ -182,6 +182,29 @@ describe('task lifecycle β following the agent stream', () => {process.exitCode = undefined;});+ it('task run sends --model and --provider only with the first topic', async () => {+ followAgentRun.mockResolvedValue({ kind: 'completed' });+ await createProgram().parseAsync([+ 'node',+ 'test',+ 'task',+ 'run',+ 'T-1',+ '--model',+ 'fixed-model',+ '--provider',+ 'working',+ '--topics',+ '2',+ ]);+ expect(client.task.run.mutate).toHaveBeenNthCalledWith(1, {+ id: 'T-1',+ model: 'fixed-model',+ provider: 'working',+ });+ expect(client.task.run.mutate).toHaveBeenNthCalledWith(2, { id: 'T-1' });+ });+it('task run --topics 2 stops with exit 1 when a run fails, without starting the next one', async () => {followAgentRun.mockResolvedValue({error: 'boom',diff --git a/apps/cli/src/commands/task/lifecycle.ts b/apps/cli/src/commands/task/lifecycle.tsindex aa2583f615e..969c68c6df5 100644--- a/apps/cli/src/commands/task/lifecycle.ts+++ b/apps/cli/src/commands/task/lifecycle.ts@@ -128,6 +128,11 @@ export function registerLifecycleCommands(task: Command) {.description('Run a task β trigger agent execution').option('-p, --prompt <text>', 'Additional context for the agent').option('-c, --continue <topicId>', 'Continue running on an existing topic')+ .option('--model <model>', "Replace the task's pinned model, for this run and later ones")+ .option(+ '--provider <provider>',+ "Provider of --model (default: the agent's provider, not checked against the model)",+ ).option('--device <target>','Target device ID, or use "local" for the current connected device',@@ -146,7 +151,9 @@ export function registerLifecycleCommands(task: Command) {device?: string;follow?: boolean;json?: boolean;+ model?: string;prompt?: string;+ provider?: string;topics?: string;verbose?: boolean;},@@ -198,6 +205,9 @@ export function registerLifecycleCommands(task: Command) {...(deviceId && { deviceId }),...(i === 0 && options.prompt && { prompt: options.prompt }),...(i === 0 && options.continue && { continueTopicId: options.continue }),+ // Persisted on the task, so later topics in this sequence inherit it.+ ...(i === 0 && options.model && { model: options.model }),+ ...(i === 0 && options.provider && { provider: options.provider }),})) as any;if (!result.success) {diff --git a/apps/server/src/routers/lambda/task/execution.test.ts b/apps/server/src/routers/lambda/task/execution.test.tsnew file mode 100644index 00000000000..197a8b35e80--- /dev/null+++ b/apps/server/src/routers/lambda/task/execution.test.ts@@ -0,0 +1,58 @@+// @vitest-environment node+import { beforeEach, describe, expect, it, vi } from 'vitest';++import { createTaskExecutionRouter } from './execution';++const mocks = vi.hoisted(() => ({ runTask: vi.fn() }));++vi.mock('@/server/services/taskRunner', () => ({+ TaskRunnerService: vi.fn().mockImplementation(function () {+ return { runTask: mocks.runTask };+ }),+}));+vi.mock('@/server/services/taskLifecycle/failStuckTasks', () => ({ failStuckTasks: vi.fn() }));+vi.mock('./procedures', async () => {+ const { z } = await import('zod');+ const { publicProcedure } = await import('@/libs/trpc/lambda');+ return {+ idInput: z.object({ id: z.string() }),+ taskProcedure: publicProcedure,+ taskProcedureWrite: publicProcedure,+ };+});++describe('task.run model override', () => {+ const caller = createTaskExecutionRouter().createCaller({+ taskModel: { resolve: async (id: string) => ({ id }) },+ userId: 'user-1',+ } as never);++ beforeEach(() => {+ mocks.runTask.mockReset();+ mocks.runTask.mockResolvedValue({ success: true });+ });++ it('forwards a trimmed model and provider to the runner', async () => {+ await caller.run({ id: 'task_1', model: ' fixed-model ', provider: 'working' });++ expect(mocks.runTask).toHaveBeenCalledWith(+ expect.objectContaining({ model: 'fixed-model', provider: 'working', taskId: 'task_1' }),+ );+ });++ it('treats blank values as not passed', async () => {+ await caller.run({ id: 'task_1', model: ' ', provider: '' });++ expect(mocks.runTask).toHaveBeenCalledWith(+ expect.objectContaining({ model: undefined, provider: undefined }),+ );+ });++ it('refuses a provider without a model before starting a run', async () => {+ await expect(caller.run({ id: 'task_1', provider: 'working' })).rejects.toMatchObject({+ code: 'BAD_REQUEST',+ });++ expect(mocks.runTask).not.toHaveBeenCalled();+ });+});diff --git a/apps/server/src/routers/lambda/task/execution.ts b/apps/server/src/routers/lambda/task/execution.tsindex a88cea39ed8..98e00a9e333 100644--- a/apps/server/src/routers/lambda/task/execution.ts+++ b/apps/server/src/routers/lambda/task/execution.ts@@ -19,11 +19,23 @@ export const createTaskExecutionRouter = (z.object({continueTopicId: z.string().optional(),deviceId: z.string().optional(),+ model: z.string().optional(),prompt: z.string().optional(),+ provider: z.string().optional(),}),),).mutation(async ({ input, ctx }) => {+ // Tool-calling models fill optional fields with "", which must not read as a choice.+ const model = input.model?.trim() || undefined;+ const provider = input.provider?.trim() || undefined;+ if (provider && !model) {+ throw new TRPCError({+ code: 'BAD_REQUEST',+ message: 'provider requires model: the Task model may not be served by that provider',+ });+ }+try {const task = await resolveTaskOrThrow(ctx.taskModel, input.id);@@ -36,6 +48,8 @@ export const createTaskExecutionRouter = (continueTopicId: input.continueTopicId,deviceId: input.deviceId,extraPrompt: input.prompt,+ model,+ provider,taskId: task.id,...(onOperationCreated ? { onOperationCreated } : {}),});diff --git a/apps/server/src/services/taskRunner/index.ts b/apps/server/src/services/taskRunner/index.tsindex 94d9b5ef3e3..8befdba0ef5 100644--- a/apps/server/src/services/taskRunner/index.ts+++ b/apps/server/src/services/taskRunner/index.ts@@ -3,7 +3,11 @@ import { AcceptanceEvidenceIdentifier } from '@lobechat/builtin-tool-acceptance-import { BriefIdentifier } from '@lobechat/builtin-tool-brief';import { INBOX_SESSION_ID } from '@lobechat/const';import type { ChatTopicMetadata, ExecAgentResult, TaskItem, TaskRunTrigger } from '@lobechat/types';-import { getHeterogeneousTaskModelProvider, readTaskExecutionConfig } from '@lobechat/types';+import {+ getHeterogeneousTaskModelProvider,+ readTaskExecutionConfig,+ resolveHeterogeneousModelOverride,+} from '@lobechat/types';import { TRPCError } from '@trpc/server';import debug from 'debug';@@ -48,8 +52,15 @@ export interface RunTaskParams {extraPrompt?: string;/** Optional per-operation cap. Omitted means the agent runtime remains uncapped. */maxSteps?: number;+ /**+ * Replaces the Task's pinned model once the run starts. Persisted on the Task, so+ * retries, continued runs and scheduled ticks stay on it instead of the old pin.+ */+ model?: string;/** Persist the dispatch owner's operation link before any execution starts. */onOperationCreated?: (operationId: string) => Promise<void>;+ /** Provider for `model`. Omitted means it resolves like a model-only Task override. */+ provider?: string;taskId: string;/*** What triggered this run. Defaults to `'manual'` β the ad-hoc "run now"@@ -159,7 +170,9 @@ export class TaskRunnerService {deviceId,extraPrompt,maxSteps,+ model,onOperationCreated,+ provider,trigger = 'manual',} = params;@@ -236,6 +249,27 @@ export class TaskRunnerService {}}+ // A heterogeneous runtime ignores a pair it cannot use, so the run would+ // report success on the Agent's own model. Refuse it before the Task moves.+ if (model) {+ const { heterogeneousProvider } =+ (await this.agentModel.getAgentAgencyConfig(task.assigneeAgentId!)) ?? {};+ if (+ heterogeneousProvider &&+ !resolveHeterogeneousModelOverride(heterogeneousProvider, {+ model,+ provider: provider ?? getHeterogeneousTaskModelProvider(heterogeneousProvider),+ })+ ) {+ throw new TRPCError({+ code: 'BAD_REQUEST',+ message: provider+ ? `This agent's runtime cannot run ${model} on provider ${provider}.`+ : `This agent's runtime cannot run ${model} without a provider it is bound to.`,+ });+ }+ }+const {acceptanceEnabled,fileIds: attachmentFileIds,@@ -321,6 +355,14 @@ export class TaskRunnerService {// the batch's plan skill β so a re-run or a manual run loads them too.pluginIds.push(...readTaskSkillIds(taskConfig));+ // The pin never follows later Agent changes, so a stale pin is corrected+ // here. A model-only override drops the previous provider and resolves one+ // from the assignee in the backfill below; that pairing is not checked+ // against what the provider serves.+ if (model) {+ Object.assign(taskConfig, { model, provider });+ }+// Backfill model snapshot for tasks created before the snapshot logic// landed, or whose assignee was set after creation. Once written, the// task is pinned to this model regardless of later agent default changes.@@ -334,7 +376,8 @@ export class TaskRunnerService {snapshot,getHeterogeneousTaskModelProvider(agencyConfig?.heterogeneousProvider),);- await this.taskModel.updateTaskConfig(task.id, missing);+ // A replacement is only written once its run starts, below.+ if (!model) await this.taskModel.updateTaskConfig(task.id, missing);Object.assign(taskConfig, missing);}}@@ -374,7 +417,7 @@ export class TaskRunnerService {);}- log('runTask: %s (continue=%s)', taskIdentifier, continueTopicId);+ log('runTask: %s (continue=%s, model=%s)', taskIdentifier, continueTopicId, model);const result = await aiAgentService.execAgent({...(onOperationCreated ? { onOperationCreated } : {}),@@ -448,6 +491,13 @@ export class TaskRunnerService {// fails below must not move its topic back to the previous machine.runAccepted = true;+ // Written only with the recorded run, so a replacement that cannot start never+ // costs the Task its previous pin, and a failed write cannot strand a live run.+ // `null` clears the stale provider when none was resolved.+ const replacedPin = model+ ? { model, provider: typeof taskConfig.provider === 'string' ? taskConfig.provider : null }+ : undefined;+if (result.topicId) {const topicId = result.topicId;// Record the run under the task's row lock (see TaskService.deleteTask).@@ -477,6 +527,7 @@ export class TaskRunnerService {trigger,});}+ if (replacedPin) await taskModel.updateTaskConfig(task.id, replacedPin);return 'recorded' as const;});if (recorded !== 'recorded') {@@ -504,6 +555,10 @@ export class TaskRunnerService {}}+ if (!result.topicId && replacedPin) {+ await this.taskModel.updateTaskConfig(task.id, replacedPin);+ }+await this.taskModel.updateHeartbeat(task.id);return {diff --git a/apps/server/src/services/taskRunner/runTask.modelSnapshot.test.ts b/apps/server/src/services/taskRunner/runTask.modelSnapshot.test.tsindex 2134b4ee58c..523289fb17b 100644--- a/apps/server/src/services/taskRunner/runTask.modelSnapshot.test.ts+++ b/apps/server/src/services/taskRunner/runTask.modelSnapshot.test.ts@@ -151,4 +151,140 @@ describe('TaskRunnerService.runTask model snapshot backfill', () => {/** @example No wrapper provider is attached to the dispatched call. */expect(mocks.execAgent.mock.calls[0][0]).not.toHaveProperty('provider');});++ // ROOT CAUSE:+ // The pin written at creation never follows the Agent, and run had no way to+ // replace it, so every retry kept dispatching the model the provider rejected.+ /** @example An explicit pair replaces a stale pin for this run and later ones. */+ it('replaces a stale pinned model with an explicit model and provider', async () => {+ setupTask({ model: 'stale-model', provider: 'blocked-provider' });+ mocks.getAgentAgencyConfig.mockResolvedValue({});++ await new TaskRunnerService(db, 'user-1').runTask({+ model: 'fixed-model',+ provider: 'working-provider',+ taskId: 'T-1',+ });++ expect(taskModel.updateTaskConfig).toHaveBeenCalledWith('task-1', {+ model: 'fixed-model',+ provider: 'working-provider',+ });+ expect(mocks.execAgent).toHaveBeenCalledWith(+ expect.objectContaining({ model: 'fixed-model', provider: 'working-provider' }),+ );+ });++ /** @example A model-only override never inherits the provider of the model it replaces. */+ it('resolves a model-only override without keeping the stale provider', async () => {+ setupTask({ model: 'stale-model', provider: 'blocked-provider' });+ mocks.getAgentModelConfig.mockResolvedValue({+ model: 'agent-model',+ provider: 'agent-provider',+ });+ mocks.getAgentAgencyConfig.mockResolvedValue({});++ await new TaskRunnerService(db, 'user-1').runTask({ model: 'fixed-model', taskId: 'T-1' });++ expect(taskModel.updateTaskConfig).toHaveBeenCalledTimes(1);+ expect(taskModel.updateTaskConfig).toHaveBeenCalledWith('task-1', {+ model: 'fixed-model',+ provider: 'agent-provider',+ });+ expect(mocks.execAgent).toHaveBeenCalledWith(+ expect.objectContaining({ model: 'fixed-model', provider: 'agent-provider' }),+ );+ });++ /** @example A replacement that cannot start leaves the previous pin in place. */+ it('keeps the previous pin when the replacement run fails to start', async () => {+ setupTask({ model: 'stale-model', provider: 'blocked-provider' });+ mocks.getAgentAgencyConfig.mockResolvedValue({});+ mocks.execAgent.mockResolvedValue({ error: 'unknown model', success: false });++ await expect(+ new TaskRunnerService(db, 'user-1').runTask({+ model: 'typo-model',+ provider: 'working-provider',+ taskId: 'T-1',+ }),+ ).rejects.toThrow('unknown model');++ expect(taskModel.updateTaskConfig).not.toHaveBeenCalled();+ });++ /** @example A pair the runtime would silently ignore is refused before dispatch. */+ it('refuses a pair a heterogeneous runtime cannot use', async () => {+ setupTask({ model: 'stale-model', provider: 'codex' });++ await expect(+ new TaskRunnerService(db, 'user-1').runTask({+ model: 'gpt-5.4',+ provider: 'openai',+ taskId: 'T-1',+ }),+ ).rejects.toMatchObject({ code: 'BAD_REQUEST' });++ expect(mocks.execAgent).not.toHaveBeenCalled();+ expect(taskModel.updateTaskConfig).not.toHaveBeenCalled();+ /** @example A refused input leaves the Task's status untouched. */+ expect(taskModel.updateStatusIfCurrent).not.toHaveBeenCalled();+ expect(taskModel.updateStatus).not.toHaveBeenCalled();+ });++ /** @example A server-default API binding cannot apply a model-only override. */+ it('refuses a model-only override a server-default binding cannot use', async () => {+ setupTask({ model: 'stale-model', provider: 'personal-provider' });+ mocks.getAgentAgencyConfig.mockResolvedValue({+ heterogeneousProvider: { authMode: 'api', type: 'codex' },+ });++ await expect(+ new TaskRunnerService(db, 'user-1').runTask({ model: 'gpt-5.4', taskId: 'T-1' }),+ ).rejects.toMatchObject({ code: 'BAD_REQUEST' });++ expect(mocks.execAgent).not.toHaveBeenCalled();+ expect(taskModel.updateStatusIfCurrent).not.toHaveBeenCalled();+ });++ /** @example A native runtime still accepts a model-only override. */+ it('accepts a model-only override on a native heterogeneous runtime', async () => {+ setupTask({ model: 'stale-model', provider: 'codex' });++ await new TaskRunnerService(db, 'user-1').runTask({ model: 'gpt-5.4', taskId: 'T-1' });++ expect(taskModel.updateTaskConfig).toHaveBeenCalledWith('task-1', {+ model: 'gpt-5.4',+ provider: 'codex',+ });+ });++ /** @example A run withdrawn during startup does not replace the pin. */+ it('keeps the previous pin when the run is withdrawn before it is recorded', async () => {+ setupTask({ model: 'stale-model', provider: 'blocked-provider' });+ mocks.getAgentAgencyConfig.mockResolvedValue({});+ taskModel.findById.mockResolvedValue({ id: 'task-1', status: 'canceled' });++ await expect(+ new TaskRunnerService(db, 'user-1').runTask({+ model: 'fixed-model',+ provider: 'working-provider',+ taskId: 'T-1',+ }),+ ).rejects.toThrow();++ expect(taskModel.updateTaskConfig).not.toHaveBeenCalled();+ });++ /** @example Without an override the run keeps the pinned pair and writes nothing. */+ it('keeps the pinned pair when no override is passed', async () => {+ setupTask({ model: 'pinned-model', provider: 'pinned-provider' });++ await new TaskRunnerService(db, 'user-1').runTask({ taskId: 'T-1' });++ expect(taskModel.updateTaskConfig).not.toHaveBeenCalled();+ expect(mocks.execAgent).toHaveBeenCalledWith(+ expect.objectContaining({ model: 'pinned-model', provider: 'pinned-provider' }),+ );+ });});diff --git a/apps/server/src/services/toolExecution/serverRuntimes/task.refs.test.ts b/apps/server/src/services/toolExecution/serverRuntimes/task.refs.test.tsindex 2be8dd82aaf..40732a28cbd 100644--- a/apps/server/src/services/toolExecution/serverRuntimes/task.refs.test.ts+++ b/apps/server/src/services/toolExecution/serverRuntimes/task.refs.test.ts@@ -58,6 +58,16 @@ describe('task runtime canonical references', () => {expect(write).toHaveBeenCalledTimes(11);},);+ it('passes a replacement model through runTask and every runTasks item', async () => {+ const { run, runtime } = setup();+ await runtime.runTask({ identifier: 'T-1', model: 'fixed-model', provider: 'working' });+ expect(run).toHaveBeenLastCalledWith(+ expect.objectContaining({ id: 'task_1', model: 'fixed-model', provider: 'working' }),+ );+ await runtime.runTasks({ identifiers: ['T-2', 'T-3'], model: 'fixed-model' });+ expect(run).toHaveBeenCalledWith({ id: 'task_2', model: 'fixed-model' });+ expect(run).toHaveBeenCalledWith({ id: 'task_3', model: 'fixed-model' });+ });it('resolves a run ref before calling the router and returns canonical state', async () => {const { run, runtime } = setup();const result = await runtime.runTask({diff --git a/apps/server/src/services/toolExecution/serverRuntimes/task.ts b/apps/server/src/services/toolExecution/serverRuntimes/task.tsindex ded45116638..3c1a93edbda 100644--- a/apps/server/src/services/toolExecution/serverRuntimes/task.ts+++ b/apps/server/src/services/toolExecution/serverRuntimes/task.ts@@ -778,7 +778,13 @@ export const createTaskRuntime = (deps: TaskRuntimeDeps) => {return taskResult(task, formatTaskEdited(taskResultLabel(task), changes));},- runTask: async (args: { continueTopicId?: string; identifier?: string; prompt?: string }) => {+ runTask: async (args: {+ continueTopicId?: string;+ identifier?: string;+ model?: string;+ prompt?: string;+ provider?: string;+ }) => {const id = args.identifier?.trim() || taskId;if (!id) {return {@@ -792,7 +798,9 @@ export const createTaskRuntime = (deps: TaskRuntimeDeps) => {const result = await taskCaller().run({continueTopicId: args.continueTopicId,id: task.id,+ model: args.model,prompt: args.prompt,+ provider: args.provider,});const topicId = (result as { topicId?: string } | undefined)?.topicId;@@ -808,7 +816,7 @@ export const createTaskRuntime = (deps: TaskRuntimeDeps) => {}},- runTasks: async (args: { identifiers: string[] }) => {+ runTasks: async (args: { identifiers: string[]; model?: string; provider?: string }) => {const identifiers = Array.isArray(args.identifiers)? args.identifiers.filter((value): value is string => typeof value === 'string' && !!value.trim(),@@ -832,7 +840,7 @@ export const createTaskRuntime = (deps: TaskRuntimeDeps) => {for (const task of resolved.tasks) {const refs = identifiers.filter((ref) => resolved.byRef.get(ref)?.id === task.id);try {- await taskCaller().run({ id: task.id });+ await taskCaller().run({ id: task.id, model: args.model, provider: args.provider });results.push({ taskId: task.id, identifier: task.identifier, refs, success: true });} catch (error) {results.push({diff --git a/packages/builtin-tool-task/src/client/executor/index.ts b/packages/builtin-tool-task/src/client/executor/index.tsindex 2622ec41d79..0733067b02e 100644--- a/packages/builtin-tool-task/src/client/executor/index.ts+++ b/packages/builtin-tool-task/src/client/executor/index.ts@@ -916,7 +916,13 @@ class TaskExecutor extends BaseExecutor<typeof TaskApiName> {};runTask = async (- params: { continueTopicId?: string; identifier?: string; prompt?: string },+ params: {+ continueTopicId?: string;+ identifier?: string;+ model?: string;+ prompt?: string;+ provider?: string;+ },ctx?: BuiltinToolContext,): Promise<BuiltinToolResult> => {const identifier = params.identifier?.trim() || ctx?.taskId || undefined;@@ -933,7 +939,9 @@ class TaskExecutor extends BaseExecutor<typeof TaskApiName> {const target = (await taskService.find(identifier)).data;const result = await taskService.run(target.id, {continueTopicId: params.continueTopicId,+ model: params.model,prompt: params.prompt,+ provider: params.provider,});const topicId = (result as { topicId?: string } | undefined)?.topicId;@@ -969,7 +977,7 @@ class TaskExecutor extends BaseExecutor<typeof TaskApiName> {};runTasks = async (- params: { identifiers: string[] },+ params: { identifiers: string[]; model?: string; provider?: string },_ctx?: BuiltinToolContext,): Promise<BuiltinToolResult> => {const identifiers = Array.isArray(params.identifiers)@@ -1014,7 +1022,9 @@ class TaskExecutor extends BaseExecutor<typeof TaskApiName> {}for (const task of byId.values()) {try {- const result = await taskService.run(task.id);+ const result = await (params.model || params.provider+ ? taskService.run(task.id, { model: params.model, provider: params.provider })+ : taskService.run(task.id));results.push({identifier: task.identifier,taskId: task.id,diff --git a/packages/builtin-tool-task/src/client/executor/runTasks.test.ts b/packages/builtin-tool-task/src/client/executor/runTasks.test.tsindex 5aa222b911e..8904184348b 100644--- a/packages/builtin-tool-task/src/client/executor/runTasks.test.ts+++ b/packages/builtin-tool-task/src/client/executor/runTasks.test.ts@@ -42,6 +42,24 @@ describe('TaskExecutor batch references', () => {expect(result.content).toContain('Ambiguous task reference');expect(mocks.run).not.toHaveBeenCalled();});+ it('passes a replacement model to the run of every batch item', async () => {+ await taskExecutor.runTasks({+ identifiers: ['T-1'],+ model: 'fixed-model',+ provider: 'working',+ });+ expect(mocks.run).toHaveBeenCalledWith('task_1', {+ model: 'fixed-model',+ provider: 'working',+ });+ });+ it('passes a replacement model to a single run', async () => {+ await taskExecutor.runTask({ identifier: 'T-1', model: 'fixed-model', provider: 'working' });+ expect(mocks.run).toHaveBeenCalledWith(+ 'task_1',+ expect.objectContaining({ model: 'fixed-model', provider: 'working' }),+ );+ });it('includes lookup and kickoff failures in the model-visible content', async () => {mocks.find.mockRejectedValueOnce(new Error('Task not found: T-9'));mocks.run.mockRejectedValueOnce(new Error('Already running'));diff --git a/packages/builtin-tool-task/src/manifest.ts b/packages/builtin-tool-task/src/manifest.tsindex d5b3f5c4a5b..df049282fd2 100644--- a/packages/builtin-tool-task/src/manifest.ts+++ b/packages/builtin-tool-task/src/manifest.ts@@ -355,11 +355,21 @@ export const TaskManifest: BuiltinToolManifest = {'The task identifier to run (e.g. "T-1"). Accepts identifiers or ids returned by previous results; prefer stable ids.',type: 'string',},+ model: {+ description:+ "A task stays on the model pinned when it was created; changing the agent's model later does not move it. Set this only when the user names the model to use; never pick one yourself. It replaces the pin once the run starts, so later runs stay on it.",+ type: 'string',+ },prompt: {description:'Optional extra prompt prepended to the task instruction for this run only.',type: 'string',},+ provider: {+ description:+ "Provider of model. Requires model. When omitted, the assignee agent's provider is used without checking that it serves model.",+ type: 'string',+ },},required: ['identifier'],type: 'object',@@ -377,6 +387,16 @@ export const TaskManifest: BuiltinToolManifest = {items: { type: 'string' },type: 'array',},+ model: {+ description:+ "Applied to every task in the batch. A task stays on the model pinned when it was created; changing the agent's model later does not move it. Set this only when the user names the model to use; never pick one yourself. It replaces the pin once the run starts, so later runs stay on it.",+ type: 'string',+ },+ provider: {+ description:+ "Provider of model. Requires model. When omitted, the assignee agent's provider is used without checking that it serves model.",+ type: 'string',+ },},required: ['identifiers'],type: 'object',diff --git a/packages/builtin-tool-task/src/types.ts b/packages/builtin-tool-task/src/types.tsindex 6ec0900564b..312949e32c1 100644--- a/packages/builtin-tool-task/src/types.ts+++ b/packages/builtin-tool-task/src/types.ts@@ -252,8 +252,12 @@ export interface RunTaskParams {/** Optional existing topic to continue (rather than creating a new topic). */continueTopicId?: string;identifier: string;+ /** Replaces the task's pinned model, for this run and later ones. */+ model?: string;/** Optional extra prompt prepended to the task instruction for this run. */prompt?: string;+ /** Provider for `model`. Omit to resolve it from the assignee agent. */+ provider?: string;}export interface RunTaskState {@@ -267,6 +271,10 @@ export interface RunTaskState {export interface RunTasksParams {/** Identifiers of tasks to run, in execution order. */identifiers: string[];+ /** Replaces the pinned model of every task in the batch, for this run and later ones. */+ model?: string;+ /** Provider for `model`. Omit to resolve it from the assignee agent. */+ provider?: string;}export interface RunTasksItemResult {diff --git a/src/services/task.ts b/src/services/task.tsindex 482a66b8e62..5db51057d45 100644--- a/src/services/task.ts+++ b/src/services/task.ts@@ -197,8 +197,10 @@ class TaskService {updateStatusCascade = async (id: string, status: 'canceled' | 'completed') =>lambdaClient.task.updateStatusCascade.mutate({ id, status });- run = async (id: string, params?: { continueTopicId?: string; prompt?: string }) =>- lambdaClient.task.run.mutate({ id, ...params });+ run = async (+ id: string,+ params?: { continueTopicId?: string; model?: string; prompt?: string; provider?: string },+ ) => lambdaClient.task.run.mutate({ id, ...params });previewSubtaskLayers = async (id: string) => lambdaClient.task.previewSubtaskLayers.query({ id });