Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

fix(chat): failed task steps show as failed in the task panel (#16556)

Hazem Adel03a136fcfbfa
diff --git a/packages/core/execution/src/lib/workers/agent-events.ts b/packages/core/execution/src/lib/workers/agent-events.ts
index ce6279c6db8..bc1746da513 100644
--- a/packages/core/execution/src/lib/workers/agent-events.ts
+++ b/packages/core/execution/src/lib/workers/agent-events.ts
@@ -93,7 +93,7 @@ export type BuildPlanEvent = {
updatedAt: string
}
-export type SubagentTimelineEntry = { kind: 'status', text: string }
+export type SubagentTimelineEntry = { kind: 'status', text: string, failed?: boolean }
export type SubagentActivity = {
taskId?: string
diff --git a/packages/server/worker/src/lib/execute/jobs/ee/agent/tools/task-subagent-tools.ts b/packages/server/worker/src/lib/execute/jobs/ee/agent/tools/task-subagent-tools.ts
index 9a684a98862..54e0dfa44cf 100644
--- a/packages/server/worker/src/lib/execute/jobs/ee/agent/tools/task-subagent-tools.ts
+++ b/packages/server/worker/src/lib/execute/jobs/ee/agent/tools/task-subagent-tools.ts
@@ -251,7 +251,7 @@ function isTitledToolCall(part: PersistedAgentPart): part is Extract<PersistedAg
function timelineFrom(parts: PersistedAgentPart[]): SubagentTimelineEntry[] {
return parts.flatMap((part): SubagentTimelineEntry[] => {
if (isTitledToolCall(part)) {
- return [{ kind: 'status', text: part.title.trim() }]
+ return [{ kind: 'status', text: part.title.trim(), failed: part.status === PersistedToolCallStatus.ERROR }]
}
if (part.type !== PersistedAgentPartType.THINKING_STATUS) {
return []
diff --git a/packages/server/worker/test/lib/execute/jobs/ee/agent/task-subagent-tools.test.ts b/packages/server/worker/test/lib/execute/jobs/ee/agent/task-subagent-tools.test.ts
index b4088173665..2a9b9bef3e1 100644
--- a/packages/server/worker/test/lib/execute/jobs/ee/agent/task-subagent-tools.test.ts
+++ b/packages/server/worker/test/lib/execute/jobs/ee/agent/task-subagent-tools.test.ts
@@ -63,7 +63,7 @@ describe('createTaskSubagentTools', () => {
expect(finishTask).toHaveBeenCalledWith(expect.objectContaining({ status: 'BLOCKED' }))
})
- it('puts each titled tool step in the timeline, so a task without status updates still shows its steps', async () => {
+ it('puts each titled tool step in the timeline and marks the failed ones, so a task without status updates still shows its steps', async () => {
runAgentTurn.mockImplementation(async (params: { tools: ToolSet }) => {
await params.tools[TASK_COMPLETION_TOOL_NAME].execute?.({ status: 'done', summary: 'Built.', artifacts: [] }, EXECUTION_OPTIONS)
return {
@@ -71,6 +71,7 @@ describe('createTaskSubagentTools', () => {
uiParts: [
{ type: PersistedAgentPartType.TOOL_CALL, toolCallId: 'b1', toolName: 'ap_build_flow', title: 'Building your intake flow', input: {}, status: PersistedToolCallStatus.COMPLETED },
{ type: PersistedAgentPartType.TOOL_CALL, toolCallId: 'v1', toolName: 'ap_validate_flow', input: {}, status: PersistedToolCallStatus.COMPLETED },
+ { type: PersistedAgentPartType.TOOL_CALL, toolCallId: 't1', toolName: 'ap_test_flow', title: 'Testing your intake flow', input: {}, status: PersistedToolCallStatus.ERROR },
],
}
})
@@ -78,7 +79,7 @@ describe('createTaskSubagentTools', () => {
const result = await tasks['ap_run_task'].execute?.({ title: 'Build', brief: 'Build it' }, EXECUTION_OPTIONS)
- expect(result).toMatchObject({ activity: { statusLine: 'Building your intake flow', timeline: [{ kind: 'status', text: 'Building your intake flow' }] } })
+ expect(result).toMatchObject({ activity: { statusLine: 'Testing your intake flow', timeline: [{ kind: 'status', text: 'Building your intake flow', failed: false }, { kind: 'status', text: 'Testing your intake flow', failed: true }] } })
})
it('sends the growing timeline with every live update', async () => {
diff --git a/packages/web/src/app/routes/chat-with-ai/components/task-panel.tsx b/packages/web/src/app/routes/chat-with-ai/components/task-panel.tsx
index 276f8cad025..2af7a4464ce 100644
--- a/packages/web/src/app/routes/chat-with-ai/components/task-panel.tsx
+++ b/packages/web/src/app/routes/chat-with-ai/components/task-panel.tsx
@@ -174,6 +174,7 @@ function TaskDetails({
<TimelineItem
key={`${index}-${entry.text}`}
text={entry.text}
+ failed={entry.failed ?? false}
active={running && index === timeline.length - 1}
/>
))}
@@ -207,7 +208,15 @@ function TaskDetails({
);
}
-function TimelineItem({ text, active }: { text: string; active: boolean }) {
+function TimelineItem({
+ text,
+ failed,
+ active,
+}: {
+ text: string;
+ failed: boolean;
+ active: boolean;
+}) {
return (
<motion.li
initial={{ opacity: 0, y: 6 }}
@@ -216,7 +225,9 @@ function TimelineItem({ text, active }: { text: string; active: boolean }) {
className="flex gap-3"
>
<span className="flex size-5 shrink-0 items-center justify-center">
- {active ? (
+ {failed ? (
+ <X className="size-3.5 text-danger-11" strokeWidth={2.5} />
+ ) : active ? (
<Loader2 className="size-3.5 animate-spin text-accent-10 motion-reduce:animate-none" />
) : (
<Check className="size-3.5 text-success-10" strokeWidth={2.5} />