agentSideEffects.ts ×9

Frontier kind: Code frontier

unlabeled · c_d6dba1470b07

25 tests · 50000 LOC · 290 files · introduces 0 tests · 68 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
9 ranges68 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
5153 ranges50000 lines · 290 files · Browse complete extent
All tests (intent)
25 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 68 introduced LOC across 9 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/agentSideEffects.ts 68 introduced LOC · 9 ranges

Open complete file

536 private _handleAgentSignal(agent: IAgent, signal: AgentSignal): void {
537 if (signal.kind === 'subagent_started') {
538 > this._handleSubagentStarted(signal.chat.toString(), signal.toolCallId, signal.agentName, signal.agentDisplayName, signal.agentDescription, signal.taskPrompt, signal.parentToolCallId); agentSideEffects.ts
539 > this._drainPendingSubagentSignals(signal.chat.toString(), signal.toolCallId);
540 > return;
541 > }
542
543 if (signal.kind === 'subagent_completed') {
821 */
822 private _drainPendingSubagentSignals(parentChatURI: ProtocolURI, parentToolCallId: string): void {
823 > const buffer = this._pendingSubagentSignals.get(parentChatURI, parentToolCallId); agentSideEffects.ts
824 > if (!buffer) {
825 return;
826 }
830 this._handleAgentSignal(agent, signal);
831 }
833
834 // ---- Subagent session management ----------------------------------------
852 */
853 private _handleSubagentStarted(
854 > chatURI: ProtocolURI, agentSideEffects.ts
855 > toolCallId: string,
856 > agentName: string,
857 > agentDisplayName: string,
858 > agentDescription?: string,
859 > taskPrompt?: string,
860 > spawningToolParentId?: string,
861 > ): void {
862 > const parentSessionUri = parseRequiredSessionUriFromChatUri(chatURI);
863 > const subagentChatUri = buildSubagentChatUri(parentSessionUri, toolCallId);
864 >
865 > // Already tracking this subagent
866 > if (this._subagentChats.get(chatURI, toolCallId)) {
867 return;
868 }
870 > this._logService.info(`[AgentSideEffects] Starting subagent turn: ${subagentChatUri} (parent=${chatURI}, toolCallId=${toolCallId})`);
871 >
872 > // The spawning tool call lives in the immediate parent chat (top-level, or the parent subagent chat when nested).
873 > const contentChatUri = spawningToolParentId
874 ? this._subagentChats.get(chatURI, spawningToolParentId)?.chatUri ?? chatURI
875 > : chatURI; agentSideEffects.ts
876 >
877 > // Seed the subagent's opening request with the delegated task prompt,
878 > // supplied by the provider on the `subagent_started` signal.
879 > const turnId = generateUuid();
880 > this._stateManager.dispatchServerAction(subagentChatUri, {
881 > type: ActionType.ChatTurnStarted,
882 > turnId,
883 > startedAt: new Date().toISOString(),
884 > message: { text: taskPrompt ?? '', origin: { kind: MessageKind.User } },
885 > });
886 >
887 > this._subagentChats.set({ parentChatUri: chatURI, toolCallId, sessionUri: parentSessionUri, chatUri: subagentChatUri, turnStopWatch: StopWatch.create(false) }, chatURI, toolCallId);
888 >
889 > // Dispatch the discovery content on the spawning tool call's own chat; the top-level chat is a no-op when nested.
890 > const parentTurnId = this._stateManager.getActiveTurnId(contentChatUri);
891 > if (parentTurnId) {
892 > const parentState = this._stateManager.getSessionState(contentChatUri);
893 > const existingContent = this._getRunningToolCallContent(parentState, parentTurnId, toolCallId);
894 > this._stateManager.dispatchServerAction(contentChatUri, {
895 > type: ActionType.ChatToolCallContentChanged,
896 > turnId: parentTurnId,
897 > toolCallId,
898 > content: [
899 > ...existingContent,
900 > {
901 > type: ToolResultContentType.Subagent,
902 > resource: subagentChatUri,
903 > title: agentDisplayName,
904 > agentName,
905 > description: agentDescription,
906 > },
907 > ],
908 > });
909 > }
910 > }
911
912 /**
914 */
915 private _getRunningToolCallContent(
916 > state: ISessionWithDefaultChat | undefined, agentSideEffects.ts
917 > turnId: string,
918 > toolCallId: string,
919 > ): ToolResultContent[] {
920 > if (!state?.activeTurn || state.activeTurn.id !== turnId) {
921 return [];
922 }
923 > for (const rp of state.activeTurn.responseParts) { agentSideEffects.ts
924 if (rp.kind === ResponsePartKind.ToolCall && rp.toolCall.toolCallId === toolCallId && rp.toolCall.status === ToolCallStatus.Running) {
925 return rp.toolCall.content ? [...rp.toolCall.content] : [];
927 }
928 return [];
930
931 private _turnDuration(stopWatch: StopWatch | undefined): number {