diff --git a/apps/coder/src/services/tools/new_task.ts b/apps/coder/src/services/tools/new_task.ts index 026fcec..9867eed 100644 --- a/apps/coder/src/services/tools/new_task.ts +++ b/apps/coder/src/services/tools/new_task.ts @@ -6,6 +6,7 @@ const NewTaskInput = z.object({ input: z.string().min(1).describe('Task description for the child subtask'), agent: z.string().optional().describe('Optional: dispatch to a specific agent'), model: z.string().optional().describe('Optional: model override for the subtask'), + background: z.boolean().optional().describe('If true, return immediately without blocking on completion'), }); type NewTaskInputT = z.infer; @@ -30,6 +31,7 @@ export const newTaskTool: ToolDef = { input: { type: 'string', description: 'Task description for the child subtask' }, agent: { type: 'string', description: 'Optional: dispatch to a specific agent' }, model: { type: 'string', description: 'Optional: model override for the subtask' }, + background: { type: 'boolean', description: 'If true, returns immediately without waiting' }, }, required: ['input'], }, @@ -50,6 +52,7 @@ export const newTaskTool: ToolDef = { return { error: 'Cannot determine project_id from current session' }; } + const isBg = input.background === true; const [task] = await sql<{ id: string; state: string }[]>` INSERT INTO tasks (project_id, parent_task_id, input, agent, model) VALUES (${session.project_id}, ${currentTaskId}, ${input.input}, ${input.agent ?? null}, ${input.model ?? null}) @@ -57,9 +60,12 @@ export const newTaskTool: ToolDef = { `; return { - message: `Subtask created (id: ${task!.id}). It will run in isolation. Use check_task_status to monitor.`, + message: isBg + ? `Background subtask created (id: ${task!.id}). It will continue independently.` + : `Subtask created (id: ${task!.id}). It will run in isolation. Use check_task_status to monitor.`, task_id: task!.id, state: task!.state, + background: isBg, }; }, }; diff --git a/packages/contracts/src/agent-capabilities.ts b/packages/contracts/src/agent-capabilities.ts new file mode 100644 index 0000000..868743c --- /dev/null +++ b/packages/contracts/src/agent-capabilities.ts @@ -0,0 +1,9 @@ +import { z } from 'zod'; + +export const AgentCapabilitiesSchema = z.object({ + supportsStreaming: z.boolean().default(true), + supportsReasoningStream: z.boolean().default(false), + supportsBackgroundExecution: z.boolean().default(false), +}); + +export type AgentCapabilities = z.infer; diff --git a/packages/contracts/src/provider-snapshot.ts b/packages/contracts/src/provider-snapshot.ts index 36d3e7b..d2d83e6 100644 --- a/packages/contracts/src/provider-snapshot.ts +++ b/packages/contracts/src/provider-snapshot.ts @@ -49,4 +49,6 @@ export interface ProviderSnapshotEntry { commands: AgentCommand[]; error?: string; fetchedAt?: string; + supportsStreaming?: boolean; + supportsReasoningStream?: boolean; }