Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

:camera_flash: tests: add test fixtures

arvinxxd780fa82abd8
diff --git a/packages/conversation-flow/src/__tests__/fixtures/index.ts b/packages/conversation-flow/src/__tests__/fixtures/index.ts
index 19411b3213a..cc922f7ebda 100644
--- a/packages/conversation-flow/src/__tests__/fixtures/index.ts
+++ b/packages/conversation-flow/src/__tests__/fixtures/index.ts
@@ -7,6 +7,7 @@ import { assistantGroup as assistantGroupInputs } from './inputs/assistantGroup'
import { branch as branchInputs } from './inputs/branch';
import { compare as compareInputs } from './inputs/compare';
import linearConversationInput from './inputs/linear-conversation.json';
+import { tasks as tasksInputs } from './inputs/tasks';
// Output fixtures
import { agentCouncil as agentCouncilOutputs } from './outputs/agentCouncil';
import { agentGroup as agentGroupOutputs } from './outputs/agentGroup';
@@ -15,6 +16,7 @@ import { assistantGroup as assistantGroupOutputs } from './outputs/assistantGrou
import { branch as branchOutputs } from './outputs/branch';
import { compare as compareOutputs } from './outputs/compare';
import linearConversationOutput from './outputs/linear-conversation.json';
+import { tasks as tasksOutputs } from './outputs/tasks';
/**
* Serialized parse result type
@@ -36,6 +38,7 @@ export const inputs = {
branch: branchInputs,
compare: compareInputs,
linearConversation: linearConversationInput as Message[],
+ tasks: tasksInputs,
};
/**
@@ -49,4 +52,5 @@ export const outputs = {
branch: branchOutputs,
compare: compareOutputs,
linearConversation: linearConversationOutput as unknown as SerializedParseResult,
+ tasks: tasksOutputs,
};
diff --git a/packages/conversation-flow/src/__tests__/fixtures/inputs/index.ts b/packages/conversation-flow/src/__tests__/fixtures/inputs/index.ts
index a7c34c5760e..57a91fdc9cc 100644
--- a/packages/conversation-flow/src/__tests__/fixtures/inputs/index.ts
+++ b/packages/conversation-flow/src/__tests__/fixtures/inputs/index.ts
@@ -6,6 +6,7 @@ import { assistantGroup } from './assistantGroup';
import { branch } from './branch';
import { compare } from './compare';
import linearConversation from './linear-conversation.json';
+import { tasks } from './tasks';
export const inputs = {
agentCouncil,
@@ -15,4 +16,5 @@ export const inputs = {
branch,
compare,
linearConversation: linearConversation as Message[],
+ tasks,
};
diff --git a/packages/conversation-flow/src/__tests__/fixtures/inputs/tasks/index.ts b/packages/conversation-flow/src/__tests__/fixtures/inputs/tasks/index.ts
new file mode 100644
index 00000000000..3db7a8c210c
--- /dev/null
+++ b/packages/conversation-flow/src/__tests__/fixtures/inputs/tasks/index.ts
@@ -0,0 +1,8 @@
+import type { Message } from '../../../../types';
+import simple from './simple.json';
+import withSummary from './with-summary.json';
+
+export const tasks = {
+ simple: simple as Message[],
+ withSummary: withSummary as Message[],
+};
diff --git a/packages/conversation-flow/src/__tests__/fixtures/inputs/tasks/simple.json b/packages/conversation-flow/src/__tests__/fixtures/inputs/tasks/simple.json
new file mode 100644
index 00000000000..39ac85fecac
--- /dev/null
+++ b/packages/conversation-flow/src/__tests__/fixtures/inputs/tasks/simple.json
@@ -0,0 +1,136 @@
+[
+ {
+ "id": "msg-user-1",
+ "role": "user",
+ "content": "Help me create two tasks to research the weather in Hangzhou and Beijing tomorrow.",
+ "parentId": null,
+ "createdAt": 1735526559382,
+ "updatedAt": 1735526559382,
+ "meta": {}
+ },
+ {
+ "id": "msg-assistant-1",
+ "role": "assistant",
+ "content": "I'll help you create two async tasks to research the weather in Hangzhou and Beijing.",
+ "parentId": "msg-user-1",
+ "createdAt": 1735526560163,
+ "updatedAt": 1735526585550,
+ "meta": {},
+ "model": "deepseek-chat",
+ "provider": "deepseek",
+ "tools": [
+ {
+ "id": "call_exec_tasks_1",
+ "type": "builtin",
+ "apiName": "execTasks",
+ "arguments": "{\"tasks\": [{\"description\": \"Research Hangzhou weather\", \"instruction\": \"Search for Hangzhou weather tomorrow.\"}, {\"description\": \"Research Beijing weather\", \"instruction\": \"Search for Beijing weather tomorrow.\"}]}",
+ "identifier": "lobe-gtd"
+ }
+ ],
+ "metadata": {
+ "tps": 29.33,
+ "cost": 0.000441,
+ "ttft": 1490,
+ "latency": 13425,
+ "duration": 11935,
+ "totalTokens": 10143,
+ "totalInputTokens": 9793,
+ "totalOutputTokens": 350
+ }
+ },
+ {
+ "id": "msg-tool-1",
+ "role": "tool",
+ "content": "Triggered 2 async tasks for execution:\n1. Research Hangzhou weather\n2. Research Beijing weather",
+ "parentId": "msg-assistant-1",
+ "tool_call_id": "call_exec_tasks_1",
+ "createdAt": 1735526588116,
+ "updatedAt": 1735526591337,
+ "meta": {},
+ "plugin": {
+ "apiName": "execTasks",
+ "arguments": "{\"tasks\": [{\"description\": \"Research Hangzhou weather\", \"instruction\": \"Search for Hangzhou weather tomorrow.\"}, {\"description\": \"Research Beijing weather\", \"instruction\": \"Search for Beijing weather tomorrow.\"}]}",
+ "identifier": "lobe-gtd",
+ "type": "builtin"
+ },
+ "pluginState": {
+ "type": "execTasks",
+ "tasks": [
+ {
+ "description": "Research Hangzhou weather",
+ "instruction": "Search for Hangzhou weather tomorrow."
+ },
+ {
+ "description": "Research Beijing weather",
+ "instruction": "Search for Beijing weather tomorrow."
+ }
+ ],
+ "parentMessageId": "msg-tool-1"
+ }
+ },
+ {
+ "id": "msg-task-hangzhou",
+ "role": "task",
+ "content": "## Hangzhou Weather Report\n\nBased on the China Meteorological Administration data:\n\n- **Temperature**: 4-9°C\n- **Condition**: Cloudy during day, light rain at night\n- **Wind**: Northeast, light breeze\n- **Humidity**: 62.3%-93.6%",
+ "parentId": "msg-tool-1",
+ "createdAt": 1735526594643,
+ "updatedAt": 1735526756262,
+ "meta": {},
+ "metadata": {
+ "instruction": "Search for Hangzhou weather tomorrow."
+ },
+ "taskDetail": {
+ "duration": 152955,
+ "status": "completed",
+ "threadId": "thd_hangzhou_weather",
+ "title": "Research Hangzhou weather",
+ "totalCost": 0.019886,
+ "totalMessages": 22,
+ "totalTokens": 143825,
+ "totalToolCalls": 0
+ }
+ },
+ {
+ "id": "msg-task-beijing",
+ "role": "task",
+ "content": "## Beijing Weather Report\n\nBased on the China Weather Network data:\n\n- **Temperature**: -9°C to 0°C\n- **Condition**: Sunny and cold\n- **Wind**: North, <3 level\n- **AQI**: 57 (Good)",
+ "parentId": "msg-tool-1",
+ "createdAt": 1735526595647,
+ "updatedAt": 1735526792430,
+ "meta": {},
+ "metadata": {
+ "instruction": "Search for Beijing weather tomorrow."
+ },
+ "taskDetail": {
+ "duration": 186928,
+ "status": "completed",
+ "threadId": "thd_beijing_weather",
+ "title": "Research Beijing weather",
+ "totalCost": 0.022058,
+ "totalMessages": 28,
+ "totalTokens": 178678,
+ "totalToolCalls": 0
+ }
+ },
+ {
+ "id": "msg-assistant-summary",
+ "role": "assistant",
+ "content": "I've created two async tasks to research the weather. Both tasks are completed:\n\n## Hangzhou: 4-9°C, cloudy with light rain at night\n## Beijing: -9°C to 0°C, sunny and cold",
+ "parentId": "msg-tool-1",
+ "createdAt": 1735526795651,
+ "updatedAt": 1735526813171,
+ "meta": {},
+ "model": "deepseek-chat",
+ "provider": "deepseek",
+ "metadata": {
+ "tps": 28.27,
+ "cost": 0.001078,
+ "ttft": 1994,
+ "latency": 10129,
+ "duration": 8135,
+ "totalTokens": 12530,
+ "totalInputTokens": 12300,
+ "totalOutputTokens": 230
+ }
+ }
+]
diff --git a/packages/conversation-flow/src/__tests__/fixtures/inputs/tasks/with-summary.json b/packages/conversation-flow/src/__tests__/fixtures/inputs/tasks/with-summary.json
new file mode 100644
index 00000000000..c4ad4fd10b2
--- /dev/null
+++ b/packages/conversation-flow/src/__tests__/fixtures/inputs/tasks/with-summary.json
@@ -0,0 +1,115 @@
+[
+ {
+ "id": "msg-user-1",
+ "role": "user",
+ "content": "Create three parallel tasks to research AI topics.",
+ "parentId": null,
+ "createdAt": 1735526559382,
+ "updatedAt": 1735526559382,
+ "meta": {}
+ },
+ {
+ "id": "msg-assistant-1",
+ "role": "assistant",
+ "content": "Creating three parallel research tasks.",
+ "parentId": "msg-user-1",
+ "createdAt": 1735526560163,
+ "updatedAt": 1735526585550,
+ "meta": {},
+ "model": "gpt-4",
+ "provider": "openai",
+ "tools": [
+ {
+ "id": "call_exec_tasks_1",
+ "type": "builtin",
+ "apiName": "execTasks",
+ "arguments": "{\"tasks\": [{\"description\": \"Research LLM architectures\"}, {\"description\": \"Research AI agents\"}, {\"description\": \"Research RAG systems\"}]}",
+ "identifier": "lobe-gtd"
+ }
+ ]
+ },
+ {
+ "id": "msg-tool-1",
+ "role": "tool",
+ "content": "Triggered 3 async tasks",
+ "parentId": "msg-assistant-1",
+ "tool_call_id": "call_exec_tasks_1",
+ "createdAt": 1735526588116,
+ "updatedAt": 1735526591337,
+ "meta": {},
+ "pluginState": {
+ "type": "execTasks",
+ "tasks": [
+ { "description": "Research LLM architectures" },
+ { "description": "Research AI agents" },
+ { "description": "Research RAG systems" }
+ ],
+ "parentMessageId": "msg-tool-1"
+ }
+ },
+ {
+ "id": "msg-task-llm",
+ "role": "task",
+ "content": "# LLM Architectures\n\nTransformer-based models dominate...",
+ "parentId": "msg-tool-1",
+ "createdAt": 1735526594643,
+ "updatedAt": 1735526756262,
+ "meta": {},
+ "taskDetail": {
+ "duration": 120000,
+ "status": "completed",
+ "threadId": "thd_llm",
+ "title": "Research LLM architectures",
+ "totalCost": 0.015,
+ "totalMessages": 15,
+ "totalTokens": 100000
+ }
+ },
+ {
+ "id": "msg-task-agents",
+ "role": "task",
+ "content": "# AI Agents\n\nAutonomous agents using LLMs...",
+ "parentId": "msg-tool-1",
+ "createdAt": 1735526595647,
+ "updatedAt": 1735526792430,
+ "meta": {},
+ "taskDetail": {
+ "duration": 150000,
+ "status": "completed",
+ "threadId": "thd_agents",
+ "title": "Research AI agents",
+ "totalCost": 0.018,
+ "totalMessages": 20,
+ "totalTokens": 120000
+ }
+ },
+ {
+ "id": "msg-task-rag",
+ "role": "task",
+ "content": "# RAG Systems\n\nRetrieval Augmented Generation combines...",
+ "parentId": "msg-tool-1",
+ "createdAt": 1735526596000,
+ "updatedAt": 1735526800000,
+ "meta": {},
+ "taskDetail": {
+ "duration": 130000,
+ "status": "completed",
+ "threadId": "thd_rag",
+ "title": "Research RAG systems",
+ "totalCost": 0.016,
+ "totalMessages": 18,
+ "totalTokens": 110000
+ }
+ },
+ {
+ "id": "msg-assistant-summary",
+ "role": "assistant",
+ "content": "All three research tasks completed successfully. Here's a summary of the findings...",
+ "parentId": "msg-tool-1",
+ "createdAt": 1735526810000,
+ "updatedAt": 1735526820000,
+ "meta": {},
+ "model": "gpt-4",
+ "provider": "openai"
+ }
+]
diff --git a/packages/conversation-flow/src/__tests__/fixtures/outputs/tasks/index.ts b/packages/conversation-flow/src/__tests__/fixtures/outputs/tasks/index.ts
new file mode 100644
index 00000000000..c13bcdaf0dc
--- /dev/null
+++ b/packages/conversation-flow/src/__tests__/fixtures/outputs/tasks/index.ts
@@ -0,0 +1,8 @@
+import type { SerializedParseResult } from '../../index';
+import simple from './simple.json';
+import withSummary from './with-summary.json';
+
+export const tasks = {
+ simple: simple as unknown as SerializedParseResult,
+ withSummary: withSummary as unknown as SerializedParseResult,
+};
diff --git a/packages/conversation-flow/src/__tests__/fixtures/outputs/tasks/simple.json b/packages/conversation-flow/src/__tests__/fixtures/outputs/tasks/simple.json
new file mode 100644
index 00000000000..4587e34174b
--- /dev/null
+++ b/packages/conversation-flow/src/__tests__/fixtures/outputs/tasks/simple.json
@@ -0,0 +1,332 @@
+{
+ "contextTree": [
+ {
+ "id": "msg-user-1",
+ "type": "message"
+ },
+ {
+ "id": "msg-assistant-1",
+ "type": "assistantGroup",
+ "children": [
+ {
+ "id": "msg-assistant-1",
+ "type": "message",
+ "tools": ["msg-tool-1"]
+ }
+ ]
+ },
+ {
+ "id": "tasks-msg-tool-1-msg-task-hangzhou-msg-task-beijing",
+ "type": "tasks",
+ "children": [
+ {
+ "id": "msg-task-hangzhou",
+ "type": "message"
+ },
+ {
+ "id": "msg-task-beijing",
+ "type": "message"
+ }
+ ],
+ "messageId": "msg-tool-1"
+ },
+ {
+ "id": "msg-assistant-summary",
+ "type": "message"
+ }
+ ],
+ "flatList": [
+ {
+ "id": "msg-user-1",
+ "role": "user",
+ "content": "Help me create two tasks to research the weather in Hangzhou and Beijing tomorrow.",
+ "parentId": null,
+ "createdAt": 1735526559382,
+ "updatedAt": 1735526559382,
+ "meta": {}
+ },
+ {
+ "id": "msg-assistant-1",
+ "role": "assistantGroup",
+ "content": "",
+ "parentId": "msg-user-1",
+ "createdAt": 1735526560163,
+ "updatedAt": 1735526585550,
+ "meta": {},
+ "model": "deepseek-chat",
+ "provider": "deepseek",
+ "children": [
+ {
+ "id": "msg-assistant-1",
+ "content": "I'll help you create two async tasks to research the weather in Hangzhou and Beijing.",
+ "tools": [
+ {
+ "id": "call_exec_tasks_1",
+ "type": "builtin",
+ "apiName": "execTasks",
+ "arguments": "{\"tasks\": [{\"description\": \"Research Hangzhou weather\", \"instruction\": \"Search for Hangzhou weather tomorrow.\"}, {\"description\": \"Research Beijing weather\", \"instruction\": \"Search for Beijing weather tomorrow.\"}]}",
+ "identifier": "lobe-gtd",
+ "result": {
+ "id": "msg-tool-1",
+ "content": "Triggered 2 async tasks for execution:\n1. Research Hangzhou weather\n2. Research Beijing weather",
+ "state": {
+ "type": "execTasks",
+ "tasks": [
+ {
+ "description": "Research Hangzhou weather",
+ "instruction": "Search for Hangzhou weather tomorrow."
+ },
+ {
+ "description": "Research Beijing weather",
+ "instruction": "Search for Beijing weather tomorrow."
+ }
+ ],
+ "parentMessageId": "msg-tool-1"
+ }
+ },
+ "result_msg_id": "msg-tool-1"
+ }
+ ],
+ "usage": {
+ "totalTokens": 10143,
+ "totalInputTokens": 9793,
+ "totalOutputTokens": 350
+ },
+ "performance": {
+ "tps": 29.33,
+ "cost": 0.000441,
+ "ttft": 1490,
+ "latency": 13425,
+ "duration": 11935
+ }
+ }
+ ],
+ "usage": {
+ "totalTokens": 10143,
+ "totalInputTokens": 9793,
+ "totalOutputTokens": 350
+ },
+ "performance": {
+ "tps": 29.33,
+ "cost": 0.000441,
+ "ttft": 1490,
+ "latency": 13425,
+ "duration": 11935
+ }
+ },
+ {
+ "id": "tasks-msg-tool-1-msg-task-hangzhou-msg-task-beijing",
+ "role": "tasks",
+ "content": "",
+ "createdAt": 1735526594643,
+ "updatedAt": 1735526792430,
+ "meta": {},
+ "extra": {
+ "parentMessageId": "msg-tool-1"
+ },
+ "children": [
+ {
+ "id": "msg-task-hangzhou",
+ "role": "task",
+ "content": "## Hangzhou Weather Report\n\nBased on the China Meteorological Administration data:\n\n- **Temperature**: 4-9°C\n- **Condition**: Cloudy during day, light rain at night\n- **Wind**: Northeast, light breeze\n- **Humidity**: 62.3%-93.6%",
+ "parentId": "msg-tool-1",
+ "createdAt": 1735526594643,
+ "updatedAt": 1735526756262,
+ "meta": {},
+ "metadata": {
+ "instruction": "Search for Hangzhou weather tomorrow."
+ },
+ "taskDetail": {
+ "duration": 152955,
+ "status": "completed",
+ "threadId": "thd_hangzhou_weather",
+ "title": "Research Hangzhou weather",
+ "totalCost": 0.019886,
+ "totalMessages": 22,
+ "totalTokens": 143825,
+ "totalToolCalls": 0
+ }
+ },
+ {
+ "id": "msg-task-beijing",
+ "role": "task",
+ "content": "## Beijing Weather Report\n\nBased on the China Weather Network data:\n\n- **Temperature**: -9°C to 0°C\n- **Condition**: Sunny and cold\n- **Wind**: North, <3 level\n- **AQI**: 57 (Good)",
+ "parentId": "msg-tool-1",
+ "createdAt": 1735526595647,
+ "updatedAt": 1735526792430,
+ "meta": {},
+ "metadata": {
+ "instruction": "Search for Beijing weather tomorrow."
+ },
+ "taskDetail": {
+ "duration": 186928,
+ "status": "completed",
+ "threadId": "thd_beijing_weather",
+ "title": "Research Beijing weather",
+ "totalCost": 0.022058,
+ "totalMessages": 28,
+ "totalTokens": 178678,
+ "totalToolCalls": 0
+ }
+ }
+ ]
+ },
+ {
+ "id": "msg-assistant-summary",
+ "role": "assistant",
+ "content": "I've created two async tasks to research the weather. Both tasks are completed:\n\n## Hangzhou: 4-9°C, cloudy with light rain at night\n## Beijing: -9°C to 0°C, sunny and cold",
+ "parentId": "msg-tool-1",
+ "createdAt": 1735526795651,
+ "updatedAt": 1735526813171,
+ "meta": {},
+ "model": "deepseek-chat",
+ "provider": "deepseek",
+ "metadata": {
+ "tps": 28.27,
+ "cost": 0.001078,
+ "ttft": 1994,
+ "latency": 10129,
+ "duration": 8135,
+ "totalTokens": 12530,
+ "totalInputTokens": 12300,
+ "totalOutputTokens": 230
+ }
+ }
+ ],
+ "messageMap": {
+ "msg-user-1": {
+ "id": "msg-user-1",
+ "role": "user",
+ "content": "Help me create two tasks to research the weather in Hangzhou and Beijing tomorrow.",
+ "parentId": null,
+ "createdAt": 1735526559382,
+ "updatedAt": 1735526559382,
+ "meta": {}
+ },
+ "msg-assistant-1": {
+ "id": "msg-assistant-1",
+ "role": "assistant",
+ "content": "I'll help you create two async tasks to research the weather in Hangzhou and Beijing.",
+ "parentId": "msg-user-1",
+ "createdAt": 1735526560163,
+ "updatedAt": 1735526585550,
+ "meta": {},
+ "model": "deepseek-chat",
+ "provider": "deepseek",
+ "tools": [
+ {
+ "id": "call_exec_tasks_1",
+ "type": "builtin",
+ "apiName": "execTasks",
+ "arguments": "{\"tasks\": [{\"description\": \"Research Hangzhou weather\", \"instruction\": \"Search for Hangzhou weather tomorrow.\"}, {\"description\": \"Research Beijing weather\", \"instruction\": \"Search for Beijing weather tomorrow.\"}]}",
+ "identifier": "lobe-gtd"
+ }
+ ],
+ "metadata": {
+ "tps": 29.33,
+ "cost": 0.000441,
+ "ttft": 1490,
+ "latency": 13425,
+ "duration": 11935,
+ "totalTokens": 10143,
+ "totalInputTokens": 9793,
+ "totalOutputTokens": 350
+ }
+ },
+ "msg-tool-1": {
+ "id": "msg-tool-1",
+ "role": "tool",
+ "content": "Triggered 2 async tasks for execution:\n1. Research Hangzhou weather\n2. Research Beijing weather",
+ "parentId": "msg-assistant-1",
+ "tool_call_id": "call_exec_tasks_1",
+ "createdAt": 1735526588116,
+ "updatedAt": 1735526591337,
+ "meta": {},
+ "plugin": {
+ "apiName": "execTasks",
+ "arguments": "{\"tasks\": [{\"description\": \"Research Hangzhou weather\", \"instruction\": \"Search for Hangzhou weather tomorrow.\"}, {\"description\": \"Research Beijing weather\", \"instruction\": \"Search for Beijing weather tomorrow.\"}]}",
+ "identifier": "lobe-gtd",
+ "type": "builtin"
+ },
+ "pluginState": {
+ "type": "execTasks",
+ "tasks": [
+ {
+ "description": "Research Hangzhou weather",
+ "instruction": "Search for Hangzhou weather tomorrow."
+ },
+ {
+ "description": "Research Beijing weather",
+ "instruction": "Search for Beijing weather tomorrow."
+ }
+ ],
+ "parentMessageId": "msg-tool-1"
+ }
+ },
+ "msg-task-hangzhou": {
+ "id": "msg-task-hangzhou",
+ "role": "task",
+ "content": "## Hangzhou Weather Report\n\nBased on the China Meteorological Administration data:\n\n- **Temperature**: 4-9°C\n- **Condition**: Cloudy during day, light rain at night\n- **Wind**: Northeast, light breeze\n- **Humidity**: 62.3%-93.6%",
+ "parentId": "msg-tool-1",
+ "createdAt": 1735526594643,
+ "updatedAt": 1735526756262,
+ "meta": {},
+ "metadata": {
+ "instruction": "Search for Hangzhou weather tomorrow."
+ },
+ "taskDetail": {
+ "duration": 152955,
+ "status": "completed",
+ "threadId": "thd_hangzhou_weather",
+ "title": "Research Hangzhou weather",
+ "totalCost": 0.019886,
+ "totalMessages": 22,
+ "totalTokens": 143825,
+ "totalToolCalls": 0
+ }
+ },
+ "msg-task-beijing": {
+ "id": "msg-task-beijing",
+ "role": "task",
+ "content": "## Beijing Weather Report\n\nBased on the China Weather Network data:\n\n- **Temperature**: -9°C to 0°C\n- **Condition**: Sunny and cold\n- **Wind**: North, <3 level\n- **AQI**: 57 (Good)",
+ "parentId": "msg-tool-1",
+ "createdAt": 1735526595647,
+ "updatedAt": 1735526792430,
+ "meta": {},
+ "metadata": {
+ "instruction": "Search for Beijing weather tomorrow."
+ },
+ "taskDetail": {
+ "duration": 186928,
+ "status": "completed",
+ "threadId": "thd_beijing_weather",
+ "title": "Research Beijing weather",
+ "totalCost": 0.022058,
+ "totalMessages": 28,
+ "totalTokens": 178678,
+ "totalToolCalls": 0
+ }
+ },
+ "msg-assistant-summary": {
+ "id": "msg-assistant-summary",
+ "role": "assistant",
+ "content": "I've created two async tasks to research the weather. Both tasks are completed:\n\n## Hangzhou: 4-9°C, cloudy with light rain at night\n## Beijing: -9°C to 0°C, sunny and cold",
+ "parentId": "msg-tool-1",
+ "createdAt": 1735526795651,
+ "updatedAt": 1735526813171,
+ "meta": {},
+ "model": "deepseek-chat",
+ "provider": "deepseek",
+ "metadata": {
+ "tps": 28.27,
+ "cost": 0.001078,
+ "ttft": 1994,
+ "latency": 10129,
+ "duration": 8135,
+ "totalTokens": 12530,
+ "totalInputTokens": 12300,
+ "totalOutputTokens": 230
+ }
+ }
+ }
+}
diff --git a/packages/conversation-flow/src/__tests__/fixtures/outputs/tasks/with-summary.json b/packages/conversation-flow/src/__tests__/fixtures/outputs/tasks/with-summary.json
new file mode 100644
index 00000000000..783ff11c1bd
--- /dev/null
+++ b/packages/conversation-flow/src/__tests__/fixtures/outputs/tasks/with-summary.json
@@ -0,0 +1,286 @@
+{
+ "contextTree": [
+ {
+ "id": "msg-user-1",
+ "type": "message"
+ },
+ {
+ "id": "msg-assistant-1",
+ "type": "assistantGroup",
+ "children": [
+ {
+ "id": "msg-assistant-1",
+ "type": "message",
+ "tools": ["msg-tool-1"]
+ }
+ ]
+ },
+ {
+ "id": "tasks-msg-tool-1-msg-task-llm-msg-task-agents-msg-task-rag",
+ "type": "tasks",
+ "children": [
+ {
+ "id": "msg-task-llm",
+ "type": "message"
+ },
+ {
+ "id": "msg-task-agents",
+ "type": "message"
+ },
+ {
+ "id": "msg-task-rag",
+ "type": "message"
+ }
+ ],
+ "messageId": "msg-tool-1"
+ },
+ {
+ "id": "msg-assistant-summary",
+ "type": "message"
+ }
+ ],
+ "flatList": [
+ {
+ "id": "msg-user-1",
+ "role": "user",
+ "content": "Create three parallel tasks to research AI topics.",
+ "parentId": null,
+ "createdAt": 1735526559382,
+ "updatedAt": 1735526559382,
+ "meta": {}
+ },
+ {
+ "id": "msg-assistant-1",
+ "role": "assistantGroup",
+ "content": "",
+ "parentId": "msg-user-1",
+ "createdAt": 1735526560163,
+ "updatedAt": 1735526585550,
+ "meta": {},
+ "model": "gpt-4",
+ "provider": "openai",
+ "children": [
+ {
+ "id": "msg-assistant-1",
+ "content": "Creating three parallel research tasks.",
+ "tools": [
+ {
+ "id": "call_exec_tasks_1",
+ "type": "builtin",
+ "apiName": "execTasks",
+ "arguments": "{\"tasks\": [{\"description\": \"Research LLM architectures\"}, {\"description\": \"Research AI agents\"}, {\"description\": \"Research RAG systems\"}]}",
+ "identifier": "lobe-gtd",
+ "result": {
+ "id": "msg-tool-1",
+ "content": "Triggered 3 async tasks",
+ "state": {
+ "type": "execTasks",
+ "tasks": [
+ { "description": "Research LLM architectures" },
+ { "description": "Research AI agents" },
+ { "description": "Research RAG systems" }
+ ],
+ "parentMessageId": "msg-tool-1"
+ }
+ },
+ "result_msg_id": "msg-tool-1"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "id": "tasks-msg-tool-1-msg-task-llm-msg-task-agents-msg-task-rag",
+ "role": "tasks",
+ "content": "",
+ "createdAt": 1735526594643,
+ "updatedAt": 1735526800000,
+ "meta": {},
+ "extra": {
+ "parentMessageId": "msg-tool-1"
+ },
+ "children": [
+ {
+ "id": "msg-task-llm",
+ "role": "task",
+ "content": "# LLM Architectures\n\nTransformer-based models dominate...",
+ "parentId": "msg-tool-1",
+ "createdAt": 1735526594643,
+ "updatedAt": 1735526756262,
+ "meta": {},
+ "taskDetail": {
+ "duration": 120000,
+ "status": "completed",
+ "threadId": "thd_llm",
+ "title": "Research LLM architectures",
+ "totalCost": 0.015,
+ "totalMessages": 15,
+ "totalTokens": 100000
+ }
+ },
+ {
+ "id": "msg-task-agents",
+ "role": "task",
+ "content": "# AI Agents\n\nAutonomous agents using LLMs...",
+ "parentId": "msg-tool-1",
+ "createdAt": 1735526595647,
+ "updatedAt": 1735526792430,
+ "meta": {},
+ "taskDetail": {
+ "duration": 150000,
+ "status": "completed",
+ "threadId": "thd_agents",
+ "title": "Research AI agents",
+ "totalCost": 0.018,
+ "totalMessages": 20,
+ "totalTokens": 120000
+ }
+ },
+ {
+ "id": "msg-task-rag",
+ "role": "task",
+ "content": "# RAG Systems\n\nRetrieval Augmented Generation combines...",
+ "parentId": "msg-tool-1",
+ "createdAt": 1735526596000,
+ "updatedAt": 1735526800000,
+ "meta": {},
+ "taskDetail": {
+ "duration": 130000,
+ "status": "completed",
+ "threadId": "thd_rag",
+ "title": "Research RAG systems",
+ "totalCost": 0.016,
+ "totalMessages": 18,
+ "totalTokens": 110000
+ }
+ }
+ ]
+ },
+ {
+ "id": "msg-assistant-summary",
+ "role": "assistant",
+ "content": "All three research tasks completed successfully. Here's a summary of the findings...",
+ "parentId": "msg-tool-1",
+ "createdAt": 1735526810000,
+ "updatedAt": 1735526820000,
+ "meta": {},
+ "model": "gpt-4",
+ "provider": "openai"
+ }
+ ],
+ "messageMap": {
+ "msg-user-1": {
+ "id": "msg-user-1",
+ "role": "user",
+ "content": "Create three parallel tasks to research AI topics.",
+ "parentId": null,
+ "createdAt": 1735526559382,
+ "updatedAt": 1735526559382,
+ "meta": {}
+ },
+ "msg-assistant-1": {
+ "id": "msg-assistant-1",
+ "role": "assistant",
+ "content": "Creating three parallel research tasks.",
+ "parentId": "msg-user-1",
+ "createdAt": 1735526560163,
+ "updatedAt": 1735526585550,
+ "meta": {},
+ "model": "gpt-4",
+ "provider": "openai",
+ "tools": [
+ {
+ "id": "call_exec_tasks_1",
+ "type": "builtin",
+ "apiName": "execTasks",
+ "arguments": "{\"tasks\": [{\"description\": \"Research LLM architectures\"}, {\"description\": \"Research AI agents\"}, {\"description\": \"Research RAG systems\"}]}",
+ "identifier": "lobe-gtd"
+ }
+ ]
+ },
+ "msg-tool-1": {
+ "id": "msg-tool-1",
+ "role": "tool",
+ "content": "Triggered 3 async tasks",
+ "parentId": "msg-assistant-1",
+ "tool_call_id": "call_exec_tasks_1",
+ "createdAt": 1735526588116,
+ "updatedAt": 1735526591337,
+ "meta": {},
+ "pluginState": {
+ "type": "execTasks",
+ "tasks": [
+ { "description": "Research LLM architectures" },
+ { "description": "Research AI agents" },
+ { "description": "Research RAG systems" }
+ ],
+ "parentMessageId": "msg-tool-1"
+ }
+ },
+ "msg-task-llm": {
+ "id": "msg-task-llm",
+ "role": "task",
+ "content": "# LLM Architectures\n\nTransformer-based models dominate...",
+ "parentId": "msg-tool-1",
+ "createdAt": 1735526594643,
+ "updatedAt": 1735526756262,
+ "meta": {},
+ "taskDetail": {
+ "duration": 120000,
+ "status": "completed",
+ "threadId": "thd_llm",
+ "title": "Research LLM architectures",
+ "totalCost": 0.015,
+ "totalMessages": 15,
+ "totalTokens": 100000
+ }
+ },
+ "msg-task-agents": {
+ "id": "msg-task-agents",
+ "role": "task",
+ "content": "# AI Agents\n\nAutonomous agents using LLMs...",
+ "parentId": "msg-tool-1",
+ "createdAt": 1735526595647,
+ "updatedAt": 1735526792430,
+ "meta": {},
+ "taskDetail": {
+ "duration": 150000,
+ "status": "completed",
+ "threadId": "thd_agents",
+ "title": "Research AI agents",
+ "totalCost": 0.018,
+ "totalMessages": 20,
+ "totalTokens": 120000
+ }
+ },
+ "msg-task-rag": {
+ "id": "msg-task-rag",
+ "role": "task",
+ "content": "# RAG Systems\n\nRetrieval Augmented Generation combines...",
+ "parentId": "msg-tool-1",
+ "createdAt": 1735526596000,
+ "updatedAt": 1735526800000,
+ "meta": {},
+ "taskDetail": {
+ "duration": 130000,
+ "status": "completed",
+ "threadId": "thd_rag",
+ "title": "Research RAG systems",
+ "totalCost": 0.016,
+ "totalMessages": 18,
+ "totalTokens": 110000
+ }
+ },
+ "msg-assistant-summary": {
+ "id": "msg-assistant-summary",
+ "role": "assistant",
+ "content": "All three research tasks completed successfully. Here's a summary of the findings...",
+ "parentId": "msg-tool-1",
+ "createdAt": 1735526810000,
+ "updatedAt": 1735526820000,
+ "meta": {},
+ "model": "gpt-4",
+ "provider": "openai"
+ }
+ }
+}
diff --git a/packages/conversation-flow/src/__tests__/parse.test.ts b/packages/conversation-flow/src/__tests__/parse.test.ts
index 56107b1b17d..f0065a9418b 100644
--- a/packages/conversation-flow/src/__tests__/parse.test.ts
+++ b/packages/conversation-flow/src/__tests__/parse.test.ts
@@ -155,6 +155,47 @@ describe('parse', () => {
});
});
+ describe('Tasks Aggregation', () => {
+ it('should aggregate multiple task messages with same parentId', () => {
+ const result = parse(inputs.tasks.simple);
+
+ // The critical assertions:
+ // 1. flatList should have 4 items: user, assistantGroup(+tool), tasks(2 tasks), assistant-summary
+ expect(result.flatList).toHaveLength(4);
+ expect(result.flatList[0].role).toBe('user');
+ expect(result.flatList[1].role).toBe('assistantGroup');
+ expect(result.flatList[2].role).toBe('tasks');
+ expect(result.flatList[3].role).toBe('assistant');
+
+ // 2. tasks virtual message should have 2 children
+ expect((result.flatList[2] as any).children).toHaveLength(2);
+
+ // 3. contextTree should have tasks node
+ const tasksNode = result.contextTree.find((node) => node.type === 'tasks');
+ expect(tasksNode).toBeDefined();
+ expect((tasksNode as any).children).toHaveLength(2);
+
+ expect(serializeParseResult(result)).toEqual(outputs.tasks.simple);
+ });
+
+ it('should aggregate three task messages with summary', () => {
+ const result = parse(inputs.tasks.withSummary);
+
+ // The critical assertions:
+ // 1. flatList should have 4 items: user, assistantGroup(+tool), tasks(3 tasks), assistant-summary
+ expect(result.flatList).toHaveLength(4);
+ expect(result.flatList[0].role).toBe('user');
+ expect(result.flatList[1].role).toBe('assistantGroup');
+ expect(result.flatList[2].role).toBe('tasks');
+ expect(result.flatList[3].role).toBe('assistant');
+
+ // 2. tasks virtual message should have 3 children
+ expect((result.flatList[2] as any).children).toHaveLength(3);
+
+ expect(serializeParseResult(result)).toEqual(outputs.tasks.withSummary);
+ });
+ });
+
describe('Performance', () => {
it('should parse 10000 items within 100ms', () => {
// Generate 10000 messages as flat siblings (no deep nesting to avoid stack overflow)