@@ -21,6 +21,8 @@ export interface VisionCaptionOutcome {
2121 timedOutRequests : number ;
2222 failedRequests : number ;
2323 budgetExhausted : boolean ;
24+ /** Failure outside provider request handling (filesystem, module, or programming error). */
25+ internalError ?: boolean ;
2426}
2527
2628interface VisionCaptionOptions {
@@ -36,11 +38,14 @@ export function resolveVisionPhaseCompletion(
3638 | { status : "completed" }
3739 | {
3840 status : "degraded" ;
39- reason : "budget-exhausted" | "request-timeout" | "provider-error" ;
41+ reason : "budget-exhausted" | "request-timeout" | "provider-error" | "internal-error" ;
4042 } {
4143 if ( outcome . budgetExhausted || remainingMs <= 0 ) {
4244 return { status : "degraded" , reason : "budget-exhausted" } ;
4345 }
46+ if ( outcome . internalError ) {
47+ return { status : "degraded" , reason : "internal-error" } ;
48+ }
4449 if ( outcome . timedOutRequests > 0 ) {
4550 return { status : "degraded" , reason : "request-timeout" } ;
4651 }
@@ -245,12 +250,15 @@ export async function captionImagesWithGemini(
245250 let timedOutCount = 0 ;
246251 let failedRequestCount = 0 ;
247252 let budgetExhausted = false ;
253+ let internalError = false ;
248254 const reportOutcome = ( ) : void => {
249- options . onOutcome ?. ( {
255+ const outcome : VisionCaptionOutcome = {
250256 timedOutRequests : timedOutCount ,
251257 failedRequests : failedRequestCount ,
252258 budgetExhausted,
253- } ) ;
259+ } ;
260+ if ( internalError ) outcome . internalError = true ;
261+ options . onOutcome ?.( outcome ) ;
254262 } ;
255263 if ( options . skipVision ) {
256264 reportOutcome ( ) ;
@@ -546,8 +554,8 @@ export async function captionImagesWithGemini(
546554 ) ;
547555 }
548556 } catch {
549- failedRequestCount = Math . max ( 1 , failedRequestCount ) ;
550- warnings . push ( `${ providerName } captioning failed; captions omitted.` ) ;
557+ internalError = true ;
558+ warnings . push ( `${ providerName } captioning failed internally ; captions omitted.` ) ;
551559 }
552560
553561 reportOutcome ( ) ;
0 commit comments