feat(agent-core-v2): report the bound model alias in subagent_created telemetry (#3086)

This commit is contained in:
7Sageer 2026-08-19 17:13:03 +08:00 committed by GitHub
parent 16499408d5
commit 2ea2ef62e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 2 deletions

View file

@ -345,6 +345,7 @@ export interface SubagentCreatedEvent {
agent_id: string;
parent_agent_id: string;
parent_tool_call_id: string;
model?: string;
}
export interface McpConnectedEvent {
@ -848,6 +849,7 @@ export const telemetryEventDefinitions = {
agent_id: 'Child agent id',
parent_agent_id: 'Parent (caller) agent id',
parent_tool_call_id: "Tool call id of the launching call in the parent agent; '' when not launched from a tool call",
model: 'Model alias the subagent binds to (secondary-model choice or inherited caller model); omitted when no binding was resolved',
},
}),
mcp_connected: defineTelemetryEvent<McpConnectedEvent>({

View file

@ -6,6 +6,7 @@ import { IAgentProfileService } from '#/agent/profile/profile';
import { isProviderRateLimitError } from '#/kosong/contract/errors';
import { type TokenUsage } from '#/kosong/contract/usage';
import { ITelemetryService } from '#/app/telemetry/telemetry';
import type { SubagentCreatedEvent } from '#/app/telemetry/events';
import { Event2 } from '#/app/event/event2';
import { isAbortError } from '#/_base/utils/abort';
import { IAgentLifecycleService } from '#/session/agentLifecycle/agentLifecycle';
@ -114,13 +115,15 @@ export function emitAgentRunSpawned(
}),
);
childProfile?.republishStatus();
requester.accessor.get(ITelemetryService)?.track2('subagent_created', {
const telemetryEvent: SubagentCreatedEvent = {
subagent_name: meta.profileName,
run_in_background: meta.runInBackground ?? false,
agent_id: targetAgentId,
parent_agent_id: requester.id,
parent_tool_call_id: meta.parentToolCallId ?? '',
});
model: meta.model,
};
requester.accessor.get(ITelemetryService)?.track2('subagent_created', telemetryEvent);
}
export async function mirrorAgentRun(

View file

@ -1532,6 +1532,7 @@ describe('Agent tool execution contract', () => {
agent_id: 'agent-child',
parent_agent_id: 'main',
parent_tool_call_id: 'call_agent',
model: 'provider/secondary',
},
});
expect(events.find((event) => event.type === 'subagent.completed')).toMatchObject({