Skip to content

Commit dc3359a

Browse files
committed
Fix #4896: Handle API streaming errors in subtasks properly
When an API streaming error occurs in a subtask, instead of reinitializing the subtask with history (which keeps it stuck in subtask view), properly return control to the parent task by calling finishSubTask(). This ensures that orchestrator mode can properly resume the parent task after a subtask encounters an API streaming failure during cancellation.
1 parent 2e2f83b commit dc3359a

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/core/task/Task.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,10 +1422,17 @@ export class Task extends EventEmitter<ClineEvents> {
14221422
error.message ?? JSON.stringify(serializeError(error), null, 2),
14231423
)
14241424

1425-
const history = await provider?.getTaskWithId(this.taskId)
1425+
// Check if this is a subtask - if so, return to parent instead of reinitializing
1426+
if (this.parentTask) {
1427+
// For subtasks, finish the subtask and return to parent
1428+
await provider?.finishSubTask(`API streaming error: ${error.message ?? "Unknown error"}`)
1429+
} else {
1430+
// For main tasks, reinitialize with history as before
1431+
const history = await provider?.getTaskWithId(this.taskId)
14261432

1427-
if (history) {
1428-
await provider?.initClineWithHistoryItem(history.historyItem)
1433+
if (history) {
1434+
await provider?.initClineWithHistoryItem(history.historyItem)
1435+
}
14291436
}
14301437
}
14311438
} finally {

0 commit comments

Comments
 (0)