The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
Merge origin/main into claude/gracious-newton-609b9n-gemini-token-types
Claude863f8f83d7c2
diff --cc cli/beacon/internal/tokens/coverage.goindex eb07946d,bbfe219b..e076d7d2--- a/cli/beacon/internal/tokens/coverage.go+++ b/cli/beacon/internal/tokens/coverage.go@@@ -86,15 -92,29 +92,34 @@@ var usageExpectation = map[string]struc"deepseek_harness": {ExpectReported, "native session backfill reports usage when DeepSeek persists it"},"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"},++ // Runtimes whose usage reaches Beacon only through a session-store sync. Their hooks carry no+ // token counts, so a window of hook activity with no usage is spend missing from the total --+ // silent, which is right -- but the fix is running the sync rather than repairing a hook, so+ // the note names the command.+ //+ // Hermes keeps running per-session totals, cost included, in its state database, and the sync+ // differences them into token.usage deltas (hermessession/collect.go, mapUsage).+ "hermes": {ExpectReported, "beacon endpoint hermes sync reads session totals and cost; hook payloads carry none"},+ // Factory keeps running totals in each session's settings file, and the sync differences them+ // (factorysession/mapper.go, emitSettingsUsage). Its OTLP export still contributes when it+ // carries the semconv names; the sync is the path Beacon reads Factory's own record from.+ "factory": {ExpectReported, "beacon endpoint factory sync reads session settings totals; OTLP only if it emits GenAI semconv usage"},+ // The factory_droid spelling never comes from the sync, which writes harness "factory" and is+ // not normalized onto this name. It is what a Factory OTLP export can name itself, so it keeps+ // the generic-OTLP expectation rather than pointing at a command that cannot clear it.+ "factory_droid": {ExpectGenericOTLP, "only if it emits OTel GenAI semconv usage"},+- "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"},+ // goose's chat spans carry the full semconv usage set, but they reach Beacon only over OTLP+ // configured by hand, and its hook adapter carries none. Without its own key it fell to the+ // unrecognized default.+ "goose": {ExpectGenericOTLP, "chat spans carry GenAI semconv usage, but only over manually configured OTLP"},// Grok Bot runs on a Cursor-hosted cloud computer and reaches Beacon only through Cursor's// server-side OpenTelemetry export, so whether usage arrives depends on whether that export// carries the semconv names -- the generic-OTLP case exactly, not a runtime Beacon reads.diff --cc docs/cli/token-usage.mdxindex 4f0d7369,9e10662d..3881194e--- a/docs/cli/token-usage.mdx+++ b/docs/cli/token-usage.mdx@@@ -51,20 -54,19 +54,21 @@@ from. A turn with no token attribution| fx (Vercel Labs) | input, output, cache read, cache creation | Reported (`cost_usd`) | 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).+ 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. The session-file sync, `beacon endpoint integrations openclaw sessions sync`, reads the usage OpenClaw commits on each assistant message and needs no grant. See [OpenClaw Gateway](/runtimes/openclaw-gateway).++ Hermes Agent and Factory Droid report usage only through their session-store sync: neither runtime's hooks carry a token count, so their usage arrives when `beacon endpoint hermes sync` or `beacon endpoint factory sync` runs. Both keep running session totals, which the sync differences into deltas. Until the sync runs, the coverage report lists them as `silent`, with a note naming the command.+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. 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:**| Runtime | Status ||---------|--------|-| Gemini CLI | Usage is captured when the runtime emits the OTel GenAI semconv names (`gen_ai.usage.*` attributes, or a `gen_ai.client.token.usage` metric split by `token_type`). The generic path is tested; these runtimes' own payloads have not been captured and pinned. |-| VS Code Copilot | As above |+| VS Code Copilot | Usage is captured when the runtime emits the OTel GenAI semconv names (`gen_ai.usage.*` attributes, or a `gen_ai.client.token.usage` metric split by `token_type`). The generic path is tested; these runtimes' own payloads have not been captured and pinned. |- | Factory Droid | As above || Grok Bot | Reaches Beacon only through Cursor's server-side OpenTelemetry export, so usage arrives only if that export carries the semconv names || goose | goose's `chat` spans carry the full `gen_ai.usage.*` set, cache reads and writes included, under the exact semconv names -- that much is read out of the runtime rather than hoped for. What is conditional is whether it arrives: usage reaches Beacon only over manually configured OTLP, so a hooks-only goose setup is correctly silent rather than faulty. goose reports no cost. See [goose](/runtimes/goose) |