diff --git a/extensions/copilot/src/extension/intents/node/toolCallingLoop.ts b/extensions/copilot/src/extension/intents/node/toolCallingLoop.ts index 743641d6f9a..03e30a22219 100644 --- a/extensions/copilot/src/extension/intents/node/toolCallingLoop.ts +++ b/extensions/copilot/src/extension/intents/node/toolCallingLoop.ts @@ -196,6 +196,11 @@ export abstract class ToolCallingLoop { - const agentName = (this.options.request as { subAgentName?: string }).subAgentName - ?? (this.options.request as { participant?: string }).participant - ?? 'GitHub Copilot Chat'; + const agentName = this.agentName ?? 'GitHub Copilot Chat'; // Extract custom mode name for debug logging (kept separate from agentName to avoid metric cardinality) const modeInstructions = (this.options.request as { modeInstructions2?: { name?: string; isBuiltin?: boolean } }).modeInstructions2; diff --git a/extensions/copilot/src/extension/intents/test/node/toolCallingLoopHooks.spec.ts b/extensions/copilot/src/extension/intents/test/node/toolCallingLoopHooks.spec.ts index e6e2e61380c..b48e339fa67 100644 --- a/extensions/copilot/src/extension/intents/test/node/toolCallingLoopHooks.spec.ts +++ b/extensions/copilot/src/extension/intents/test/node/toolCallingLoopHooks.spec.ts @@ -197,7 +197,10 @@ describe('ToolCallingLoop SessionStart hook', () => { describe('SessionStart hook execution conditions', () => { it('should execute SessionStart hook on the first turn of regular sessions', async () => { const conversation = createTestConversation(1); // First turn - const request = createMockChatRequest(); + const request = createMockChatRequest({ + model: { id: 'test-model-id' } as ChatRequest['model'], + participant: 'test-agent', + } as unknown as Partial); const loop = instantiationService.createInstance( TestToolCallingLoop, @@ -216,7 +219,12 @@ describe('ToolCallingLoop SessionStart hook', () => { const sessionStartCalls = mockChatHookService.getCallsForHook('SessionStart'); expect(sessionStartCalls).toHaveLength(1); - expect((sessionStartCalls[0].input as SessionStartHookInput).source).toBe('new'); + const input = sessionStartCalls[0].input as SessionStartHookInput; + expect(input).toMatchObject({ + source: 'new', + model: 'test-model-id', + agent_type: 'test-agent', + }); }); it('should NOT execute SessionStart hook on subsequent turns', async () => { diff --git a/extensions/copilot/src/platform/chat/common/chatHookService.ts b/extensions/copilot/src/platform/chat/common/chatHookService.ts index edd6faa727d..db1b2db2432 100644 --- a/extensions/copilot/src/platform/chat/common/chatHookService.ts +++ b/extensions/copilot/src/platform/chat/common/chatHookService.ts @@ -172,6 +172,14 @@ export interface SessionStartHookInput { * The source of the session start. Always "new". */ readonly source: 'new'; + /** + * The model identifier (e.g. "claude-sonnet-4-6"). + */ + readonly model: string; + /** + * The agent or mode name, if applicable. + */ + readonly agent_type?: string; } /**