buzz icon indicating copy to clipboard operation
buzz copied to clipboard

feat(acp): report standard adapter usage

Open atishpatel opened this issue 3 months ago • 1 comments

Why

Claude Code and Codex expose standard ACP prompt-response usage, but Buzz only consumed Goose’s private cumulative usage notification. Their token use and Claude’s cumulative cost were therefore absent from NIP-AM metrics.

What

  • Read per-turn session/prompt response usage for known Claude and Codex adapters
  • Publish Claude’s raw cumulative cost separately from per-turn tokens without changing the NIP-AM schema
  • Keep Goose usage exclusive and cover Claude/Codex wire serialization

Risk Assessment

Low-to-medium: changes best-effort observability only and does not affect prompt execution. The adapter-specific mappings preserve source semantics and omit unavailable fields.

References

  • Validated with cargo fmt --check, cargo test -p buzz-acp --no-run, and full cargo test -p buzz-acp (678 passed at 652e373a before merge-trailer amendment).

Generated with Codex

atishpatel avatar Aug 05 '26 20:08 atishpatel

I validated this problem independently while building an owner-side NIP-AM usage projection for a mixed Codex/Claude/Goose fleet. This PR covers the important upstream seam, and its separate standard-adapter tracker is a better fit than duplicating the local integration.

Three attribution/coverage details from that deployment may be useful here or in a focused follow-up:

  1. Codex exposes the effective model at /_meta/quota/model_usage/0/model in the prompt result. Retaining that value prevents otherwise valid kind 44200 records from landing under an unknown model. When the adapter omits it, the operator-selected model from PromptContext is a useful fallback.
  2. Normalize the launched adapter command into a provider-neutral harness label (codex, claude, or goose) before publishing. Absolute paths and wrapper names otherwise fragment the dataset.
  3. Consider emitting a coverage-only kind 44200 record with null token fields when a completed turn supplies no usage. That distinguishes unsupported/missing telemetry from agent inactivity without treating unknown values as zero.

Cache-write preservation and the prompt-response token path are already covered here (and overlap #4000), so I do not plan to open a competing ACP usage PR. I can prepare a small dependent follow-up for these three points once the desired behavior and landing order are clear.

custard-pirate avatar Aug 06 '26 13:08 custard-pirate