@@ -150,7 +150,7 @@ export class CopilotAgentSession extends Disposable {
150150 readonly sessionUri : URI ;
151151
152152 /** Tracks active tool invocations so we can produce past-tense messages on completion. */
153- private readonly _activeToolCalls = new Map < string , { toolName : string ; displayName : string ; parameters : Record < string , unknown > | undefined ; content : ToolResultContent [ ] } > ( ) ;
153+ private readonly _activeToolCalls = new Map < string , { toolName : string ; displayName : string ; parameters : Record < string , unknown > | undefined ; content : ToolResultContent [ ] ; parentToolCallId : string | undefined } > ( ) ;
154154 /** Pending permission requests awaiting a renderer-side decision. */
155155 private readonly _pendingPermissions = new Map < string , DeferredPromise < boolean > > ( ) ;
156156 /** Pending user input requests awaiting a renderer-side answer. */
@@ -206,6 +206,8 @@ export class CopilotAgentSession extends Disposable {
206206 private _currentMarkdownPartId : string | undefined ;
207207 /** Current reasoning response part ID for the active turn. Reset on each new turn. */
208208 private _currentReasoningPartId : string | undefined ;
209+ /** Tracks whether a non-empty activity has been published, so we only emit a clear when needed. */
210+ private _hasReportedActivity = false ;
209211
210212 constructor (
211213 options : ICopilotAgentSessionOptions ,
@@ -612,6 +614,11 @@ export class CopilotAgentSession extends Disposable {
612614
613615 // Fire a pending_confirmation signal to transition the tool to PendingConfirmation
614616 const toolName = request . toolName ?? request . kind ;
617+ // Forward the tool's parentToolCallId (if any) so the host can
618+ // route the resulting SessionToolCallReady to the correct
619+ // subagent session — without it the action would land on the
620+ // parent session, which has no matching SessionToolCallStart.
621+ const parentToolCallId = this . _activeToolCalls . get ( toolCallId ) ?. parentToolCallId ;
615622 this . _onDidSessionProgress . fire ( {
616623 kind : 'pending_confirmation' ,
617624 session : this . sessionUri ,
@@ -627,6 +634,7 @@ export class CopilotAgentSession extends Disposable {
627634 } ,
628635 permissionKind,
629636 permissionPath,
637+ parentToolCallId,
630638 } ) ;
631639
632640 const approved = await deferred . p ;
@@ -992,6 +1000,21 @@ export class CopilotAgentSession extends Disposable {
9921000 this . _register ( wrapper . onToolStart ( e => {
9931001 if ( isHiddenTool ( e . data . toolName ) ) {
9941002 this . _logService . trace ( `[Copilot:${ sessionId } ] Tool started (hidden): ${ e . data . toolName } ` ) ;
1003+ // The CLI uses the `report_intent` tool to signal what the
1004+ // agent is currently doing. Surface this as session activity
1005+ // so the UI can show a live "what is the agent doing now?"
1006+ // hint while the turn is in progress.
1007+ if ( e . data . toolName === 'report_intent' ) {
1008+ const intent = ( e . data . arguments as { intent ?: unknown } | undefined ) ?. intent ;
1009+ if ( typeof intent === 'string' && intent . length > 0 ) {
1010+ this . _hasReportedActivity = true ;
1011+ this . _emitAction ( {
1012+ type : ActionType . SessionActivityChanged ,
1013+ session : this . _protocolSession ( ) ,
1014+ activity : intent ,
1015+ } ) ;
1016+ }
1017+ }
9951018 return ;
9961019 }
9971020 this . _logService . info ( `[Copilot:${ sessionId } ] Tool started: ${ e . data . toolName } ` ) ;
@@ -1007,7 +1030,7 @@ export class CopilotAgentSession extends Disposable {
10071030 toolArgs = tryStringify ( parameters ) ;
10081031 }
10091032 const displayName = getToolDisplayName ( e . data . toolName ) ;
1010- this . _activeToolCalls . set ( e . data . toolCallId , { toolName : e . data . toolName , displayName, parameters, content : [ ] } ) ;
1033+ this . _activeToolCalls . set ( e . data . toolCallId , { toolName : e . data . toolName , displayName, parameters, content : [ ] , parentToolCallId : e . data . parentToolCallId } ) ;
10111034 const toolKind = getToolKind ( e . data . toolName ) ;
10121035 const subagentMeta = toolKind === 'subagent' ? getSubagentMetadata ( parameters ) : undefined ;
10131036 const toolClientId = this . _clientToolNames . has ( e . data . toolName ) ? this . _appliedSnapshot . clientId : undefined ;
@@ -1124,6 +1147,17 @@ export class CopilotAgentSession extends Disposable {
11241147
11251148 this . _register ( wrapper . onIdle ( ( ) => {
11261149 this . _logService . info ( `[Copilot:${ sessionId } ] Session idle` ) ;
1150+ // Clear any in-progress activity description set during the
1151+ // turn (e.g. via the `report_intent` tool) — the agent is no
1152+ // longer doing anything once the turn completes.
1153+ if ( this . _hasReportedActivity ) {
1154+ this . _hasReportedActivity = false ;
1155+ this . _emitAction ( {
1156+ type : ActionType . SessionActivityChanged ,
1157+ session : this . _protocolSession ( ) ,
1158+ activity : undefined ,
1159+ } ) ;
1160+ }
11271161 this . _emitAction ( {
11281162 type : ActionType . SessionTurnComplete ,
11291163 session : this . _protocolSession ( ) ,
0 commit comments