Skip to content

ACP: populate PromptResponse.usage and send UsageUpdate with cost #24280

Closed

Description

@simonrosenberg

Problem

When running Gemini CLI as an ACP server (gemini --acp), token usage and cost data are reported differently from other ACP implementations (Claude Agent ACP, Codex ACP), making it harder for ACP clients to track usage consistently.

Current behavior

Token usage is returned in PromptResponse._meta.quota.token_count:

{
  "stopReason": "end_turn",
  "_meta": {
    "quota": {
      "token_count": { "input_tokens": 1234, "output_tokens": 567 },
      "model_usage": [...]
    }
  }
}

Cost is not reported anywhere.

Expected behavior (per ACP protocol)

Token usage in PromptResponse.usage (standard ACP field):

{
  "stopReason": "end_turn",
  "usage": {
    "input_tokens": 1234,
    "output_tokens": 567,
    "total_tokens": 1801
  }
}

Cost via UsageUpdate session notification:

{
  "sessionUpdate": "usage_update",
  "cost": { "amount": 0.0023, "currency": "USD" },
  "size": 1048576,
  "used": 1801
}

Why this matters

ACP clients (Zed, OpenHands, etc.) use PromptResponse.usage and UsageUpdate.cost to track token consumption and spending. Without these standard fields, each client needs Gemini-specific fallback logic to parse _meta.quota.

Claude Agent ACP and Codex ACP both populate these standard fields. Aligning Gemini CLI would make it a drop-in replacement in any ACP client.

Reference

  • ACP protocol schema: PromptResponse.usage (Usage type)
  • ACP protocol schema: UsageUpdate.cost (Cost type)
  • Claude Agent ACP implementation: sends both usage in PromptResponse and cost in UsageUpdate (source)

Activity

  1. added
    status/need-triageIssues that need to be triaged by the triage automation.
    area/non-interactiveIssues related to GitHub Actions, SDK, 3P Integrations, Shell Scripting, Command line automation
    on Mar 30, 2026
  2. gemini-cli commented on Mar 30, 2026

    @gemini-cli
    Contributor

    Found possible duplicate issues:

    If you believe this is not a duplicate, please remove the status/possible-duplicate label.

  3. simonrosenberg commented on Mar 30, 2026

    @simonrosenberg
    Author

    This is related to #19249 but proposes a different (and more standard) approach:

    • feat: emit token usage metadata via ACP extNotification in zed-integration #19249 proposes a custom extNotification for token usage — this would work for Zed but requires every ACP client to handle a Gemini-specific notification type.
    • This issue asks for the standard ACP protocol fields that Claude Agent ACP and Codex ACP already populate: PromptResponse.usage and UsageUpdate with cost. Any ACP client that works with Claude/Codex would automatically work with Gemini CLI too, with no Gemini-specific code needed.

    Both could coexist (the extNotification as a bonus for clients that want real-time updates), but populating PromptResponse.usage is the baseline that ensures interoperability across all ACP clients.

  4. Adib234 commented on May 8, 2026

    @Adib234
    Contributor

    Thank you for bringing this to our attention. Right now, our engineering team is focusing all resources on critical system maintenance and core stability. Because of this, we don't have immediate plans to address this specific issue, but we truly appreciate you flagging it for us.

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/non-interactiveIssues related to GitHub Actions, SDK, 3P Integrations, Shell Scripting, Command line automationstatus/need-triageIssues that need to be triaged by the triage automation.status/possible-duplicatetype/feature

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions