Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class ScopeUtils {
agentId: recipient.agenticAppId,
agentName: recipient.name,
agentAUID: recipient.aadObjectId,
agentDescription: recipient.role,
agentType: recipient.role,
tenantId: recipient.tenantId
} as AgentDetails;
}
Expand All @@ -77,7 +77,7 @@ export class ScopeUtils {
agentBlueprintId: from.agenticAppBlueprintId,
agentName: from.name,
agentAUID: from.aadObjectId,
agentDescription: from.role,
agentType: from.role,
Comment thread
fpfp100 marked this conversation as resolved.
Outdated
tenantId: from.tenantId,
agentId: from.agenticAppId
} as AgentDetails;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ export function getTargetAgentBaggagePairs(turnContext: TurnContext): Array<[str
const agentId = recipient.agenticAppId;
const agentName = recipient.name;
const aadObjectId = recipient.aadObjectId;
const agentDescription = recipient.role;
const agentType = recipient.role;
const pairs: Array<[string, string | undefined]> = [
[OpenTelemetryConstants.GEN_AI_AGENT_ID_KEY, agentId],
[OpenTelemetryConstants.GEN_AI_AGENT_NAME_KEY, agentName],
[OpenTelemetryConstants.GEN_AI_AGENT_TYPE_KEY, agentType],
Comment thread
fpfp100 marked this conversation as resolved.
Outdated
[OpenTelemetryConstants.GEN_AI_AGENT_AUID_KEY, aadObjectId],
[OpenTelemetryConstants.GEN_AI_AGENT_DESCRIPTION_KEY, agentDescription]
];
return normalizePairs(pairs);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export class OpenTelemetryConstants {

public static readonly GEN_AI_AGENT_ID_KEY = 'gen_ai.agent.id';
public static readonly GEN_AI_AGENT_NAME_KEY = 'gen_ai.agent.name';
public static readonly GEN_AI_AGENT_TYPE_KEY = 'gen_ai.agent.type';
Comment thread
fpfp100 marked this conversation as resolved.
public static readonly GEN_AI_AGENT_DESCRIPTION_KEY = 'gen_ai.agent.description';
public static readonly GEN_AI_AGENT_PLATFORM_ID_KEY = 'gen_ai.agent.platformid';
public static readonly GEN_AI_CONVERSATION_ID_KEY = 'gen_ai.conversation.id';
Expand Down
3 changes: 3 additions & 0 deletions packages/agents-a365-observability/src/tracing/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ export interface AgentDetails {
/** The human-readable name of the AI agent */
agentName?: string;

/** Optional type of the AI agent */
agentType?: string;

/** A description of the AI agent's purpose or capabilities */
agentDescription?: string;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,16 @@ export class BaggageBuilder {
return this;
}

/**
* Set the agent type baggage value.
* @param value The agent type
* @returns Self for method chaining
*/
agentType(value: string | null | undefined): BaggageBuilder {
this.set(OpenTelemetryConstants.GEN_AI_AGENT_TYPE_KEY, value);
return this;
}

/**
* Set the agent description baggage value.
* @param value The agent description
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const GENERIC_ATTRIBUTES: readonly string[] = [
consts.GEN_AI_OPERATION_NAME_KEY,
consts.GEN_AI_AGENT_ID_KEY,
consts.GEN_AI_AGENT_NAME_KEY,
consts.GEN_AI_AGENT_TYPE_KEY,
consts.GEN_AI_AGENT_DESCRIPTION_KEY,
consts.SESSION_DESCRIPTION_KEY,
consts.GEN_AI_AGENT_USER_ID_KEY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export abstract class OpenTelemetryScope implements Disposable {
if (agentDetails) {
this.setTagMaybe(OpenTelemetryConstants.GEN_AI_AGENT_ID_KEY, agentDetails.agentId);
this.setTagMaybe(OpenTelemetryConstants.GEN_AI_AGENT_NAME_KEY, agentDetails.agentName);
this.setTagMaybe(OpenTelemetryConstants.GEN_AI_AGENT_TYPE_KEY, agentDetails.agentType);
this.setTagMaybe(OpenTelemetryConstants.GEN_AI_AGENT_DESCRIPTION_KEY, agentDetails.agentDescription);
this.setTagMaybe(OpenTelemetryConstants.GEN_AI_AGENT_PLATFORM_ID_KEY, agentDetails.platformId);
this.setTagMaybe(OpenTelemetryConstants.GEN_AI_CONVERSATION_ID_KEY, agentDetails.conversationId);
Expand Down
12 changes: 12 additions & 0 deletions tests/observability/core/BaggageBuilder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ describe('BaggageBuilder', () => {
.agentId('agent-456')
.correlationId('corr-789')
.agentName('TestAgent')
.agentType('assistant')
.agentPlatformId('platform-xyz-123')
.conversationId('conv-001');

Expand All @@ -57,6 +58,17 @@ describe('BaggageBuilder', () => {
expect(bag?.getEntry(OpenTelemetryConstants.GEN_AI_AGENT_PLATFORM_ID_KEY)?.value).toBe('platform-abc-456');
});

it('should set agent type', () => {
const builder = new BaggageBuilder();
builder.agentType('assistant');

const scope = builder.build();
expect(scope).toBeInstanceOf(BaggageScope);

const bag = propagation.getBaggage((scope as any).contextWithBaggage);
expect(bag?.getEntry(OpenTelemetryConstants.GEN_AI_AGENT_TYPE_KEY)?.value).toBe('assistant');
});

it('should set caller agent platform ID via fluent API', () => {
const builder = new BaggageBuilder();
builder.callerAgentPlatformId('caller-platform-xyz');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ describe('BaggageBuilderUtils', () => {
expect(asObj[OpenTelemetryConstants.GEN_AI_CALLER_TENANT_ID_KEY]).toBe('tenant1');
expect(asObj[OpenTelemetryConstants.GEN_AI_AGENT_ID_KEY]).toBe('agent-app-1');
expect(asObj[OpenTelemetryConstants.GEN_AI_AGENT_NAME_KEY]).toBe('Agent One');
expect(asObj[OpenTelemetryConstants.GEN_AI_AGENT_TYPE_KEY]).toBe('agent');
expect(asObj[OpenTelemetryConstants.GEN_AI_AGENT_AUID_KEY]).toBe('aad-object-2');
expect(asObj[OpenTelemetryConstants.GEN_AI_AGENT_BLUEPRINT_ID_KEY]).toBe('blueprint-123');
expect(asObj[OpenTelemetryConstants.GEN_AI_AGENT_UPN_KEY]).toBe(undefined);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ describe('TurnContextUtils', () => {
const obj = Object.fromEntries(pairs);
expect(obj[OpenTelemetryConstants.GEN_AI_AGENT_ID_KEY]).toBe('agent-app-1');
expect(obj[OpenTelemetryConstants.GEN_AI_AGENT_NAME_KEY]).toBe('Agent One');
expect(obj[OpenTelemetryConstants.GEN_AI_AGENT_TYPE_KEY]).toBe('agenticUser');
expect(obj[OpenTelemetryConstants.GEN_AI_AGENT_AUID_KEY]).toBe('aad-object-1');
expect(obj[OpenTelemetryConstants.GEN_AI_AGENT_BLUEPRINT_ID_KEY]).toBe(undefined);
});
Expand Down
10 changes: 5 additions & 5 deletions tests/observability/extension/hosting/scope-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('ScopeUtils.populateFromTurnContext', () => {
[OpenTelemetryConstants.GEN_AI_AGENT_NAME_KEY, 'Agent One'],
[OpenTelemetryConstants.GEN_AI_AGENT_AUID_KEY, 'agent-oid'],
[OpenTelemetryConstants.GEN_AI_AGENT_ID_KEY, 'agent-1'],
[OpenTelemetryConstants.GEN_AI_AGENT_DESCRIPTION_KEY, 'assistant'],
[OpenTelemetryConstants.GEN_AI_AGENT_TYPE_KEY, 'assistant'],
[OpenTelemetryConstants.TENANT_ID_KEY, 'tenant-123'],
[OpenTelemetryConstants.GEN_AI_INPUT_MESSAGES_KEY, 'input text']
])
Expand Down Expand Up @@ -138,7 +138,7 @@ describe('ScopeUtils.populateFromTurnContext', () => {
[OpenTelemetryConstants.GEN_AI_INPUT_MESSAGES_KEY, 'invoke message'],
[OpenTelemetryConstants.GEN_AI_AGENT_ID_KEY, 'agent-1'],
[OpenTelemetryConstants.GEN_AI_AGENT_NAME_KEY, 'Agent One'],
[OpenTelemetryConstants.GEN_AI_AGENT_DESCRIPTION_KEY, 'assistant']
[OpenTelemetryConstants.GEN_AI_AGENT_TYPE_KEY, 'assistant']
])
);
scope?.dispose();
Expand All @@ -158,7 +158,7 @@ describe('ScopeUtils.populateFromTurnContext', () => {
[OpenTelemetryConstants.GEN_AI_AGENT_AUID_KEY, 'agent-oid'],
[OpenTelemetryConstants.GEN_AI_AGENT_NAME_KEY, 'Agent One'],
[OpenTelemetryConstants.GEN_AI_AGENT_ID_KEY, 'agent-1'],
[OpenTelemetryConstants.GEN_AI_AGENT_DESCRIPTION_KEY, 'assistant'],
[OpenTelemetryConstants.GEN_AI_AGENT_TYPE_KEY, 'assistant'],
[OpenTelemetryConstants.TENANT_ID_KEY, 'tenant-123']
])
);
Expand Down Expand Up @@ -186,8 +186,8 @@ test('deriveAgentDetails maps recipient fields to AgentDetails', () => {
expect(ScopeUtils.deriveAgentDetails(ctx)).toEqual({
agentId: 'aid',
agentName: 'A',
agentType: 'bot',
agentAUID: 'auid',
agentDescription: 'bot',
tenantId: 't1',
});
});
Expand All @@ -203,7 +203,7 @@ test('deriveCallerAgent maps from fields to caller AgentDetails', () => {
agentBlueprintId: 'bp',
agentName: 'Caller',
agentAUID: 'uid',
agentDescription: 'agent',
agentType: 'agent',
tenantId: 't2',
agentId: 'agent-caller',
});
Expand Down