Skip to content

Commit f5fd3d2

Browse files
committed
🤖 fix: correct taskId in tool output injection
- Pass child task workspace ID (not parent) to injectToolOutputToParent - Fix fallback paths to also use correct taskId when posting as message - The taskId in TaskToolResult should identify the child task, not parent Change-Id: I9f8e8730d307e7c582b0c3f68b822a739b545489 Signed-off-by: Thomas Kosiewski <tk@coder.com>
1 parent 91046da commit f5fd3d2

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/node/services/taskService.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ export class TaskService extends EventEmitter {
331331
// This enables restart recovery - even if pendingCompletions was lost, the parent
332332
// will have the tool output when it resumes
333333
if (taskState.parentToolCallId) {
334-
await this.injectToolOutputToParent(taskState, args);
334+
await this.injectToolOutputToParent(workspaceId, taskState, args);
335335
} else {
336336
// Background task - post report as a message to parent history
337337
await this.postReportToParent(workspaceId, taskState, args);
@@ -389,6 +389,7 @@ export class TaskService extends EventEmitter {
389389
* persists across restarts.
390390
*/
391391
private async injectToolOutputToParent(
392+
taskId: string,
392393
taskState: TaskState,
393394
report: { reportMarkdown: string; title?: string }
394395
): Promise<void> {
@@ -397,7 +398,7 @@ export class TaskService extends EventEmitter {
397398

398399
const toolOutput: TaskToolResult = {
399400
status: "completed",
400-
taskId: taskState.parentWorkspaceId, // The task workspace ID
401+
taskId, // The child task workspace ID
401402
reportMarkdown: report.reportMarkdown,
402403
reportTitle: report.title,
403404
};
@@ -437,11 +438,11 @@ export class TaskService extends EventEmitter {
437438

438439
// Couldn't find the tool call - fall back to posting as message
439440
log.warn(`Could not find parent tool call ${parentToolCallId}, posting as message instead`);
440-
await this.postReportToParent(parentWorkspaceId, taskState, report);
441+
await this.postReportToParent(taskId, taskState, report);
441442
} catch (error) {
442443
log.error(`Failed to inject tool output to parent ${parentWorkspaceId}:`, error);
443444
// Fall back to posting as message
444-
await this.postReportToParent(parentWorkspaceId, taskState, report);
445+
await this.postReportToParent(taskId, taskState, report);
445446
}
446447
}
447448

0 commit comments

Comments
 (0)