-
Notifications
You must be signed in to change notification settings - Fork 331
fix(maker-core): surface Claude subagent launch failures to the parent task #3024
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 9 commits
559b19b
e47400a
68452e1
43be3a5
01d6527
6d166f0
a59f8c7
0c51141
3a63d8c
b1c3fe5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ import { | |
| import { useTranslation } from 'react-i18next'; | ||
| import { | ||
| deriveAgentTaskStatus, | ||
| isSubagentResultError, | ||
| type AgentTaskTerminalStatus, | ||
| } from '@cindy/maker-shared/agent-task'; | ||
|
|
||
|
|
@@ -235,6 +236,7 @@ export function AgentTaskCard({ | |
| resultIsLaunchReceipt: | ||
| subagentSpawnReceiptName(toolCall?.toolName, toolCall?.toolInput, result) !== undefined | ||
| || subagentSpawnResultIndicatesRunning(toolCall?.toolName, result), | ||
| resultIsError: isSubagentResultError(result), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 当历史 Claude 子任务只有以 Context Used: 使用和PR描述相同的语言进行评论 (source) Knowledge Base Used: Prompt To Fix With AIThis is a comment left during a code review.
Path: apps/desktop/src/renderer/components/chat/AgentTaskCard.tsx
Line: 239
Comment:
**跨端终态不一致**
当历史 Claude 子任务只有以 `<tool_use_error>` 开头的工具结果、没有持久化终态或实时更新时,这里只让 Desktop 聊天卡片将其判为 `failed`;Mobile 共享卡片模型和 Desktop 后台任务列表仍按“有结果即完成”推导为 `completed`,导致同一启动失败在重连或重载后的不同入口显示相反终态。
**Context Used:** 使用和PR描述相同的语言进行评论 ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))
**Knowledge Base Used:**
- [Agent runtime](https://app.greptile.com/xindong/-/custom-context/knowledge-base/makecindy/cindy/-/docs/agent-runtime.md)
- [Desktop renderer experience](https://app.greptile.com/xindong/-/custom-context/knowledge-base/makecindy/cindy/-/docs/desktop-renderer-experience.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly. |
||
| }); | ||
| const StatusIcon = statusIcon(status); | ||
| const statusIconClassName = cn( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ | |
| import { | ||
| deriveAgentTaskStatus, | ||
| isAgentTaskToolName, | ||
| isSubagentResultError, | ||
| subagentSpawnReceiptName, | ||
| subagentSpawnResultIndicatesRunning, | ||
| } from '@cindy/maker-shared/agent-task'; | ||
|
|
@@ -341,6 +342,7 @@ export function listSessionTasks(input: { | |
| resultIsLaunchReceipt: | ||
| subagentSpawnReceiptName(toolName, toolInput, resultText) !== undefined | ||
| || subagentSpawnResultIndicatesRunning(toolName, resultText), | ||
| resultIsError: isSubagentResultError(resultText), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 当 Desktop 重载或远程控制端重连后,live-only 的 Useful? React with 👍 / 👎. |
||
| }) | ||
| : (settled ? 'completed' : isSessionStreaming ? 'running' : 'stopped'); | ||
| const provider: SessionTaskItem['provider'] = | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -174,15 +174,50 @@ export function deriveAgentTaskStatus( | |
| options?: { | ||
| resultIsLaunchReceipt?: boolean; | ||
| persistedStatus?: AgentTaskTerminalStatus; | ||
| resultIsError?: boolean; | ||
| }, | ||
| ): AgentTaskStatus { | ||
| const persistedStatus = normalizeAgentTaskTerminalStatus(options?.persistedStatus); | ||
| if (persistedStatus) return persistedStatus; | ||
| const hasResult = typeof result === 'string' && result.trim().length > 0; | ||
| if (options?.resultIsError && hasResult) return 'failed'; | ||
| if (updateStatus === 'running' && hasResult && !options?.resultIsLaunchReceipt) return 'completed'; | ||
| return updateStatus ?? (hasResult ? 'completed' : 'running'); | ||
| } | ||
|
|
||
| /** | ||
| * 判断子任务工具结果是否以协议级错误收尾(历史回放恢复 failed 的依据)。 | ||
| * | ||
| * 仅识别 Claude SDK 协议标记 `<tool_use_error>` — 这是 SDK 在 tool call 失败时 | ||
| * 发出的结构化错误格式。不解析任意 JSON 字段或自然语言错误短语,因为子任务结果 | ||
| * 内容是用户工作产物,其中 "errors"/"status"/"stderr" 等字段是数据而非执行信号。 | ||
| * | ||
| * 调用方约束:此函数仅应在已确认为子任务上下文的调用点使用 | ||
| * (AgentTaskCard / listSessionTasks)。普通工具结果包含 `<tool_use_error>` 时 | ||
| * 不应传入此函数,否则会将非子任务结果误判为失败。 | ||
| * | ||
| * Authority: Claude protocol `<tool_use_error>` — SDK 在 tool call 失败时发出。 | ||
| */ | ||
| export function isSubagentResultError(result: string | undefined): boolean { | ||
|
Battleplus marked this conversation as resolved.
|
||
| const text = typeof result === 'string' ? result.trim() : ''; | ||
| if (text.length === 0) return false; | ||
| // Only trust protocol-level error markers. Subagent result content is arbitrary | ||
| // user work product -- fields like "errors", "status", "stderr" in JSON output | ||
| // are data, not execution failure signals. Parsing arbitrary body for | ||
| // error-looking fields creates false positives that mark successful tasks as | ||
| // failed after Desktop reload / Mobile reconnect. | ||
| // | ||
| // Authority sources: | ||
| // 1. Claude protocol <tool_use_error> -- emitted by the SDK when a tool call fails | ||
| // 2. Persisted structured terminal status (agentTaskStatus) -- written by | ||
| // messagePersistBroadcaster on terminal observations | ||
| // | ||
| // Note: <error> prefix removed -- too generic. A subagent returning | ||
| // `<error>校验报告</error>` as work output would be misclassified as failure. | ||
| // Only <tool_use_error> is a reliable protocol-owned error marker. | ||
| return text.startsWith('<tool_use_error>'); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 当 Mobile 重连后只有配对的 Useful? React with 👍 / 👎. |
||
| } | ||
|
|
||
| /** | ||
| * Tool names that spawn a sub-agent task: Claude `Task`/`Agent`, Codex collab agents, | ||
| * PI `subagent`(Cindy 自有扩展注册的工具名,与 pi 社区惯例一致)。 | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.