@@ -131,7 +131,20 @@ describe('run failure telemetry smoke', () => {
131131 expectedDetail : 'prompt_too_large' ,
132132 expectedDiagnosticSource : 'error_event' ,
133133 expectStderr : false ,
134- message : `od-failure-smoke-context ${ 'large-context ' . repeat ( 4000 ) } ` ,
134+ message : `od-failure-smoke-context ${ 'large-context ' . repeat ( 10_000 ) } ` ,
135+ } ,
136+ {
137+ id : 'model_context_budget' ,
138+ agentId : 'claude' ,
139+ config : { agentCliEnv : { claude : { CLAUDE_BIN : path . join ( binDir , 'claude-auth' ) } } } ,
140+ model : 'claude-sonnet-4-5' ,
141+ expectedCode : 'AGENT_PROMPT_TOO_LARGE' ,
142+ expectedCategory : 'prompt_too_large' ,
143+ expectedDetail : 'prompt_too_large' ,
144+ expectedDiagnosticSource : 'error_event' ,
145+ expectedContextBudgetAction : 'blocked' ,
146+ expectStderr : false ,
147+ message : `od-failure-smoke-model-context ${ 'x' . repeat ( 650_000 ) } ` ,
135148 } ,
136149 {
137150 id : 'hang_timeout' ,
@@ -151,6 +164,7 @@ describe('run failure telemetry smoke', () => {
151164 caseId : item . id ,
152165 agentId : item . agentId ,
153166 message : 'message' in item ? item . message : `od-failure-smoke-${ item . id } ` ,
167+ ...( 'model' in item ? { model : item . model } : { } ) ,
154168 } ) ;
155169 const events = await readRunEvents ( run . eventsLogPath ) ;
156170 const errorCode = deriveRunErrorCode ( run ) ;
@@ -167,20 +181,33 @@ describe('run failure telemetry smoke', () => {
167181 signal : run . signal ,
168182 } ) ;
169183
170- expect ( run . status ) . toBe ( 'failed' ) ;
184+ expect ( run . status , item . id ) . toBe ( 'failed' ) ;
171185 expect ( 'expectedCodes' in item ? item . expectedCodes : [ item . expectedCode ] )
172186 . toContain ( errorCode ) ;
173187 expect ( failure ?. failure_category ) . toBe ( item . expectedCategory ) ;
174188 expect ( failure ?. failure_detail ) . toBe ( item . expectedDetail ) ;
175189 expect ( diagnostics . diagnostic_source ) . toBe ( item . expectedDiagnosticSource ) ;
176190 expect ( diagnostics . stderr_present ) . toBe ( item . expectStderr ) ;
191+ if ( 'expectedContextBudgetAction' in item ) {
192+ expect ( events ) . toContainEqual ( expect . objectContaining ( {
193+ event : 'diagnostic' ,
194+ data : expect . objectContaining ( {
195+ type : 'model_context_budget' ,
196+ action : item . expectedContextBudgetAction ,
197+ } ) ,
198+ } ) ) ;
199+ }
177200
178201 await finalizeAssistantMessage ( started . url , run ) ;
179202 const trace = await ingestion . waitForTrace ( run . id ) ;
180203 expect ( 'expectedCodes' in item ? item . expectedCodes : [ item . expectedCode ] )
181204 . toContain ( trace . body . metadata . error_code ) ;
182205 expect ( trace . body . metadata . failure_category ) . toBe ( item . expectedCategory ) ;
183206 expect ( trace . body . metadata . failure_detail ) . toBe ( item . expectedDetail ) ;
207+ if ( 'expectedContextBudgetAction' in item ) {
208+ expect ( trace . body . metadata . contextBudgetAction ) . toBe ( item . expectedContextBudgetAction ) ;
209+ expect ( trace . body . metadata . contextWindowTokens ) . toBe ( 204_800 ) ;
210+ }
184211 if ( item . expectStderr ) {
185212 expect ( trace . body . metadata . stderr . lineCount ) . toBeGreaterThan ( 0 ) ;
186213 } else {
@@ -479,6 +506,7 @@ async function createAndWaitForRun(url: string, input: {
479506 caseId : string ;
480507 agentId : string ;
481508 message : string ;
509+ model ?: string ;
482510} ) : Promise < RunStatus > {
483511 const projectId = `failure_smoke_${ input . caseId } _${ randomUUID ( ) } ` ;
484512 const projectResponse = await fetch ( `${ url } /api/projects` , {
@@ -503,6 +531,7 @@ async function createAndWaitForRun(url: string, input: {
503531 assistantMessageId,
504532 clientRequestId : `client_${ input . caseId } _${ randomUUID ( ) } ` ,
505533 agentId : input . agentId ,
534+ ...( input . model ? { model : input . model } : { } ) ,
506535 message : input . message ,
507536 currentPrompt : input . message ,
508537 } ) ,
0 commit comments