Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(acp): preserve Grok context usage on wake replay #42610

Closedgujunxiang(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/42610/headopened View on GitHub

Summary

 replay wake notification
+  skip context-usage extraction
   project wake output

Follow-up to #42568. Wake-buffer replays no longer overwrite a newer live contextUsage snapshot. The Grok end-to-end assertion now uses the recorded provider fixture through OrchestratorV2 and persisted projections.

Evidence

  • Before: A buffered wake carrying usedTokens: 100 could replace a newer live 200 snapshot during drain. After: AcpAdapterV2 regression test keeps the latest 200; the relevant 178 affected tests pass.
  • Recorded Grok simple replay fixture passes through the orchestrator and asserts { usedTokens: 22_271, maxTokens: 500_000 } in the persisted provider thread.
  • Formatting, lint, knip, GraphQL, focused typechecks, and git diff --check pass. check:changed only reports an unrelated duplicate HostProcess import error in apps/desktop/src/preview/BrowserSession.test.ts on the merged upstream commit.

Merge Danger

Door: two-way

Blast Radius: provider-ACP wake replay and Grok replay-fixture coverage. The behavior change is limited to suppressing context extraction for buffered wake replays.

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    2. Explain Change →

      No actionable comments were generated in the recent review.

      Walkthrough

      ACP wake replays no longer project context usage. Grok resolves the default model’s context window using the session’s current model ID when available. Tests check ACP continuation summaries and Grok projected context usage.

      Changes: Provider context usage

      Layer / File(s)Summary
      ACP wake replay and usage checks
      packages/provider-acp/src/server/adapter.ts, apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts
      ACP wake-buffer drains mark notifications as replays, and handleSessionUpdate skips context-usage projection for those notifications. The test checks that buffered wake processing preserves the latest observed usage and that completed-task summaries use task IDs as command labels.
      Grok context window and fixture checks
      packages/provider-grok/src/server/adapter.ts, apps/server/src/orchestration-v2/Adapters/GrokAdapterV2.test.ts, apps/server/src/orchestration-v2/testkit/fixtures/simple/grok_output.ts, apps/server/src/orchestration-v2/testkit/fixtures/index.ts
      The default Grok model selection uses the trimmed session model ID when available. The simple fixture checks for 22,271 used tokens and a 500,000-token maximum. A live metadata replay test was removed.

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Change: Bug fix

      Possibly related issues

      • pingdotgg/t3code#29296: The PR adds a Grok fixture for projected context usage and changes ACP wake replay handling. The issue concerns missing usage extraction from Grok _meta fields, which these changes do not confirm as fixed.

      Suggested reviewers: juliusmarminge

      Merge Risk: Minimal · up to 24b51

      Wake replay no longer overwrites newer context-usage values, and Grok resolves the default model's context window from the session model ID. No concrete merge-blocking risk remains.

      Pre-merge checks: Passed 4

      Check nameStatusExplanation
      Title checkPassedThe title "fix(acp): preserve Grok context usage on wake replay" matches the main change. The adapter now skips context-usage extraction for replayed wake notifications, so a buffered wake no longer o…
      Description checkPassedThe description follows the template's main sections. It has a Summary that explains the change and a Verification section with concrete before/after evidence and the checks that passed. It also notes…
      Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
      Full details: Title check

      Explanation

      The title "fix(acp): preserve Grok context usage on wake replay" matches the main change. The adapter now skips context-usage extraction for replayed wake notifications, so a buffered wake no longer overwrites a newer live contextUsage snapshot. The title is a conventional commit with a specific scope and describes the primary fix. The Grok fixture and test-removal changes are secondary.

      Full details: Description check

      Explanation

      The description follows the template's main sections. It has a Summary that explains the change and a Verification section with concrete before/after evidence and the checks that passed. It also notes what could not be verified (check:changed reports an unrelated HostProcess import error). The Problem, Change, and Scope sections are not labeled as in the template. The Scope section does not link an issue (it references #42568 as a follow-up, not as a bug report), and it does not say why no issue is needed. The model/harness line from the template is missing. These gaps are minor, so the description is mostly complete.

      Finishing Touches

      Generate unit tests (beta)

      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Recent review info

      Run configuration

      Commits

      Reviewing files that changed from the base of the PR and between 6632511cd8f523c2b9439272d776fb44c2bce110 and 24b51027425b7c65478e047a457edb86aacd6c32.

      Files selected for processing: 6

      • apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts
      • apps/server/src/orchestration-v2/Adapters/GrokAdapterV2.test.ts
      • apps/server/src/orchestration-v2/testkit/fixtures/index.ts
      • apps/server/src/orchestration-v2/testkit/fixtures/simple/grok_output.ts
      • packages/provider-acp/src/server/adapter.ts
      • packages/provider-grok/src/server/adapter.ts
      Files with no reviewable changes: 1

      • apps/server/src/orchestration-v2/Adapters/GrokAdapterV2.test.ts

      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

    3. tanstack-source added labelsbug

Sign in to join this conversation.