Skip to content

Commit aa74e7d

Browse files
committed
Handle codex errors as acp agent messages
1 parent 3d44e19 commit aa74e7d

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/CodexEventHandler.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {ACPSessionConnection, type UpdateSessionEvent} from "./ACPSessionConnect
77
import type {
88
AgentMessageDeltaNotification,
99
CommandAction,
10+
ErrorNotification,
1011
FileUpdateChange,
1112
ItemCompletedNotification,
1213
ItemStartedNotification,
@@ -50,6 +51,8 @@ export class CodexEventHandler {
5051
return await this.completeItemEvent(notification.params);
5152
case "turn/plan/updated":
5253
return await this.updatePlan(notification.params);
54+
case "error":
55+
return await this.createErrorEvent(notification.params);
5356
case "item/reasoning/summaryTextDelta": //TODO streaming reasoning?
5457
case "item/reasoning/summaryPartAdded":
5558
//skipped events
@@ -59,7 +62,6 @@ export class CodexEventHandler {
5962
case "turn/diff/updated":
6063
case "item/commandExecution/outputDelta":
6164
case "item/fileChange/outputDelta":
62-
case "error":
6365
case "thread/tokenUsage/updated":
6466
case "item/mcpToolCall/progress":
6567
case "account/updated":
@@ -219,4 +221,14 @@ export class CodexEventHandler {
219221
entries: plan,
220222
}
221223
}
224+
225+
private async createErrorEvent(params: ErrorNotification): Promise<UpdateSessionEvent> {
226+
return {
227+
sessionUpdate: "agent_message_chunk",
228+
content: {
229+
type: "text",
230+
text: `❌ ${params.error.message}\n\n`
231+
}
232+
}
233+
}
222234
}

0 commit comments

Comments
 (0)