@@ -325,7 +325,7 @@ describe("BUG-R86 routed web-search timeout semantics", () => {
325325 expect ( text ) . toContain ( "event: response.completed" ) ;
326326 } ) ;
327327
328- test ( "routed iterations use upstream streaming and never call parseResponse" , async ( ) => {
328+ test ( "routed iterations isolate diagnostic failures and never call parseResponse" , async ( ) => {
329329 const seenStream : boolean [ ] = [ ] ;
330330 const reasoningLogs : unknown [ ] = [ ] ;
331331 let parseStreamCalls = 0 ;
@@ -366,7 +366,10 @@ describe("BUG-R86 routed web-search timeout semantics", () => {
366366 selectedForwardHeaders : new Headers ( { authorization : "Bearer token" } ) ,
367367 settings : { model : "gpt-5.6-luna" , reasoning : "low" , timeoutMs : 30_000 } ,
368368 maxSearches : 1 ,
369- onRequestBuilt : request => reasoningLogs . push ( request . reasoningLog ) ,
369+ onRequestBuilt : request => {
370+ reasoningLogs . push ( request . reasoningLog ) ;
371+ throw new Error ( "diagnostic hook failure must not abort delivery" ) ;
372+ } ,
370373 } ) ;
371374
372375 expect ( response . status ) . toBe ( 200 ) ;
@@ -498,16 +501,37 @@ describe("web-search sidecar native web_search_call emission", () => {
498501 ) ) ) as typeof fetch ;
499502
500503 // First adapter always 429s via fetchResponse; the rotated adapter answers.
504+ const reasoningLogs : unknown [ ] = [ ] ;
501505 const firstAdapter : ProviderAdapter = {
502506 name : "mock-429" ,
503- buildRequest : ( ) => ( { url : "https://routed.test/v1" , method : "POST" , headers : { } , body : "{}" } ) ,
507+ buildRequest : ( ) => ( {
508+ url : "https://routed.test/v1" ,
509+ method : "POST" ,
510+ headers : { } ,
511+ body : "{}" ,
512+ reasoningLog : {
513+ effectiveEffort : "low" ,
514+ wireField : "reasoning_effort" ,
515+ wireValue : "low" ,
516+ } ,
517+ } ) ,
504518 fetchResponse : async ( ) => new Response ( "rate limited" , { status : 429 , headers : { "retry-after" : "30" } } ) ,
505519 async * parseStream ( ) { /* unused */ } ,
506520 async parseResponse ( ) { return [ { type : "text_delta" , text : "should not reach" } , { type : "done" } ] as AdapterEvent [ ] ; } ,
507521 } ;
508522 const rotatedAdapter : ProviderAdapter = {
509523 name : "mock-rotated" ,
510- buildRequest : ( ) => ( { url : "https://routed.test/v1" , method : "POST" , headers : { } , body : "{}" } ) ,
524+ buildRequest : ( ) => ( {
525+ url : "https://routed.test/v1" ,
526+ method : "POST" ,
527+ headers : { } ,
528+ body : "{}" ,
529+ reasoningLog : {
530+ effectiveEffort : "high" ,
531+ wireField : "reasoning_effort" ,
532+ wireValue : "high" ,
533+ } ,
534+ } ) ,
511535 fetchResponse : async ( ) => new Response ( "{}" , { status : 200 } ) ,
512536 async * parseStream ( ) {
513537 yield { type : "text_delta" , text : "answer from rotated key" } ;
@@ -525,6 +549,7 @@ describe("web-search sidecar native web_search_call emission", () => {
525549 selectedForwardHeaders : new Headers ( { authorization : "Bearer token" } ) ,
526550 settings : { model : "gpt-5.4-mini" , reasoning : "low" , timeoutMs : 30_000 } ,
527551 maxSearches : 1 ,
552+ onRequestBuilt : request => reasoningLogs . push ( request . reasoningLog ) ,
528553 on429 : retryAfter => {
529554 rotations ++ ;
530555 expect ( retryAfter ) . toBe ( "30" ) ;
@@ -537,6 +562,18 @@ describe("web-search sidecar native web_search_call emission", () => {
537562 const output = completed . output as { type : string ; content ?: { text ?: string } [ ] } [ ] ;
538563 expect ( output . find ( o => o . type === "message" ) ?. content ?. [ 0 ] ?. text ) . toBe ( "answer from rotated key" ) ;
539564 expect ( rotations ) . toBe ( 1 ) ;
565+ expect ( reasoningLogs ) . toEqual ( [
566+ {
567+ effectiveEffort : "low" ,
568+ wireField : "reasoning_effort" ,
569+ wireValue : "low" ,
570+ } ,
571+ {
572+ effectiveEffort : "high" ,
573+ wireField : "reasoning_effort" ,
574+ wireValue : "high" ,
575+ } ,
576+ ] ) ;
540577 } ) ;
541578
542579 test ( "loop 429 with exhausted pool (on429 null) surfaces the provider error" , async ( ) => {
0 commit comments