Skip to content

Commit 09e6f9c

Browse files
authored
Handle error message from coding agent (#7721)
1 parent fb246e3 commit 09e6f9c

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/github/copilotRemoteAgent/chatSessionContentBuilder.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,12 @@ export class ChatSessionContentBuilder {
335335
// Skip if content is empty (running state)
336336
} else {
337337
if (delta.content) {
338-
if (!delta.content.startsWith('<pr_title>')) {
338+
if (!delta.content.startsWith('<pr_title>') && !delta.content.startsWith('<error>')) {
339339
currentResponseContent += delta.content;
340340
}
341341
}
342342

343+
const isError = delta.content?.startsWith('<error>');
343344
if (delta.tool_calls) {
344345
// Add any accumulated content as markdown first
345346
if (currentResponseContent.trim()) {
@@ -353,6 +354,15 @@ export class ChatSessionContentBuilder {
353354
responseParts.push(toolPart);
354355
}
355356
}
357+
358+
if (isError) {
359+
const toolPart = new vscode.ChatToolInvocationPart('Command', 'command');
360+
// Remove <error> at the start and </error> at the end
361+
const cleaned = (delta.content ?? '').replace(/^\s*<error>\s*/i, '').replace(/\s*<\/error>\s*$/i, '');
362+
toolPart.invocationMessage = cleaned;
363+
toolPart.isError = true;
364+
responseParts.push(toolPart);
365+
}
356366
}
357367
}
358368
}

0 commit comments

Comments
 (0)