Skip to content

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

Open
gujunxiang wants to merge 1 commit into
pingdotgg:mainfrom
gujunxiang:fix/grok-context-review-followup
Open

gujunxiang wants to merge 1 commit into
pingdotgg:mainfrom
gujunxiang:fix/grok-context-review-followup

Conversation

@gujunxiang

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Nov 25, 2026
@coderabbitai

coderabbitai Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

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

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 name Status Explanation
Title check Passed 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 o…
Description check Passed 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…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check 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 6632511 and 24b5102.

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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant