pingdotgg / pingdotgg/t3code

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

Open
#8,382 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
23k
Forks
5.9k
Avg merge
11h 14m
Merged PRs (30d)
357

Description

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 #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
  • ProviderRuntimeIngestion already maps thread.token-usage.updated to context-window.updated.
  • ContextWindowMeter already renders that activity. No new UI component is needed.
  • Grok exposes context fill through ACP _meta.totalTokens and model capacity through availableModels[]._meta.totalContextTokens. A standard ACP usage_update should also be accepted when available.
  • #5405 demonstrates the intended behavior and contains focused tests, but it predates #8358 and should be rebased or manually ported rather than merged unchanged.
  • Keep the change on top of #8358's current AcpRuntimeModel, GrokAcpSupport, and GrokAdapter structure.
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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with GrokAdapter, GrokAcpSupport, and AcpRuntimeModel to trace usage-bearing ACP notifications and completed prompts. Compare the focused tests from #5405, then inspect ProviderRuntimeIngestion and ContextWindowMeter to verify the existing event path. Done means valid Grok snapshots include the model maximum, update the composer meter, and are not replaced by interrupted turns.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.