Skip to content

OTel: root invoke_agent nano_aiu and token totals exclude subagents, so the documented way to measure AI credits undercounts #5650

Backlog

Description

@sebdanielsson

Describe the bug

The OpenTelemetry reference says:

To measure AI unit consumption, read github.copilot.nano_aiu from the root invoke_agent span only. The attribute is also stamped on the child chat spans, so summing it across every span double-counts.

The root invoke_agent span's github.copilot.nano_aiu covers only the main agent's own chat spans. Subagent usage isn't included. Since #4224 was fixed, that usage is on the subagents' own nested invoke_agent spans and their chat spans. Following the docs therefore undercounts AI credits in every session that uses subagents.

Summing github.copilot.nano_aiu over all chat spans matches /usage exactly, and so does summing it over all invoke_agent spans, root and subagents.

The root's token totals have the same gap. gen_ai.usage.input_tokens and gen_ai.usage.output_tokens are documented as "Total input/output tokens (all turns)", but they leave out the subagents' tokens.

One Copilot CLI session: a claude-sonnet-5.5 session started two background subagents in parallel, one on gpt-6-luna and one on claude-haiku-5.5.

Source AI credits Input tokens
/usage 11.88 (Sonnet 11.26, Haiku 0.38, Luna 0.24) 276.4k
Root invoke_agent spans (two turns) 11.257 176,020 (Sonnet only)
All chat spans 11.879 276,373
All invoke_agent spans (roots + subagents) 11.879 276,373

We saw the same thing on two other clients that use the same runtime. In each case the root's nano_aiu equals the sum of the main agent's own chat spans exactly, and every subagent is left out:

  • Desktop app (runtime 1.0.115-7), two background subagents: root 21.449, all chat spans 22.846.
  • VS Code 1.149 Copilot harness (runtime 1.0.116), one synchronous subagent (gen_ai.transfer.mode=return_to_caller on the task span): root 15.308, all chat spans 15.613.

Affected version

GitHub Copilot CLI 1.0.119. Also seen in runtime 1.0.115-7 (desktop app) and 1.0.116 (VS Code 1.149).

Steps to reproduce the behavior

  1. COPILOT_OTEL_FILE_EXPORTER_PATH=otel.jsonl copilot, then /model and pick claude-sonnet-5.5.
  2. Prompt: Use the task tool to start two background subagents in parallel: one with model gpt-6-luna that creates a.txt with three lines about OpenTelemetry, and one with model claude-haiku-5.5 that creates b.txt with three lines about Grafana.
  3. When both have finished, run /usage and note the AI credits.
  4. Sum github.copilot.nano_aiu / 1e9 in otel.jsonl:
    • over invoke_agent spans with no parent: lower than /usage, missing the subagents.
    • over all chat spans: equal to /usage.

Expected behavior

One of these:

  • The root invoke_agent span's github.copilot.nano_aiu and gen_ai.usage.* include the usage of the subagents it started, as the docs imply.
  • Or the docs say to sum github.copilot.nano_aiu over all invoke_agent spans (root and subagents), or over all chat spans.

Additional context

Activity

  1. added
    area:agents
    and removed on Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:agents

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions