Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

Merge remote-tracking branch 'origin/main' into claude/gracious-newton-609b9n-gemini-token-types

Claudea2bea8570a17
diff --cc cli/beacon/internal/tokens/coverage.go
index 5c1ad107,05d15429..eb07946d
--- a/cli/beacon/internal/tokens/coverage.go
+++ b/cli/beacon/internal/tokens/coverage.go
@@@ -84,14 -84,10 +84,14 @@@ var usageExpectation = map[string]struc
"openclaw_gateway": {ExpectReported, "plugin reports usage per model response when conversation access is granted"},
"vercel_fx": {ExpectReported, "session store carries cumulative usage and cost"},
"deepseek_harness": {ExpectReported, "native session backfill reports usage when DeepSeek persists it"},
- "copilot_cli": {ExpectReported, "session store carries output tokens and cumulative model usage"},
+ "copilot_cli": {ExpectReported, "session store carries output tokens, cumulative model usage, and AI-credit cost"},
"asymptote_observe": {ExpectReported, "SDK spans carry semconv usage"},
+ // Read from Gemini CLI's own gemini_cli.api_response log, which it emits for every model
+ // response whenever its telemetry is on -- not from the semconv names -- so a Gemini session
+ // with events and no usage is a fault worth reporting. The record shape is pinned from Gemini
+ // CLI's telemetry source rather than from a recorded session.
+ "gemini_cli": {ExpectReported, "api_response log reports input, cache, thought and tool tokens; Gemini CLI emits no cost"},
- "gemini_cli": {ExpectGenericOTLP, "only if it emits OTel GenAI semconv usage"},
"vscode_copilot": {ExpectGenericOTLP, "only if it emits OTel GenAI semconv usage"},
"factory": {ExpectGenericOTLP, "only if it emits OTel GenAI semconv usage"},
"factory_droid": {ExpectGenericOTLP, "only if it emits OTel GenAI semconv usage"},
diff --cc docs/cli/token-usage.mdx
index 5d64b515,512e3f82..4f0d7369
--- a/docs/cli/token-usage.mdx
+++ b/docs/cli/token-usage.mdx
@@@ -49,15 -49,12 +49,15 @@@ from. A turn with no token attribution
| Prime Agent | input, output, cache read, cache creation, reasoning | Reported (`cost_usd`) | Yes | Yes |
| DeepSeek Harness | input, output, cache read, cache creation | Not reported | Yes, from committed session records | Yes |
| fx (Vercel Labs) | input, output, cache read, cache creation | Reported (`cost_usd`) | Yes | Yes |
- | GitHub Copilot CLI | input, output, cache read, cache creation, reasoning | Not reported | Yes | Yes |
+ | GitHub Copilot CLI | input, output, cache read, cache creation, reasoning | Reported (`cost_usd`) for sessions started on or after 2026-06-01, from AI credits | Yes | Yes |
| OpenClaw Gateway | input, output, cache read, cache creation | Not reported on the hook | Yes, per model response | Yes |
+| Gemini CLI | input, output, cache read, reasoning | Not emitted by Gemini CLI | Yes, per model response | When local user context is present |
OpenClaw reports usage on its `llm_output` hook, which is a *conversation* hook -- OpenClaw withholds those from every non-bundled plugin until `plugins.entries.beacon-endpoint.hooks.allowConversationAccess` is set in its config. An OpenClaw endpoint collecting prompts, tools, commands and files while reporting no tokens at all is almost always that key, and `beacon endpoint hooks status --harness openclaw` says so. OpenClaw does compute a per-turn price, from an operator-configured cost table rather than from a provider report, so Beacon does not record it as a reported cost. See [OpenClaw Gateway](/runtimes/openclaw-gateway).
+Gemini CLI reports each model response on its `gemini_cli.api_response` log record and again on the `gemini_cli.token.usage` counter, under Gemini's own counts rather than the semconv names. Those counts are not disjoint: Gemini's input (`promptTokenCount`) already includes the cached content, its output (`candidatesTokenCount`) leaves out thinking tokens, and its tool-use prompt tokens are input that the prompt count does not hold. Beacon therefore records input as prompt minus cached plus tool-use prompt, cache read as the cached count, and output as candidates plus thoughts with the thoughts as its reasoning breakdown, so a response's Beacon total equals Gemini's own `total_token_count`. Gemini also restates input and output on a `gen_ai.client.inference.operation.details` record; Beacon reads usage only from `api_response`, so a response is counted once, and the counter is de-duplicated against the log because both carry Gemini's `session.id`. These shapes are pinned from Gemini CLI's telemetry source rather than from a recorded session.
+
- Cline reports usage once per task rather than per model call, because Beacon's rollups sum `gen_ai.usage` across events and reporting at both granularities would count every token twice. fx reports cumulative totals, which Beacon differences into per-turn deltas for the same reason. GitHub Copilot CLI reports assistant message output tokens and cumulative shutdown model totals; Beacon records the message output directly, then differences shutdown totals for input, cache, reasoning, and any output not already counted.
+ Cline reports usage once per task rather than per model call, because Beacon's rollups sum `gen_ai.usage` across events and reporting at both granularities would count every token twice. fx reports cumulative totals, which Beacon differences into per-turn deltas for the same reason. GitHub Copilot CLI reports assistant message output tokens and cumulative shutdown model totals; Beacon records the message output directly, then differences shutdown totals for input, cache, reasoning, and any output not already counted. Cost comes from the shutdown's session-wide `totalNanoAiu`, differenced the same way and converted at one AI credit = 10^9 nano-AIU = US$0.01. It is recorded once per shutdown: on the model's usage event when the shutdown names one model, otherwise on one usage event with no model, so a multi-model session is not counted once per model. Sessions started before GitHub moved Copilot to AI credits on 2026-06-01 were billed per premium request, so they record no cost; the raw nano-AIU total stays in `raw.copilot`. Annual Copilot Pro and Pro+ subscribers stay on premium-request billing until their plan renews, and the session record does not say which plan applies, so for them the recorded cost is what the session would cost in AI credits rather than their bill.
**Collected through the generic OpenTelemetry path, not yet verified against captured payloads:**