Description
AzureAIClient.as_agent() does not forward self.agent_name to the ChatAgent it creates. This causes ChatAgent.name to be None even when agent_name was provided to the AzureAIClient constructor, breaking observability/telemetry.
What happened?
- When creating an agent via
AzureAIClient(agent_name="my_agent").as_agent(...), the resulting ChatAgent.name is None.
- The
_trace_agent_run decorator in observability.py reads self.name for span attributes (agent_name=self.name), which evaluates to None.
- Telemetry spans show
agent_name=None instead of the actual agent name.
What did you expect to happen?
ChatAgent.name should default to self.agent_name when name is not explicitly passed to as_agent().
- Telemetry spans should correctly reflect the agent name.
Steps to reproduce:
- Create an
AzureAIClient with agent_name set.
- Call
.as_agent() without passing name=.
- Observe that
ChatAgent.name is None.
Code Sample
from agent_framework_azure_ai import AzureAIClient
client = AzureAIClient(
credential=credential,
agent_name="my_agent", # agent_name is set here
model_deployment_name="gpt-4",
)
agent = client.as_agent(
instructions="You are helpful.",
)
print(agent.name) # None — expected: "my_agent"
**Root cause in `agent_framework_azure_ai/_client.py`:**
# AzureAIClient.__init__ stores agent_name:
self.agent_name = agent_name # e.g. "my_agent"
# But as_agent() does NOT use it as a default:
def as_agent(self, *, name: str | None = None, ...):
return super().as_agent(name=name, ...) # name stays None
Error Messages / Stack Traces
No error is raised — the issue is silent. `ChatAgent.name` is simply `None`, causing telemetry spans in `_trace_agent_run` (observability.py) to record `agent_name=<agent_uuid>`.
Package Versions
agent-framework: 1.0.0b260130, agent-framework-azure-ai: 1.0.0b260130, agent-framework-core: 1.0.0b260130
Python Version
Python 3.10
Additional Context
The AzureAIClient has two separate name concepts that are not bridged:
self.agent_name — used for server-side Azure AI agent creation (passed to project_client.agents.create_or_update)
ChatAgent.name (from BaseAgent) — used for OpenTelemetry observability via _trace_agent_run
as_agent() creates the ChatAgent but never connects these two. The _update_agent_name_and_description method only copies ChatAgent.name → AzureAIClient.agent_name (not the other direction), and since ChatAgent.name is None, the condition if agent_name is False, so nothing happens.
Current workaround: Explicitly pass name= to as_agent():
agent = client.as_agent(name="my_agent", instructions="...")
Description
AzureAIClient.as_agent()does not forwardself.agent_nameto theChatAgentit creates. This causesChatAgent.nameto beNoneeven whenagent_namewas provided to theAzureAIClientconstructor, breaking observability/telemetry.What happened?
AzureAIClient(agent_name="my_agent").as_agent(...), the resultingChatAgent.nameisNone._trace_agent_rundecorator inobservability.pyreadsself.namefor span attributes (agent_name=self.name), which evaluates toNone.agent_name=Noneinstead of the actual agent name.What did you expect to happen?
ChatAgent.nameshould default toself.agent_namewhennameis not explicitly passed toas_agent().Steps to reproduce:
AzureAIClientwithagent_nameset..as_agent()without passingname=.ChatAgent.nameisNone.Code Sample
from agent_framework_azure_ai import AzureAIClient client = AzureAIClient( credential=credential, agent_name="my_agent", # agent_name is set here model_deployment_name="gpt-4", ) agent = client.as_agent( instructions="You are helpful.", ) print(agent.name) # None — expected: "my_agent" **Root cause in `agent_framework_azure_ai/_client.py`:** # AzureAIClient.__init__ stores agent_name: self.agent_name = agent_name # e.g. "my_agent" # But as_agent() does NOT use it as a default: def as_agent(self, *, name: str | None = None, ...): return super().as_agent(name=name, ...) # name stays NoneError Messages / Stack Traces
Package Versions
agent-framework: 1.0.0b260130, agent-framework-azure-ai: 1.0.0b260130, agent-framework-core: 1.0.0b260130
Python Version
Python 3.10
Additional Context
The
AzureAIClienthas two separate name concepts that are not bridged:self.agent_name— used for server-side Azure AI agent creation (passed toproject_client.agents.create_or_update)ChatAgent.name(fromBaseAgent) — used for OpenTelemetry observability via_trace_agent_runas_agent()creates theChatAgentbut never connects these two. The_update_agent_name_and_descriptionmethod only copiesChatAgent.name→AzureAIClient.agent_name(not the other direction), and sinceChatAgent.nameisNone, the conditionif agent_nameisFalse, so nothing happens.Current workaround: Explicitly pass
name=toas_agent():