Skip to content

Python: [Bug]: ClaudeAgent missing telemetry - inherits from BaseAgent instead of Agent #4278

@amitmukh

Description

@amitmukh

Description

ClaudeAgent inherits directly from BaseAgent, bypassing AgentTelemetryLayer, AgentMiddlewareLayer, and RawAgent. As a result, enable_instrumentation() has no effect on ClaudeAgent — no OpenTelemetry spans are emitted when calling agent.run(), and agents are invisible in Azure Application Insights Agents (Preview) view.

Code Sample

from agent_framework_claude import ClaudeAgent
from agent_framework import Agent

# Check 1: issubclass is False
print(issubclass(ClaudeAgent, Agent))  # False ← should be True

# Check 2: Compare MRO chains
print([c.__name__ for c in ClaudeAgent.__mro__])
# ['ClaudeAgent', 'BaseAgent', 'SerializationMixin', 'Generic', 'object']

print([c.__name__ for c in Agent.__mro__])
# ['Agent', 'AgentTelemetryLayer', 'AgentMiddlewareLayer', 'RawAgent', 'BaseAgent', 'SerializationMixin', 'Generic', 'object']

Error Messages / Stack Traces

Package Versions

Package: agent-framework-claude v1.0.0b260212 Dependency: agent-framework-core v1.0.0b260212 Python: 3.12.10 (Windows ARM64)

Python Version

No response

Additional Context

Missing Layers
ClaudeAgent is missing 4 layers that Agent includes:

AgentTelemetryLayer — emits gen_ai.invoke_agent spans, token/duration histograms
AgentMiddlewareLayer — middleware pipeline support
RawAgent — raw agent contract
Agent — the complete agent class

Expected Behavior:
ClaudeAgent should inherit from Agent (not BaseAgent), so that:

  1. enable_instrumentation() automatically wraps ClaudeAgent.run() with telemetry
  2. gen_ai.invoke_agent spans are emitted with gen_ai.agent.id and gen_ai.agent.name attributes
  3. Agents appear in Azure Application Insights Agents (Preview) view
  4. Token usage histograms and duration metrics are recorded

Actual Behavior:
enable_instrumentation() has no effect on ClaudeAgent
No gen_ai.* spans are emitted for ClaudeAgent invocations
Agents are invisible in App Insights Agents (Preview) view
Only custom spans manually created via get_tracer() appear

Impact
Any application using agent-framework-claude with Azure Application Insights observability (Option 3: Third party setup with configure_azure_monitor() + enable_instrumentation()) cannot see Claude agents in the Agents (Preview) monitoring view.

Suggested Fix
In agent_framework_claude/_agent.py, change:

class ClaudeAgent(BaseAgent): # ← current

to:

class ClaudeAgent(Agent): # ← fix (or at minimum RawAgent)

This aligns ClaudeAgent with how other agent implementations (e.g., OpenAI-based) inherit from the full Agent class.

Metadata

Metadata

Assignees

Labels

agentsIssues related to single agentsbugSomething isn't workingpythonv1.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