@@ -19,6 +19,18 @@ describe("ResponseItemHistoryFallback", () => {
1919 ] ) ;
2020 } ) ;
2121
22+ it ( "does not recover function calls when all parsed tool call ids already exist" , ( ) => {
23+ const updates = parseResponseItemHistoryFallback ( jsonl ( [
24+ functionCall ( "call-existing-a" , "rg \"ExistingA\" src" ) ,
25+ functionCallOutput ( "call-existing-a" , "Chunk ID: existing-a\nProcess exited with code 0\nOutput:\nsrc/a.ts\n" ) ,
26+ functionCall ( "call-existing-b" , "rg \"ExistingB\" src" ) ,
27+ functionCallOutput ( "call-existing-b" , "Chunk ID: existing-b\nProcess exited with code 0\nOutput:\nsrc/b.ts\n" ) ,
28+ ] ) , "terminal_output" , new Set ( [ "call-existing-a" , "call-existing-b" ] ) ) ;
29+
30+ expect ( toolCallIds ( updates ) ) . toEqual ( [ ] ) ;
31+ expect ( toolCallUpdateStatuses ( updates ) ) . toEqual ( [ ] ) ;
32+ } ) ;
33+
2234 it ( "does not duplicate adjacent reasoning from event and response item records" , ( ) => {
2335 const updates = parseResponseItemHistoryFallback ( jsonl ( [
2436 {
@@ -53,6 +65,17 @@ describe("ResponseItemHistoryFallback", () => {
5365 { toolCallId : "call-read-failed" , status : "failed" } ,
5466 ] ) ;
5567 } ) ;
68+
69+ it ( "marks exec command outputs without exit footers completed when they do not report errors" , ( ) => {
70+ const updates = parseResponseItemHistoryFallback ( jsonl ( [
71+ functionCall ( "call-read-ok" , "cat existing.txt" ) ,
72+ functionCallOutput ( "call-read-ok" , "existing file contents\n" ) ,
73+ ] ) , "terminal_output" ) ;
74+
75+ expect ( toolCallUpdateStatuses ( updates ) ) . toEqual ( [
76+ { toolCallId : "call-read-ok" , status : "completed" } ,
77+ ] ) ;
78+ } ) ;
5679} ) ;
5780
5881function jsonl ( records : unknown [ ] ) : string {
0 commit comments