@@ -13,10 +13,8 @@ import { formatDurationCompact } from "../../../infra/format-time/format-duratio
1313import { buildAgentRunTerminalOutcomeFromWaitResult } from "../../agent-run-terminal-outcome.js" ;
1414import { wrapPromptDataBlock } from "../../sanitize-for-prompt.js" ;
1515import { extractStoredAssistantText , sanitizeTextContent } from "../../tools/chat-history-text.js" ;
16- import {
17- isAnnounceSkip ,
18- selectDeliverableSessionsReply ,
19- } from "../../tools/sessions-send-tokens.js" ;
16+ import { isAnnounceSkip } from "../../tools/sessions-send-tokens.js" ;
17+ import { resolveSubagentCompletionResultText } from "../completion/subagent-completion-result.js" ;
2018import { compareSubagentRunGeneration } from "../registry/subagent-run-generation.js" ;
2119import { classifySubagentTerminalOutcome } from "../subagent-terminal-outcome.js" ;
2220import {
@@ -441,11 +439,7 @@ type ChildCompletionRow = {
441439 label ?: string ;
442440 createdAt : number ;
443441 execution : ChildCompletionExecution ;
444- frozenResultText ?: string | null ;
445- completion ?: {
446- resultText ?: string | null ;
447- fallbackResultText ?: string | null ;
448- } ;
442+ completion ?: Parameters < typeof resolveSubagentCompletionResultText > [ 0 ] [ "completion" ] ;
449443} ;
450444
451445type ChildCompletionSection = {
@@ -454,21 +448,12 @@ type ChildCompletionSection = {
454448 actionable : boolean ;
455449} ;
456450
457- function selectChildCompletionResultText ( child : ChildCompletionRow ) : string | undefined {
458- const primary = child . completion ?. resultText ;
459- const fallback = child . completion ?. fallbackResultText ?? child . frozenResultText ;
460- if ( child . execution . outcome ?. status === "ok" ) {
461- return selectDeliverableSessionsReply ( primary , fallback ) ;
462- }
463- return ( primary ?? fallback ) ?. trim ( ) || undefined ;
464- }
465-
466451function hasCapturedChildCompletionReply ( child : ChildCompletionRow ) : boolean {
467- return [
468- child . completion ?. resultText ,
469- child . completion ?. fallbackResultText ,
470- child . frozenResultText ,
471- ] . some ( ( value ) => Boolean ( value ?. trim ( ) ) ) ;
452+ return Boolean (
453+ child . completion ?. terminalReply ||
454+ child . completion ?. resultText ?. trim ( ) ||
455+ child . completion ?. fallbackResultText ?. trim ( ) ,
456+ ) ;
472457}
473458
474459export function buildChildCompletionFindings (
@@ -496,7 +481,7 @@ export function buildChildCompletionFindings(
496481
497482 const sections : ChildCompletionSection [ ] = [ ] ;
498483 for ( const [ index , child ] of sorted . entries ( ) ) {
499- const resultText = selectChildCompletionResultText ( child ) ;
484+ const resultText = resolveSubagentCompletionResultText ( child ) ;
500485 const outcome = describeSubagentOutcome ( child . execution . outcome ) ;
501486 if (
502487 child . execution . outcome ?. status === "ok" &&
@@ -569,20 +554,12 @@ export function buildChildCompletionFindings(
569554}
570555
571556export function dedupeLatestChildCompletionRows (
572- children : Array < {
573- runId : string ;
574- childSessionKey : string ;
575- task : string ;
576- label ?: string ;
577- generation ?: number ;
578- createdAt : number ;
579- execution : ChildCompletionExecution ;
580- frozenResultText ?: string | null ;
581- completion ?: {
582- resultText ?: string | null ;
583- fallbackResultText ?: string | null ;
584- } ;
585- } > ,
557+ children : Array <
558+ ChildCompletionRow & {
559+ runId : string ;
560+ generation ?: number ;
561+ }
562+ > ,
586563) {
587564 const latestByChildSessionKey = new Map < string , ( typeof children ) [ number ] > ( ) ;
588565 for ( const child of children ) {
@@ -595,21 +572,13 @@ export function dedupeLatestChildCompletionRows(
595572}
596573
597574export function filterCurrentDirectChildCompletionRows (
598- children : Array < {
599- runId : string ;
600- childSessionKey : string ;
601- requesterSessionKey : string ;
602- requesterAgentId ?: string ;
603- task : string ;
604- label ?: string ;
605- createdAt : number ;
606- execution : ChildCompletionExecution ;
607- frozenResultText ?: string | null ;
608- completion ?: {
609- resultText ?: string | null ;
610- fallbackResultText ?: string | null ;
611- } ;
612- } > ,
575+ children : Array <
576+ ChildCompletionRow & {
577+ runId : string ;
578+ requesterSessionKey : string ;
579+ requesterAgentId ?: string ;
580+ }
581+ > ,
613582 params : {
614583 requesterSessionKey : string ;
615584 requesterAgentId ?: string ;
0 commit comments