claude-code
claude-code copied to clipboard
[FEATURE] Add subagent_type to OTEL telemetry for Task tool calls
Summary
When using the Task tool to spawn subagents (e.g., Explore, claude-code-guide, Plan, or custom agents), the OTEL telemetry does not capture which agent type was invoked. This makes it impossible to build observability dashboards showing agent usage patterns.
Current Behavior
For tool_result events where tool_name="Task":
-
tool_parametersisnull(unlike Bash which logs command details) - No
subagent_typefield exists in structured metadata
Example current telemetry for Task:
{
"tool_name": "Task",
"tool_parameters": null,
"session_id": "...",
"success": "true",
"duration_ms": "8801"
}
Expected Behavior
Task tool telemetry should include the subagent_type parameter:
{
"tool_name": "Task",
"subagent_type": "Explore",
"tool_parameters": null,
"session_id": "...",
"success": "true",
"duration_ms": "8801"
}
Use Case
Organizations monitoring Claude Code usage want to understand:
- Which subagents are most frequently used (Explore, Plan, custom agents)
- Agent usage distribution per session
- Cost/time attribution by agent type
- Custom vs system agent utilization
Environment
- Claude Code version: 2.0.74
- OTEL exporter: OTLP gRPC to local collector
- Observability stack: OTEL Collector → Prometheus/Loki → Grafana
Additional Context
This gap was discovered while building a local observability POC. The telemetry correctly captures tool_name for all tools, but the subagent_type parameter passed to the Task tool is not emitted as a structured metadata field.