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.
This commit is contained in:
Roo Code 2025-06-19 18:34:57 +00:00
parent 2e2f83be60
commit dc3359a224

View file

@ -1422,10 +1422,17 @@ export class Task extends EventEmitter<ClineEvents> {
error.message ?? JSON.stringify(serializeError(error), null, 2),
)
const history = await provider?.getTaskWithId(this.taskId)
// Check if this is a subtask - if so, return to parent instead of reinitializing
if (this.parentTask) {
// For subtasks, finish the subtask and return to parent
await provider?.finishSubTask(`API streaming error: ${error.message ?? "Unknown error"}`)
} else {
// For main tasks, reinitialize with history as before
const history = await provider?.getTaskWithId(this.taskId)
if (history) {
await provider?.initClineWithHistoryItem(history.historyItem)
if (history) {
await provider?.initClineWithHistoryItem(history.historyItem)
}
}
}
} finally {