Skip to content

feat(server): ACP sessionUpdate parity for Grok clients - #5502

Open
EnzoTironi wants to merge 3 commits into
pingdotgg:mainfrom
EnzoTironi:pr/grok-acp-parser
Open

feat(server): ACP sessionUpdate parity for Grok clients#5502
EnzoTironi wants to merge 3 commits into
pingdotgg:mainfrom
EnzoTironi:pr/grok-acp-parser

Conversation

@EnzoTironi

@EnzoTironi EnzoTironi commented Aug 6, 2026

Copy link
Copy Markdown

Recovery: New PR after head fork EnzoTironi/t3code was deleted (auto-closed #5422). Same branch tip. #5424/#5425 stay closed (absorbed into Grok native).

Original: #5422

What Changed

Shared ACP session/update parsing so live Grok (and other ACP clients) map into typed runtime events instead of being dropped:

  • agent_thought_chunk → reasoning stream (streamKind: reasoning_text)
  • usage_updatethread.token-usage.updated via makeAcpTokenUsageEvent
  • available_commands_update, config_option_update, session_info_update, user_message_chunk
  • UnknownSessionUpdate fallback for forward compatibility
  • session/set_model optional _meta pass-through (needed by Grok effort)
  • acp-mock-agent toggles for Grok-shaped session behavior

Fixes #5417

Why

Live grok agent stdio already emits these update kinds. Without shared parser coverage, each provider adapter drops them or casts ad hoc. Putting the model in AcpRuntimeModel / AcpCoreRuntimeEvents keeps orchestration pure.

UI Changes

None (server/shared ACP only).

Checklist

  • This PR is small and focused (~+379 / 6 files)
  • I explained what changed and why
  • UI screenshots N/A
  • Video N/A

Test plan

  • AcpRuntimeModel / AcpCoreRuntimeEvents unit tests
  • Live Grok 0.2.x initialize/session on macOS

Model: grok-4.5 (Grok Build)


Note

Medium Risk
Touches core ACP event parsing and Cursor runtime event emission for token usage and streaming; behavior changes for live ACP sessions but scope is server-only with unit test coverage.

Overview
Extends shared ACP session/update handling so Grok-shaped agents no longer drop common update kinds. parseSessionUpdateEvent now emits typed events for reasoning chunks (agent_thought_chunkContentDelta with streamKind: reasoning_text), token usage, slash commands, live config options, session title/metadata, and user echo chunks, with an UnknownSessionUpdate fallback for forward compatibility.

Adds makeAcpTokenUsageEvent and optional streamKind on makeAcpContentDeltaEvent so adapters can publish thread.token-usage.updated and distinguish assistant vs reasoning text. CursorAdapter wires UsageUpdated through that helper and forwards streamKind / rawPayload on content deltas.

AcpSessionRuntime now returns authenticateResult from startup, passes optional _meta on session/set_model, and refreshes configOptionsRef when config_option_update arrives so config validation stays current. The acp-mock-agent gains Grok-like toggles (/compact, session info, usage on prompt result, init commands, non-numeric JSON-RPC id).

Reviewed by Cursor Bugbot for commit 6fbe75f. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Add ACP sessionUpdate parity for Grok clients with token usage, thought chunks, and session info events

  • Extends AcpRuntimeModel.ts to parse additional ACP session update types: agent_thought_chunk, user_message_chunk, usage_update, available_commands_update, config_option_update, and session_info_update, plus an UnknownSessionUpdate fallback.
  • Adds makeAcpTokenUsageEvent factory in AcpCoreRuntimeEvents.ts to produce thread.token-usage.updated runtime events; makeAcpContentDeltaEvent now accepts an optional streamKind to distinguish assistant_text from reasoning_text.
  • Wires UsageUpdated and ContentDelta (with streamKind/rawPayload) through the CursorAdapter so token usage and stream kind reach the event stream.
  • Updates AcpSessionRuntime.ts to return authenticateResult from start(), keep configOptionsRef in sync on live updates, and forward optional _meta in setSessionModel.
  • Extends the mock agent script acp-mock-agent.ts to simulate /compact commands, session_info_update notifications, skills-reload responses, and token usage fields in prompt responses.

Macroscope summarized 6fbe75f.

CursorAdapter now maps usage_update → thread.token-usage.updated via the
shared factory (same consumer pattern as ContentDelta/streamKind).
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 567d97e5-44d9-4e56-b565-c0e5fcecb7db

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Aug 6, 2026
Comment thread apps/server/src/provider/acp/AcpRuntimeModel.ts
@macroscopeapp

macroscopeapp Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

This PR introduces a new feature adding multiple new session update event types (usage, commands, config, session info, thought chunks) with parsing logic and runtime integration across several layers. The scope and new capability introduced warrant human review.

You can customize Macroscope's approvability policy. Learn more.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a45fb3d. Configure here.

Comment thread apps/server/src/provider/acp/AcpCoreRuntimeEvents.ts Outdated
…flag

Refresh configOptionsRef when config_option_update arrives so validation and
getConfigOptions stay live. Stop hardcoding compactsAutomatically on generic
ACP token usage events; only set it when the caller knows auto-compact.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Grok/ACP: sessionUpdate parity for live Grok agent stdio

1 participant