Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(acp): order mid-reasoning Antigravity steers after the first reply #48657

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

electrum(GitHub profile, opens in a new tab)commented

Problem

When steering Antigravity (agy acp 1.5+, steersWithPrompt) while it is still running tool calls or final reasoning for the earlier prompt, Antigravity finishes its full answer to prompt 1 before executing the steer in the same run. Because the steer user_message keeps its submission-time ordinal and the pre-steer answer has no phase: "final_answer", the settled timeline places the steer bubble ahead of prompt 1's answer and folds prompt 1's entire answer under "Continued for ..." (and hides it in Zen mode) once the steer runs tools and emits a short reply.

Change

packages/provider-acp/src/server/adapter.ts now tracks mid-turn prompt steers on replyEndsWithUsageUpdate flavors using the existing steer.updated (pending → completed with atPromptStart: true) and phase: "final_answer" contracts:

  • When a user steer is dispatched while a reply or prompt is still open, the adapter emits steer.updated (pending).
  • Once the pre-steer reply completes (usage_update, or an agent_thought starting the next turn after a non-narration reply) and new steer output begins, the adapter closes the pre-steer reply, marks it phase: "final_answer" (skipping short interim narration), and emits steer.updated (completed, atPromptStart: true) before projecting the steer's items. ProviderEventIngestor and TurnItemPositionStore then move the steer immediately after the pre-steer answer and ahead of the steer's reasoning/tools/reply.
  • If the steer is absorbed into the first reply and the prompt settles without a follow-up, steer.updated (completed) is emitted without atPromptStart, keeping the steer at its original position before that reply.
  • If a user steer arrives after the prior reply already settled (e.g. while background work holds the turn open), the prior reply is closed and marked final_answer without deferring the steer behind its own reply.

No client or orchestration changes are needed: ProviderEventIngestor, TurnItemPositionStore, web (MessagesTimeline.logic.ts), and mobile (threadActivity.ts) already honor steer.updated (atPromptStart: true) and phase: "final_answer".

Scope

Fixes #48620.

Verification

  • Added 7 tests under deferred mid-turn prompt steers in apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.ts, including an end-to-end test through the real Orchestrator, EffectWorker, RunExecutionService, ProviderEventIngestor, TurnItemPositionStore, and SQLite ProjectionStore verifying the settled timeline order (user_message:turn_start → dynamic_tool → reasoning → assistant_message:final_answer → user_message:steer:completed → reasoning → file_change → assistant_message) as well as absorbed steers, mid-work progress narration with tool-step usage_update, omitted intermediate usage_update, back-to-back steers, immediate follow-up replies, and post-settle background wakes.
  • vp test run apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.ts: 68/68 passed.
  • vp test run apps/server/src/orchestration-v2/ProviderEventIngestor.test.ts -t "steer": 2/2 passed.
  • vp run check:changed: passed (format, lint, knip, graphql, typecheck across 13 packages, and test across 3 files / 72 tests).
  • Not verified manually against a live agy acp process in the web/mobile UI; verified via scripted ACP sessions and persisted orchestration projections.

