Skip to content
Open
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
32 changes: 32 additions & 0 deletions packages/client-runtime/src/state/subagentRuntime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,38 @@ describe("foldSubagentActivities", () => {
expect(agents[0]!.completedAt).toBe("2026-08-01T11:00:00.000Z");
});

it("maps cancelled status to a terminal cancelled state", () => {
const agents = fold([
activity("task.started", { taskId: "task-cancelled", taskType: "local_agent" }),
activity("task.completed", {
taskId: "task-cancelled",
status: "cancelled",
summary: "user cancelled",
}),
]);
expect(agents).toHaveLength(1);
const agent = agents[0]!;
expect(agent.status).toBe("cancelled");
expect(agent.result).toBe("user cancelled");
expect(agent.completedAt).not.toBeNull();
});

it("maps interrupted status to a terminal interrupted state", () => {
const agents = fold([
activity("task.started", { taskId: "task-interrupted", taskType: "local_agent" }),
activity("task.completed", {
taskId: "task-interrupted",
status: "interrupted",
summary: "context window exceeded",
}),
]);
expect(agents).toHaveLength(1);
const agent = agents[0]!;
expect(agent.status).toBe("interrupted");
expect(agent.result).toBe("context window exceeded");
expect(agent.completedAt).not.toBeNull();
});

it("reactivation increments the run count and clears result/error", () => {
const agents = fold([
activity("task.started", { taskId: "task-4", taskType: "local_agent" }),
Expand Down
2 changes: 2 additions & 0 deletions packages/client-runtime/src/state/subagentRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,8 @@ const TASK_COMPLETED_STATUS: ReadonlyMap<string, RuntimeSubagentStatus> = new Ma
["completed", "completed"],
["failed", "failed"],
["stopped", "interrupted"],
["cancelled", "cancelled"],
["interrupted", "interrupted"],
Comment on lines +433 to +434

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 Extend the task-completion wire contract

These branches cannot handle normal production events because TaskCompletedPayload.status in packages/contracts/src/providerRuntime.ts still permits only completed, failed, and stopped; current Codex interruption paths also emit task.updated, not task.completed. The new tests bypass that contract with a cast, so they exercise fabricated activity rows while the reported live task.completed scenario remains unsupported. Add these statuses to the contract and normalize them through the relevant adapter and ingestion paths before relying on this client mapping.

AGENTS.md reference: AGENTS.md:L71-L72

Useful? React with 👍 / 👎.

]);

const KNOWN_STATUSES: ReadonlySet<string> = new Set([
Expand Down
Loading