Skip to content

.NET: [Bug]: recommended gen_ai attributes not populated at agent span creation time #4486

@zakimaksyutov

Description

@zakimaksyutov

Description

Description

According to https://github.com/open-telemetry/semantic-conventions/blob/main/docs/gen-ai/gen-ai-agent-spans.md the expectation is that gen_ai.operation.name should be populated at agent span creation time.

Current behavior

This is needed to be able to provide SpanProcessor to do special propagation logic of main agent name (to be stamped on all outgoing telemetry). But in OnStart there are no tags:

--- [OnStart] chat gpt-4.1 (DisplayName=chat gpt-4.1) ---
Source : CmdAgent.Agent
Kind : Client
Parent : (none)
Duration : 00:00:00
Tags:
(none)
--- /OnStart ---

They appear only in OnEnd:

--- [OnEnd] chat gpt-4.1 (DisplayName=invoke_agent CmdAgent(76633d34ff8b4a40a779f1b3f08c0879)) ---
Source : CmdAgent.Agent
Kind : Client
Parent : (none)
Duration : 00:00:06.0745008
Tags:
gen_ai.operation.name = invoke_agent
gen_ai.request.model = gpt-4.1
gen_ai.provider.name = openai
server.address = zakima-cmd-agent-resource.openai.azure.com
gen_ai.input.messages =
gen_ai.agent.id =
gen_ai.agent.name = CmdAgent
gen_ai.output.messages =
gen_ai.response.finish_reasons = ["stop"]
gen_ai.response.id =
gen_ai.response.model = gpt-4.1-2025-04-14
--- /OnEnd ---

Expected behavior

--- [OnStart] chat gpt-4.1 (DisplayName=chat gpt-4.1) ---
Source : CmdAgent.Agent
Kind : Client
Parent : (none)
Duration : 00:00:00
Tags:
gen_ai.operation.name = invoke_agent
gen_ai.request.model = gpt-4.1
gen_ai.provider.name = openai
--- /OnStart ---

Code Sample

Error Messages / Stack Traces

Package Versions

Microsoft.Agents.AI.OpenAI:1.0.0-preview.260128.1, Microsoft.Extensions.AI.OpenAI:10.2.0-preview.1.26063.2, Azure.AI.OpenAI:2.8.0-beta.1, Azure.AI.Projects:1.2.0-beta.5, Azure.AI.Projects.OpenAI:1.0.0-beta.5

.NET Version

.NET 8.0

Additional Context

No response

Metadata

Metadata

Assignees

Labels

.NETbugSomething isn't workingv1.0Features being tracked for the version 1.0 GA

Type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions