-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
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 resultingChatAgent.nameisNone. - The
_trace_agent_rundecorator inobservability.pyreadsself.namefor span attributes (agent_name=self.name), which evaluates toNone. - Telemetry spans show
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().- Telemetry spans should correctly reflect the agent name.
Steps to reproduce:
- Create an
AzureAIClientwithagent_nameset. - Call
.as_agent()without passingname=. - Observe that
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
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 toproject_client.agents.create_or_update)ChatAgent.name(fromBaseAgent) — 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="...")Metadata
Metadata
Assignees
Labels
Type
Projects
Status