mirror of
https://github.com/MoonshotAI/kimi-code.git
synced 2026-08-16 04:05:58 +00:00
feat(kap-server): expose the subagent registry id in /tasks responses (#2907)
This commit is contained in:
parent
245e3d56a6
commit
325913a532
4 changed files with 20 additions and 0 deletions
|
|
@ -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>;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ interface TaskWire {
|
|||
completed_at?: string;
|
||||
output_preview?: string;
|
||||
output_bytes?: number;
|
||||
agent_id?: string;
|
||||
}
|
||||
|
||||
interface ListWire {
|
||||
|
|
@ -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();
|
||||
|
||||
|
|
@ -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 () => {
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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>;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue