@@ -1724,6 +1724,11 @@ export async function runEmbeddedAgent(
17241724 lastAssistant : sessionLastAssistant ,
17251725 currentAttemptAssistant,
17261726 } = attempt ;
1727+ const setTerminalLifecycleMeta : NonNullable <
1728+ typeof attempt . setTerminalLifecycleMeta
1729+ > = ( meta ) => {
1730+ attempt . setTerminalLifecycleMeta ?.( { ...meta , aborted } ) ;
1731+ } ;
17271732 const timedOutDuringToolExecution = attempt . timedOutDuringToolExecution ?? false ;
17281733 if ( sessionIdUsed && sessionIdUsed !== activeSessionId ) {
17291734 activeSessionId = sessionIdUsed ;
@@ -2340,7 +2345,7 @@ export async function runEmbeddedAgent(
23402345 `[context-overflow-recovery] exhausted provider overflow recovery for ${ provider } /${ modelId } ; ` +
23412346 `livenessState=blocked suggestedAction=reset_or_new kind=${ kind } ` ,
23422347 ) ;
2343- attempt . setTerminalLifecycleMeta ?. ( {
2348+ setTerminalLifecycleMeta ( {
23442349 replayInvalid : resolveReplayInvalidForAttempt ( ) ,
23452350 livenessState : "blocked" ,
23462351 } ) ;
@@ -2378,7 +2383,7 @@ export async function runEmbeddedAgent(
23782383 if ( promptErrorSource === "hook:before_agent_run" && ! aborted ) {
23792384 const errorText = formatErrorMessage ( promptError ) ;
23802385 const replayInvalid = resolveReplayInvalidForAttempt ( ) ;
2381- attempt . setTerminalLifecycleMeta ?. ( {
2386+ setTerminalLifecycleMeta ( {
23822387 replayInvalid,
23832388 livenessState : "blocked" ,
23842389 } ) ;
@@ -2483,7 +2488,7 @@ export async function runEmbeddedAgent(
24832488 }
24842489 // Handle role ordering errors with a user-friendly message
24852490 if ( / i n c o r r e c t r o l e i n f o r m a t i o n | r o l e s m u s t a l t e r n a t e / i. test ( errorText ) ) {
2486- attempt . setTerminalLifecycleMeta ?. ( {
2491+ setTerminalLifecycleMeta ( {
24872492 replayInvalid : resolveReplayInvalidForAttempt ( ) ,
24882493 livenessState : "blocked" ,
24892494 } ) ;
@@ -2524,7 +2529,7 @@ export async function runEmbeddedAgent(
25242529 const maxMbLabel =
25252530 typeof maxMb === "number" && Number . isFinite ( maxMb ) ? `${ maxMb } ` : null ;
25262531 const maxBytesHint = maxMbLabel ? ` (max ${ maxMbLabel } MB)` : "" ;
2527- attempt . setTerminalLifecycleMeta ?. ( {
2532+ setTerminalLifecycleMeta ( {
25282533 replayInvalid : resolveReplayInvalidForAttempt ( ) ,
25292534 livenessState : "blocked" ,
25302535 } ) ;
@@ -3035,7 +3040,7 @@ export async function runEmbeddedAgent(
30353040 } ) ;
30363041 const timeoutPhase = attempt . promptTimeoutOutcome ?. timeoutPhase ?? "provider" ;
30373042 const providerStarted = attempt . promptTimeoutOutcome ?. providerStarted ?? true ;
3038- attempt . setTerminalLifecycleMeta ?. ( {
3043+ setTerminalLifecycleMeta ( {
30393044 replayInvalid,
30403045 livenessState,
30413046 timeoutPhase,
@@ -3287,7 +3292,7 @@ export async function runEmbeddedAgent(
32873292 // terminal.
32883293 const replayInvalid = resolveReplayInvalidForAttempt ( null ) ;
32893294 const livenessState : EmbeddedRunLivenessState = "blocked" ;
3290- attempt . setTerminalLifecycleMeta ?. ( {
3295+ setTerminalLifecycleMeta ( {
32913296 replayInvalid,
32923297 livenessState,
32933298 } ) ;
@@ -3336,7 +3341,7 @@ export async function runEmbeddedAgent(
33363341 attempt,
33373342 incompleteTurnText : "⚠️ Agent couldn't generate a response. Please try again." ,
33383343 } ) ;
3339- attempt . setTerminalLifecycleMeta ?. ( {
3344+ setTerminalLifecycleMeta ( {
33403345 replayInvalid,
33413346 livenessState,
33423347 } ) ;
@@ -3442,7 +3447,7 @@ export async function runEmbeddedAgent(
34423447 attempt,
34433448 incompleteTurnText,
34443449 } ) ;
3445- attempt . setTerminalLifecycleMeta ?. ( {
3450+ setTerminalLifecycleMeta ( {
34463451 replayInvalid,
34473452 livenessState,
34483453 } ) ;
@@ -3564,7 +3569,7 @@ export async function runEmbeddedAgent(
35643569 const terminalPayloads = emptyAssistantReplyIsSilent
35653570 ? [ { text : SILENT_REPLY_TOKEN } ]
35663571 : payloadsForTerminalPath ;
3567- attempt . setTerminalLifecycleMeta ?. ( {
3572+ setTerminalLifecycleMeta ( {
35683573 replayInvalid,
35693574 livenessState,
35703575 stopReason,
0 commit comments