@@ -2377,6 +2377,87 @@ describe("openai transport stream", () => {
23772377 }
23782378 } ) ;
23792379
2380+ it ( "keeps distinct overlong Copilot Responses replay item ids distinct" , ( ) => {
2381+ const sharedToolItemPrefix = "iVec" + "A" . repeat ( 160 ) ;
2382+ const firstToolCallId = `call_first|${ sharedToolItemPrefix } Aa` ;
2383+ const secondToolCallId = `call_second|${ sharedToolItemPrefix } BB` ;
2384+ const params = buildOpenAIResponsesParams (
2385+ {
2386+ id : "gpt-5.5" ,
2387+ name : "GPT-5.5" ,
2388+ api : "openai-responses" ,
2389+ provider : "github-copilot" ,
2390+ baseUrl : "https://api.githubcopilot.com" ,
2391+ reasoning : true ,
2392+ input : [ "text" ] ,
2393+ cost : { input : 0 , output : 0 , cacheRead : 0 , cacheWrite : 0 } ,
2394+ contextWindow : 200000 ,
2395+ maxTokens : 8192 ,
2396+ } satisfies Model < "openai-responses" > ,
2397+ {
2398+ systemPrompt : "system" ,
2399+ messages : [
2400+ {
2401+ role : "assistant" ,
2402+ api : "openai-responses" ,
2403+ provider : "github-copilot" ,
2404+ model : "gpt-5.5" ,
2405+ usage : {
2406+ input : 0 ,
2407+ output : 0 ,
2408+ cacheRead : 0 ,
2409+ cacheWrite : 0 ,
2410+ totalTokens : 0 ,
2411+ cost : { input : 0 , output : 0 , cacheRead : 0 , cacheWrite : 0 , total : 0 } ,
2412+ } ,
2413+ stopReason : "toolUse" ,
2414+ timestamp : 1 ,
2415+ content : [
2416+ { type : "toolCall" , id : firstToolCallId , name : "read" , arguments : { path : "a" } } ,
2417+ { type : "toolCall" , id : secondToolCallId , name : "read" , arguments : { path : "b" } } ,
2418+ ] ,
2419+ } ,
2420+ {
2421+ role : "toolResult" ,
2422+ toolCallId : firstToolCallId ,
2423+ toolName : "read" ,
2424+ content : [ { type : "text" , text : "a" } ] ,
2425+ isError : false ,
2426+ timestamp : 2 ,
2427+ } ,
2428+ {
2429+ role : "toolResult" ,
2430+ toolCallId : secondToolCallId ,
2431+ toolName : "read" ,
2432+ content : [ { type : "text" , text : "b" } ] ,
2433+ isError : false ,
2434+ timestamp : 3 ,
2435+ } ,
2436+ { role : "user" , content : "continue" , timestamp : 4 } ,
2437+ ] ,
2438+ tools : [ ] ,
2439+ } as never ,
2440+ { sessionId : "session-123" } ,
2441+ ) as {
2442+ input ?: Array < { type ?: string ; id ?: string ; call_id ?: string } > ;
2443+ } ;
2444+
2445+ const functionCalls = params . input ?. filter ( ( item ) => item . type === "function_call" ) ?? [ ] ;
2446+ const functionOutputs =
2447+ params . input ?. filter ( ( item ) => item . type === "function_call_output" ) ?? [ ] ;
2448+ expect ( functionCalls ) . toHaveLength ( 2 ) ;
2449+ expect ( functionOutputs ) . toHaveLength ( 2 ) ;
2450+ expect ( functionCalls . map ( ( item ) => item . id ) ) . toEqual ( [
2451+ expect . stringMatching ( / ^ f c _ / ) ,
2452+ expect . stringMatching ( / ^ f c _ / ) ,
2453+ ] ) ;
2454+ expect ( new Set ( functionCalls . map ( ( item ) => item . id ) ) . size ) . toBe ( 2 ) ;
2455+ for ( const item of functionCalls ) {
2456+ expect ( item . id ?. length ) . toBeLessThanOrEqual ( 64 ) ;
2457+ }
2458+ expect ( functionOutputs . map ( ( item ) => item . call_id ) ) . toEqual ( [ "call_first" , "call_second" ] ) ;
2459+ } ) ;
2460+
23802461 it ( "adds minimal user input for Codex responses when only the system prompt is present" , ( ) => {
23812462 const params = buildOpenAIResponsesParams (
23822463 {
0 commit comments