Skip to content

fix(a2a): show A2A task usage through the usage extension - #1529

Merged
edenreich merged 2 commits into
mainfrom
fix/a2a-unreported-usage
Oct 4, 2026
Merged

edenreich merged 2 commits into
mainfrom
fix/a2a-unreported-usage

Conversation

@edenreich

@edenreich edenreich commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A2A tasks always showed 0 tokens. The ADK dropped the streamed usage, and the CLI rendered missing usage as zero. Both sides are fixed now: the ADK side shipped in ADK v0.33.0 (inference-gateway/adk#397) and this PR is the CLI side.

Activate the usage extension and read its keys

ADK 0.33.0 moved task usage behind the A2A usage extension. Its metadata keys are namespaced by the URI, and an agent only returns them to a request that lists the extension in the A2A-Extensions header.

  • Bumps adk to v0.33.0.
  • Sets A2A-Extensions: adk.UsageExtensionURI in the single client factory (infrastructure/client.go), so every request activates the extension.
  • Reads adk.UsageMetadataKey / adk.ExecutionStatsMetadataKey in taskRunStats (subagent stats) and appendTaskMetadataLines (task result lines).
  • Updates docs/a2a-connections.md and examples/a2a/README.md. The example README showed an old tree-style block, so it now shows the current child line.

Hide token figures when an agent reports no usage

Zero tokens now means "not reported". The subagent list, the task view and the stats line the parent agent reads all drop the token figures instead of claiming 0.

Breaking

Agents on ADK < 0.33.0 no longer show tool counts or tokens, since they only write the old bare keys. Older agents never returned streamed usage anyway.

Test plan

  • TestNewClient_ActivatesUsageExtension checks that a request from the client factory carries A2A-Extensions: <URI>.
  • job_test.go / submit_task_test.go read the namespaced keys.
  • TestA2AJobStatsWithoutUsage checks that execution stats without usage give Tools: 1 succeeded, 0 failed, with no token part. It fails without the fix.
  • TestSubagentListStatsIconsDimAtZero expects no token segment for zero-token stats.
  • go test ./internal/... ./config/... ./cmd/... and task precommit:run are clean.
  • End to end, mock-agent built against the ADK fix returns the namespaced usage (200 / 100 / 300 over two LLM calls) only when the header is sent. The card declares the extension, and the response echoes the header. With fix(mock): end streams with an include_usage chunk mock-agent#167, the mock also streams the usage chunk.

Refs #1526

Go ADK agents put execution_stats but no usage in the task metadata,
so every A2A row claimed 0 tokens in the subagent list, the task view
and the stats line the parent agent reads. Zero tokens now means
unreported, and all three drop the token figures instead.

The missing usage itself is fixed upstream in the ADK and mock-agent.

Refs #1526
@edenreich
edenreich requested a review from a team as a code owner October 4, 2026 17:14
@edenreich edenreich changed the title fix(a2a): hide token figures when an agent reports no usage fix(a2a): show A2A task usage through the usage extension Oct 4, 2026
ADK 0.33.0 moved task usage behind the A2A usage extension: namespaced
metadata keys that an agent only returns to a request listing the
extension in the A2A-Extensions header. Bump the ADK, send the header
from the client factory so every request activates it, and read the
new keys for the subagent stats and the task result lines.

Refs #1526
@edenreich
edenreich force-pushed the fix/a2a-unreported-usage branch from 70dc344 to 7b2a644 Compare October 4, 2026 17:56
@edenreich
edenreich merged commit 0cd1439 into main Oct 4, 2026
1 check passed
@edenreich
edenreich deleted the fix/a2a-unreported-usage branch October 4, 2026 18:44
@edenreich edenreich moved this from In progress to Done in 2026 Oct 4, 2026
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.225.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Oct 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant