Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/kap-server/src/protocol/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ export const taskSchema = z.object({
model: z.string().optional(),
/** Subagent tasks only: the child's effective thinking effort at spawn. */
thinking_effort: z.string().optional(),
agent_id: z.string().optional(),
});
export type Task = z.infer<typeof taskSchema>;
3 changes: 3 additions & 0 deletions packages/kap-server/src/routes/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,9 @@ function toWireTask(
if (info.kind === 'agent' && info.thinkingEffort !== undefined) {
base.thinking_effort = info.thinkingEffort;
}
if (info.kind === 'agent' && info.agentId !== undefined) {
base.agent_id = info.agentId;
}
if (output !== undefined) {
base.output_preview = output.preview;
base.output_bytes = output.bytes;
Expand Down
15 changes: 15 additions & 0 deletions packages/kap-server/test/tasks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ interface TaskWire {
completed_at?: string;
output_preview?: string;
output_bytes?: number;
agent_id?: string;
}

interface ListWire {
Expand Down Expand Up @@ -214,6 +215,7 @@ describe('server-v2 /api/v1/sessions/{sid}/tasks', () => {
status: 'running',
model: 'provider/secondary', // subagent tasks expose the bound display model
thinking_effort: 'low', // …and its effective thinking effort
agent_id: 'sub-1',
});
expect(byId.get(agentId)?.command).toBeUndefined();

Expand All @@ -223,6 +225,8 @@ describe('server-v2 /api/v1/sessions/{sid}/tasks', () => {
kind: 'tool', // question → tool
status: 'running',
});
expect(byId.get(processId)?.agent_id).toBeUndefined();
expect(byId.get(questionId)?.agent_id).toBeUndefined();
});

it('filters the list by wire status', async () => {
Expand All @@ -245,11 +249,22 @@ describe('server-v2 /api/v1/sessions/{sid}/tasks', () => {
const id = await createSession();
const tasks = await mainAgentTasks(id);
const taskId = tasks.registerTask(fakeTask('process'));
const subagentId = tasks.registerTask(fakeTask('agent'));
await flush();

const got = await getJson<TaskWire>(`/api/v1/sessions/${id}/tasks/${taskId}`);
expect(got.body.code).toBe(0);
expect(got.body.data).toMatchObject({ id: taskId, session_id: id, kind: 'bash' });
expect(got.body.data.agent_id).toBeUndefined();

const gotSubagent = await getJson<TaskWire>(`/api/v1/sessions/${id}/tasks/${subagentId}`);
expect(gotSubagent.body.code).toBe(0);
expect(gotSubagent.body.data).toMatchObject({
id: subagentId,
session_id: id,
kind: 'subagent',
agent_id: 'sub-1',
});

const missing = await getJson<null>(`/api/v1/sessions/${id}/tasks/nope`);
expect(missing.body.code).toBe(40406);
Expand Down
1 change: 1 addition & 0 deletions packages/protocol/src/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const taskSchema = z.object({
model: z.string().optional(),
/** Subagent tasks only: the child's effective thinking effort at spawn. */
thinking_effort: z.string().optional(),
agent_id: z.string().optional(),
});
export type Task = z.infer<typeof taskSchema>;

Expand Down
Loading