Written with Gemini 4 Neon in T3 Code (Antigravity harness).

    1. tanstack-source added labelsbug

    2. chatgpt-codex-connector[bot](GitHub profile, opens in a new tab)commented
      Codex Review Summary: ✅ Completed

      This comment shows the latest Codex review activity on this pull request.

      ReviewStatusCommitReview trigger
      📝 Code Review✅ Completed 2026-12-04T07:38:37.745452Z093fdfePR opened
      ℹ️ About Codex in GitHub

      Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

      • Open a pull request for review
      • Mark a draft as ready
      • Comment "@codex review" or "@codex security review".

      Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

    3. Approvability

      Verdict: Approved at 093fdfe

      Macroscope's review found this PR approvable — This fixes Antigravity steer ordering so the preceding reply appears before the steer’s work. The change is confined to event tracking and reply boundaries, without changing product defaults or tool permissions.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. Steer handling can mistake interim narration for a completed reply or miss a direct tool-call boundary, leaving the original answer incorrectly ordered and vulnerable to being folded away.

      2 open issues
      • Medium severity [Exclude interim narration before usage updates from completed replies](https://github.com/pingdotgg/t3code/pull/48657#discussion_r4796837490) · New
      • Medium severity [Release pending steer when a new tool call follows the answer](https://github.com/pingdotgg/t3code/pull/48657#discussion_r4796837518) · New
    5. What changed in this PR

      Addresses #48620 by placing deferred Antigravity steers after the completed original reply and keeping that reply visible.

      Changes:

      • Tracks pending prompt steers and detects reply boundaries.
      • Marks pre-steer answers as final and updates steer ordering.
      • Adds adapter regression tests and persisted-timeline coverage.
      FileDescription
      packages/​provider-acp/​src/​server/​adapter.tsTracks deferred steers and preserves pre-steer replies.
      apps/​server/​src/​orchestration-v2/​Adapters/​AntigravityAdapterV2.test.tsTests reply retention, steer ordering, and persisted timeline behavior.
      Review effort: Balanced
@@ -7322,3 +7438,11 @@
73227438 } else if (context.nativeThreadId === notification.sessionId) {
73237439 if (update.sessionUpdate === "usage_update") {
73247440 context.replyOpen = false;
7441+ if (!context.finalized && context.pendingPromptSteers.length > 0) {
7442+ const lastReply =
7443+ (context.assistant.current?.text.trim().length ?? 0) > 0
7444+ ? context.assistant.current
7445+ : context.closingAssistantSegments.findLast(
7446+ (segment) => segment.text.trim().length > 0,
7447+ );
7448+ if (lastReply !== undefined && lastReply !== null) {
copilot-pull-request-reviewer[bot](GitHub profile, opens in a new tab)commented

If a pending steer is followed by short progress narration, a tool-step usage_update, and another original-prompt tool call, this records the narration as the completed reply. The next tool then releases and repositions the steer before the actual answer, which can still be folded away. Exclude short interim narration here, matching the reasoning fallback, and test usage arriving after narration but before the next tool.

@@ -7579,3 +7706,15 @@
75797706 ) {
75807707 yield* emitProviderRetry(context, "completed");
75817708 }
7709+ // A prompt-steered agent that finished its prior reply before taking the steer now
7710+ // begins the steer's work; anchor the steer after that reply before emitting new items.
7711+ if (context.pendingPromptSteers.length > 0) {
7712+ if (
7713+ context.completedPreSteerReply !== null &&
7714+ isNewModelOutputForSteer(context, notification)
7715+ ) {
7716+ yield* releaseDeferredPromptSteers(context, context.completedPreSteerReply);
7717+ } else if (
7718+ (update.sessionUpdate === "agent_thought_chunk" &&
7719+ (acpContentBlockDisplayText(update.content)?.length ?? 0) > 0) ||
7720+ (update.sessionUpdate === "agent_thought" &&
copilot-pull-request-reviewer[bot](GitHub profile, opens in a new tab)commented

Without an intervening usage_update, this fallback only recognizes reasoning frames. If the first answer is followed directly by the steer's new tool_call, no steer is released; emitTool then calls closeTextStreamsForNewTool, clearing the answer from closingAssistantSegments. The original answer therefore remains below the steer and can still be folded away after the steer reply. Handle a new-tool boundary after a substantive answer as well, and cover the no-usage/direct-tool sequence in the regression tests.

  • 💡 Codex Review

    Here are some automated review suggestions for this pull request.

    Reviewed commit: 093fdfe59f

    ℹ️ About Codex in GitHub

    Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

    • Open a pull request for review
    • Mark a draft as ready
    • Comment "@codex review".

    If Codex has suggestions, it will comment; otherwise it will react with 👍.

    Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

    @@ -7579,3 +7706,11 @@
    75797706 ) {
    75807707 yield* emitProviderRetry(context, "completed");
    75817708 }
    7709+ // A prompt-steered agent that finished its prior reply before taking the steer now
    7710+ // begins the steer's work; anchor the steer after that reply before emitting new items.
    7711+ if (context.pendingPromptSteers.length > 0) {
    7712+ if (
    7713+ context.completedPreSteerReply !== null &&
    7714+ isNewModelOutputForSteer(context, notification)
    7715+ ) {
    7716+ yield* releaseDeferredPromptSteers(context, context.completedPreSteerReply);

    P2 Badge Preserve the position of steers absorbed by the first reply

    If Antigravity incorporates a steer into its first answer and a Stop hook then continues the same prompt, the next thought is treated as a deferred steer being read. releaseDeferredPromptSteers emits atPromptStart: true, and ProviderEventIngestor consequently requests moveTurnItemToEnd, moving the user instruction after the answer that already applied it. This regresses the absorbed-steer case whenever the prompt continues rather than settling immediately after that answer; the added absorbed-steer test releases the prompt before any continuation, so it misses this case. Preserve the original position unless there is evidence distinguishing deferred steer consumption from continuation of an already-steered answer.

    Useful? React with 👍 / 👎.

  • Thanks for this. T3 Code's ACP Registry support follows the ACP spec: the code every agent shares takes no changes that are specific to one agent, and the special cases already there are not a precedent for more (how providers are integrated).

    The ordering problem in #48620 is real, but this diff adds Antigravity's queued-steer and reply-boundary heuristics to the shared ACP adapter. The usage-update flavor flag is an Antigravity integration setting, not a capability advertised through ACP, so naming the flag generically does not make this shared protocol handling.

    Antigravity already has a dedicated driver. Please keep the provider-specific reply-boundary decisions in that driver's flavor, with any shared primitives limited to provider-neutral event handling; the reproduction and timeline assertions are useful evidence for that revision.

    An integration that needs Antigravity's identity, credentials or private API is a dedicated provider driver, and we only add one when a maintainer has decided to own that integration. If you think Antigravity should have one, open an issue making that case first.

    Closing.

  • juliusmarminge closed this

  • Sign in to join this conversation.