Skip to content

Commit b2c7191

Browse files
committed
Restore agent reasoning from event history
1 parent 9113be3 commit b2c7191

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

src/ResponseItemHistoryFallback.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ function createEventMsgUpdates(record: JsonRecord): UpdateSessionEvent[] | null
190190
switch (payload["type"]) {
191191
case "user_message":
192192
return createUserMessageEventUpdates(payload);
193+
case "agent_reasoning":
194+
return createAgentReasoningEventUpdates(payload);
193195
default:
194196
return [];
195197
}
@@ -210,6 +212,18 @@ function createUserMessageEventUpdates(payload: JsonRecord): UpdateSessionEvent[
210212
}));
211213
}
212214

215+
function createAgentReasoningEventUpdates(payload: JsonRecord): UpdateSessionEvent[] {
216+
const text = stringValue(payload["text"]);
217+
if (text === null || text.length === 0) {
218+
return [];
219+
}
220+
221+
return [{
222+
sessionUpdate: "agent_thought_chunk",
223+
content: { type: "text", text },
224+
}];
225+
}
226+
213227
function imageBlocks(images: unknown): ContentBlock[] {
214228
if (!Array.isArray(images)) {
215229
return [];

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,11 +320,19 @@ describe("CodexACPAgent - loadSession", () => {
320320
content: [{ type: "input_text", text: "List the files" }],
321321
},
322322
},
323+
{
324+
type: "event_msg",
325+
payload: {
326+
type: "agent_reasoning",
327+
text: "Need to inspect the directory.",
328+
},
329+
},
323330
{
324331
type: "response_item",
325332
payload: {
326333
type: "reasoning",
327-
summary: [{ type: "summary_text", text: "Need to inspect the directory." }],
334+
summary: [],
335+
content: [],
328336
encrypted_content: null,
329337
},
330338
},

0 commit comments

Comments
 (0)