@@ -4900,6 +4900,18 @@ describe("CodexAdapterV2 post-settle continuation", () => {
49004900 notification : false ,
49014901 expectedClass : "usage_limit" ,
49024902 } ,
4903+ {
4904+ name : "matching-details" ,
4905+ code : "usageLimitExceeded" ,
4906+ notification : true ,
4907+ expectedClass : "usage_limit" ,
4908+ } ,
4909+ {
4910+ name : "deferred-reset" ,
4911+ code : "usageLimitExceeded" ,
4912+ notification : false ,
4913+ expectedClass : "usage_limit" ,
4914+ } ,
49034915 { name : "retry" , code : "usageLimitExceeded" , notification : true , expectedClass : "usage_limit" } ,
49044916 ] as const ) {
49054917 it . effect ( `classifies Codex terminal failures from ${ scenario . name } evidence` , ( ) =>
@@ -4926,7 +4938,45 @@ describe("CodexAdapterV2 post-settle continuation", () => {
49264938 scenario : `codex-limit-${ scenario . name } ` ,
49274939 entries : [
49284940 ...codexReplayPreamble ( { nativeThreadId, nativeTurnId, prompt : "Continue." } ) ,
4929- ...( scenario . name === "known-reset" ? [ snapshot ] : [ ] ) ,
4941+ ...( scenario . name === "known-reset" || scenario . name === "deferred-reset"
4942+ ? [ snapshot ]
4943+ : [ ] ) ,
4944+ ...( scenario . name === "deferred-reset"
4945+ ? [
4946+ {
4947+ type : "emit_inbound" as const ,
4948+ label : "item/completed/subAgentActivity-started" ,
4949+ frame : {
4950+ method : "item/completed" ,
4951+ params : {
4952+ threadId : nativeThreadId ,
4953+ turnId : nativeTurnId ,
4954+ item : {
4955+ type : "subAgentActivity" ,
4956+ id : "limit-child-spawn" ,
4957+ kind : "started" ,
4958+ agentThreadId : "native-limit-child" ,
4959+ agentPath : "/root/limit_child" ,
4960+ } ,
4961+ } ,
4962+ } ,
4963+ } ,
4964+ {
4965+ type : "emit_inbound" as const ,
4966+ label : "turn/started/child" ,
4967+ frame : {
4968+ method : "turn/started" ,
4969+ params : {
4970+ threadId : "native-limit-child" ,
4971+ turn : makeCodexReplayTurn ( {
4972+ id : "limit-child-turn" ,
4973+ status : "inProgress" ,
4974+ } ) ,
4975+ } ,
4976+ } ,
4977+ } ,
4978+ ]
4979+ : [ ] ) ,
49304980 ...( scenario . notification
49314981 ? [
49324982 {
@@ -4941,7 +4991,10 @@ describe("CodexAdapterV2 post-settle continuation", () => {
49414991 error : {
49424992 message,
49434993 codexErrorInfo : scenario . code ,
4944- additionalDetails : null ,
4994+ additionalDetails :
4995+ scenario . name === "matching-details"
4996+ ? "Detailed provider allowance explanation."
4997+ : null ,
49454998 } ,
49464999 } ,
49475000 } ,
@@ -4959,13 +5012,49 @@ describe("CodexAdapterV2 post-settle continuation", () => {
49595012 ...makeCodexReplayTurn ( { id : nativeTurnId , status : "failed" } ) ,
49605013 error : {
49615014 message : scenario . name === "replacement" ? "A different failure." : message ,
4962- ...( scenario . notification ? { } : { codexErrorInfo : scenario . code } ) ,
5015+ ...( scenario . notification && scenario . name !== "matching-details"
5016+ ? { }
5017+ : { codexErrorInfo : scenario . code } ) ,
49635018 } ,
49645019 } ,
49655020 } ,
49665021 } ,
49675022 } ,
49685023 ...( scenario . name === "late-reset" ? [ snapshot ] : [ ] ) ,
5024+ ...( scenario . name === "deferred-reset"
5025+ ? [
5026+ {
5027+ ...snapshot ,
5028+ frame : {
5029+ method : "account/rateLimits/updated" ,
5030+ params : {
5031+ rateLimits : {
5032+ limitId : "codex" ,
5033+ primary : {
5034+ usedPercent : 100 ,
5035+ resetsAt : 2000200000 ,
5036+ windowDurationMins : 300 ,
5037+ } ,
5038+ } ,
5039+ } ,
5040+ } ,
5041+ } ,
5042+ {
5043+ type : "emit_inbound" as const ,
5044+ label : "turn/completed/child" ,
5045+ frame : {
5046+ method : "turn/completed" ,
5047+ params : {
5048+ threadId : "native-limit-child" ,
5049+ turn : makeCodexReplayTurn ( {
5050+ id : "limit-child-turn" ,
5051+ status : "completed" ,
5052+ } ) ,
5053+ } ,
5054+ } ,
5055+ } ,
5056+ ]
5057+ : [ ] ) ,
49695058 ] ,
49705059 } ) ;
49715060 const resetReceipt = yield * Deferred . make < void > ( ) ;
@@ -4991,7 +5080,10 @@ describe("CodexAdapterV2 post-settle continuation", () => {
49915080 if ( terminal ?. status !== "failed" ) return ;
49925081 assert . equal ( terminal . failure . class , scenario . expectedClass ) ;
49935082 assert . equal ( terminal . threadDisposition , "reusable" ) ;
4994- if ( scenario . name === "known-reset" ) assert . equal ( terminal . failure . resetAt , resetAt ) ;
5083+ if ( scenario . name === "known-reset" || scenario . name === "deferred-reset" )
5084+ assert . equal ( terminal . failure . resetAt , resetAt ) ;
5085+ if ( scenario . name === "matching-details" )
5086+ assert . equal ( terminal . failure . message , "Detailed provider allowance explanation." ) ;
49955087 if ( scenario . name === "late-reset" ) {
49965088 yield * Deferred . await ( resetReceipt ) ;
49975089 const item = harness . events . find (
0 commit comments