Skip to content

[Bug]: Grok threads do not show context-window usage in the composer #8382

Closed

Description

@ahmed-besic

Before submitting

  • I searched existing issues and did not find an active duplicate.
  • I included enough detail to reproduce or investigate the problem.

Related work: the broader #5418 is closed, and #5405 is an open pre-#8358 implementation PR.

Area

apps/server

Steps to reproduce

  1. Run a T3 Code build containing fix(grok): improve skills, plans, usage, and turn reliability #8358.
  2. Start a Grok thread with a model that advertises _meta.totalContextTokens over ACP.
  3. Send a prompt and wait for Grok to report _meta.totalTokens in session/update or the final prompt response.
  4. Inspect the context-window meter beside the composer.

Expected behavior

Grok threads should show the existing context-window meter with used tokens, maximum tokens, and fill percentage, matching Codex and other providers. The value should update when Grok reports a newer usage snapshot.

Actual behavior

The meter is absent for Grok threads.

#8358 added Grok token and cost records to the historical Usage page by parsing updates.jsonl. That is a separate pipeline. The live Grok adapter still does not emit thread.token-usage.updated, so the existing ingestion path never creates context-window.updated activity for the composer.

Impact

Minor bug or occasional failure

The failure is consistent, but it does not block a turn. Users cannot see when a long Grok thread is approaching its context limit or decide when to compact or start a new thread.

Version or commit

main after #8358 (ead4ce52a1624d9c55461f61524580978fc8b719)

Environment

Web or desktop client with the Grok provider.

Logs or stack traces

No error is shown. This is a missing provider-runtime event.

Technical notes

Acceptance criteria

  • A usage-bearing Grok notification or completed prompt emits a positive thread.token-usage.updated snapshot.
  • The snapshot includes the active model's context-window maximum when Grok advertises it.
  • The existing composer meter appears and updates for Grok threads.
  • Interrupted turns do not overwrite the last valid context snapshot.
  • Focused adapter and ingestion tests prove the public event and visible activity contract.

Workaround

There is no in-app workaround. Users can inspect Grok directly or start a new thread conservatively.

Activity

  1. theman6660 commented on Sep 2, 2026

    @theman6660

    Confirmed on a live Grok ACP session with the current CLI.

    Grok still does not emit sessionUpdate: "usage_update". The composer meter stays empty because the live adapter never publishes thread.token-usage.updated.

    What does work for occupancy:

    • session/update _meta.totalTokens is the context fill. A greeting turn was 1615; a long thread sat around 199k–210k.
    • The session signals.json records contextWindowTokens: 500000.
    • Mapping _meta.totalTokens onto the existing thread.token-usage.updated → context-window.updated path is enough for ContextWindowMeter. No new UI.

    What does not work for the meter:

    • Prompt-response usage.totalTokens / _meta.usage is billed API tokens, not context occupancy. Same greeting: 20554 billed vs 1615 occupancy. Using that as an end-of-turn snapshot overwrites the correct number.

    #5405 already maps _meta.totalTokens (the right source) and also prompt-response usage (the source to drop). Happy to help rebase or retest against current GrokAdapter if that is useful.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions