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/agent-core-v2/docs/state-manifest.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,7 @@ export interface AgentStateSnapshot {
readonly kind: 'agent';
readonly agentId?: string;
readonly subagentType?: string;
readonly parentToolCallId?: string;
readonly model?: string;
readonly thinkingEffort?: string;
readonly taskId: string;
Expand Down
1 change: 1 addition & 0 deletions packages/agent-core-v2/src/agent/tools/agent/agentTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ export class SubagentTool implements ISubagentTool {
return {
agentId,
profileName,
parentToolCallId: toolCallId,
model: displayModel,
thinkingEffort: this.lifecycle
.get(agentId)
Expand Down
5 changes: 5 additions & 0 deletions packages/agent-core-v2/src/agent/tools/agent/subagent-task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type SubagentCompletion = {
export type SubagentHandle = {
readonly agentId: string;
readonly profileName: string;
readonly parentToolCallId?: string;
readonly model?: string;
readonly thinkingEffort?: string;
readonly completion: Promise<SubagentCompletion>;
Expand All @@ -36,6 +37,7 @@ export interface SubagentTaskInfo extends AgentTaskInfoBase {
readonly kind: 'agent';
readonly agentId?: string;
readonly subagentType?: string;
readonly parentToolCallId?: string;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Regenerate the state manifest for task ghosts

Adding parentToolCallId changes SubagentTaskInfo, which is part of the persisted task.ghosts state snapshot, but packages/agent-core-v2/docs/state-manifest.d.ts still omits this field under the generated SubagentTaskInfo expansion. That leaves the checked-in manifest stale and should make test/state/stateManifest.test.ts fail its freshness check; regenerate the state manifest alongside this type change.

AGENTS.md reference: packages/agent-core-v2/AGENTS.md:L105-L105

Useful? React with 👍 / 👎.

readonly model?: string;
readonly thinkingEffort?: string;
}
Expand Down Expand Up @@ -84,6 +86,7 @@ export class SubagentTask implements AgentTask {
readonly idPrefix: string = 'agent';
readonly agentId: string;
readonly subagentType: string;
readonly parentToolCallId?: string;
readonly model?: string;
readonly thinkingEffort?: string;

Expand All @@ -94,6 +97,7 @@ export class SubagentTask implements AgentTask {
) {
this.agentId = handle.agentId;
this.subagentType = handle.profileName;
this.parentToolCallId = handle.parentToolCallId;
this.model = handle.model;
this.thinkingEffort = handle.thinkingEffort;
}
Expand Down Expand Up @@ -129,6 +133,7 @@ export class SubagentTask implements AgentTask {
kind: 'agent',
agentId: this.agentId,
subagentType: this.subagentType,
parentToolCallId: this.parentToolCallId,
model: this.model,
thinkingEffort: this.thinkingEffort,
};
Expand Down
4 changes: 4 additions & 0 deletions packages/agent-core-v2/test/agent/task/taskManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,15 @@ function agentTask(
options: {
readonly agentId?: string;
readonly subagentType?: string;
readonly parentToolCallId?: string;
readonly abortController?: AbortController;
readonly timeoutMs?: number;
} = {},
): SubagentTask {
const handle: SubagentHandle = {
agentId: options.agentId ?? 'agent-child',
profileName: options.subagentType ?? 'coder',
parentToolCallId: options.parentToolCallId,
completion,
};
const task = new SubagentTask(
Expand Down Expand Up @@ -410,6 +412,7 @@ describe('AgentTaskService', () => {
agentTask(new Promise(() => {}), 'investigate bug', {
agentId: 'agent-child',
subagentType: 'coder',
parentToolCallId: 'call-parent-1',
}),
);

Expand All @@ -420,6 +423,7 @@ describe('AgentTaskService', () => {
description: 'investigate bug',
agentId: 'agent-child',
subagentType: 'coder',
parentToolCallId: 'call-parent-1',
status: 'running',
});
});
Expand Down
2 changes: 2 additions & 0 deletions packages/kap-server/src/protocol/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,7 @@ export const taskSchema = z.object({
/** Subagent tasks only: the child's effective thinking effort at spawn. */
thinking_effort: z.string().optional(),
agent_id: z.string().optional(),
subagent_type: z.string().optional(),
parent_tool_call_id: z.string().optional(),
});
export type Task = z.infer<typeof taskSchema>;
6 changes: 6 additions & 0 deletions packages/kap-server/src/routes/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,12 @@ function toWireTask(
if (info.kind === 'agent' && info.agentId !== undefined) {
base.agent_id = info.agentId;
}
if (info.kind === 'agent' && info.subagentType !== undefined) {
base.subagent_type = info.subagentType;
}
if (info.kind === 'agent' && info.parentToolCallId !== undefined) {
base.parent_tool_call_id = info.parentToolCallId;
}
if (output !== undefined) {
base.output_preview = output.preview;
base.output_bytes = output.bytes;
Expand Down
11 changes: 11 additions & 0 deletions packages/kap-server/test/tasks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ interface TaskWire {
output_preview?: string;
output_bytes?: number;
agent_id?: string;
subagent_type?: string;
parent_tool_call_id?: string;
}

interface ListWire {
Expand Down Expand Up @@ -159,6 +161,7 @@ describe('server-v2 /api/v1/sessions/{sid}/tasks', () => {
kind: 'agent',
agentId: 'sub-1',
subagentType: 'explore',
parentToolCallId: 'call-parent-1',
model: 'provider/secondary',
thinkingEffort: 'low',
};
Expand Down Expand Up @@ -216,6 +219,8 @@ describe('server-v2 /api/v1/sessions/{sid}/tasks', () => {
model: 'provider/secondary', // subagent tasks expose the bound display model
thinking_effort: 'low', // …and its effective thinking effort
agent_id: 'sub-1',
subagent_type: 'explore',
parent_tool_call_id: 'call-parent-1',
});
expect(byId.get(agentId)?.command).toBeUndefined();

Expand All @@ -227,6 +232,10 @@ describe('server-v2 /api/v1/sessions/{sid}/tasks', () => {
});
expect(byId.get(processId)?.agent_id).toBeUndefined();
expect(byId.get(questionId)?.agent_id).toBeUndefined();
expect(byId.get(processId)?.subagent_type).toBeUndefined();
expect(byId.get(questionId)?.subagent_type).toBeUndefined();
expect(byId.get(processId)?.parent_tool_call_id).toBeUndefined();
expect(byId.get(questionId)?.parent_tool_call_id).toBeUndefined();
});

it('filters the list by wire status', async () => {
Expand Down Expand Up @@ -264,6 +273,8 @@ describe('server-v2 /api/v1/sessions/{sid}/tasks', () => {
session_id: id,
kind: 'subagent',
agent_id: 'sub-1',
subagent_type: 'explore',
parent_tool_call_id: 'call-parent-1',
});

const missing = await getJson<null>(`/api/v1/sessions/${id}/tasks/nope`);
Expand Down
Loading