Skip to content

Commit c5c7adc

Browse files
daniel-lxsEric Wheeler
authored andcommitted
fix: ensure newUserContent is never empty when resuming tasks
Added a check to ensure that newUserContent always has at least one text block when calling initiateTaskLoop. This prevents the 'text content blocks must be non-empty' API error when resuming a task with no response text or images.
1 parent 0e86549 commit c5c7adc

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/core/task/Task.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,15 @@ export class Task extends EventEmitter<ClineEvents> {
998998
newUserContent.push(...formatResponse.imageBlocks(responseImages))
999999
}
10001000

1001+
// Ensure we have at least some content to send to the API
1002+
// If newUserContent is empty, add a minimal resumption message
1003+
if (newUserContent.length === 0) {
1004+
newUserContent.push({
1005+
type: "text",
1006+
text: "[TASK RESUMPTION] Resuming task...",
1007+
})
1008+
}
1009+
10011010
await this.overwriteApiConversationHistory(modifiedApiConversationHistory)
10021011

10031012
console.log(`[subtasks] task ${this.taskId}.${this.instanceId} resuming from history item`)

0 commit comments

Comments
 (0)