Skip to content

Commit 3f360e8

Browse files
committed
Preserve failed tool call status in history fallback
1 parent 2c5d7bd commit 3f360e8

3 files changed

Lines changed: 53 additions & 1 deletion

File tree

src/ResponseItemHistoryFallback.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ function createFunctionCallOutputUpdate(
337337
return {
338338
sessionUpdate: "tool_call_update",
339339
toolCallId,
340-
status: "completed",
340+
status,
341341
rawOutput: { output: item["output"] },
342342
};
343343
}

src/__tests__/CodexACPAgent/data/load-session-response-item-history-fallback.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,37 @@
118118
}
119119
]
120120
}
121+
{
122+
"method": "sessionUpdate",
123+
"args": [
124+
{
125+
"sessionId": "session-legacy",
126+
"update": {
127+
"sessionUpdate": "tool_call",
128+
"toolCallId": "call-rg-failed",
129+
"status": "in_progress",
130+
"kind": "search",
131+
"title": "Search for 'Missing' in src"
132+
}
133+
}
134+
]
135+
}
136+
{
137+
"method": "sessionUpdate",
138+
"args": [
139+
{
140+
"sessionId": "session-legacy",
141+
"update": {
142+
"sessionUpdate": "tool_call_update",
143+
"toolCallId": "call-rg-failed",
144+
"status": "failed",
145+
"rawOutput": {
146+
"output": "Chunk ID: search456\nWall time: 0.0000 seconds\nProcess exited with code 1\nOutput:\n"
147+
}
148+
}
149+
}
150+
]
151+
}
121152
{
122153
"method": "sessionUpdate",
123154
"args": [

src/__tests__/CodexACPAgent/load-session.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,27 @@ describe("CodexACPAgent - loadSession", () => {
349349
output: "Chunk ID: search123\nWall time: 0.0000 seconds\nProcess exited with code 0\nOutput:\nsrc/service.ts:export class Service {}\n",
350350
},
351351
},
352+
{
353+
type: "response_item",
354+
payload: {
355+
type: "function_call",
356+
name: "exec_command",
357+
arguments: JSON.stringify({
358+
cmd: "rg \"Missing\" src",
359+
workdir: "/test/project",
360+
yield_time_ms: 1000,
361+
}),
362+
call_id: "call-rg-failed",
363+
},
364+
},
365+
{
366+
type: "response_item",
367+
payload: {
368+
type: "function_call_output",
369+
call_id: "call-rg-failed",
370+
output: "Chunk ID: search456\nWall time: 0.0000 seconds\nProcess exited with code 1\nOutput:\n",
371+
},
372+
},
352373
{
353374
type: "response_item",
354375
payload: {

0 commit comments

Comments
 (0)