Skip to content

fix(provider-acp): preserve Grok answers after early task completion - #32229

Open
Sidreyas wants to merge 1 commit into
pingdotgg:mainfrom
Sidreyas:sidreyas/fix-22865-grok-early-result
Open

Sidreyas wants to merge 1 commit into
pingdotgg:mainfrom
Sidreyas:sidreyas/fix-22865-grok-early-result

Conversation

@Sidreyas

@Sidreyas Sidreyas commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Problem

When an unpolled Grok background command finishes before the root prompt settles, T3 queues a continuation without any native wake output. That empty run replaces the child's completed answer in the delegated result, so its parent receives Child task completed without an assistant result. A later native answer does not repair the already published result.

Fixes #22865.

Change

Require the existing assistant-output/completed-tool evidence predicate when offering a continuation from finalization or a late task mutation. Keep the unreported completion pending until the native wake arrives, using the existing bounded idle-session retention. The real wake still creates and completes its own turn.

Extend the existing early-completion and staggered-completion cases to cover reportless notices, reasoning-only traffic, duplicate completions, native answer delivery, and release of pending work after the wake.

Scope and approval

This is a focused exception for an obvious result-loss bug in an established workflow. The production change is confined to the ACP adapter's continuation eligibility and retention. Grok is the only production flavor enabling this continuation path; no client, contract, prompt, or product default changes are needed.

I checked related PR diffs, including #32109 (commands keeping the root running), #17779 (native subagent lifetime), #21877 (nested follow-ups), and #21094 (native subagent wait_all/will_wake). They address different cases and do not remove this reportless command continuation.

Verification

Windows, Node 26.12.1, local frozen-lockfile dependencies; base 32a0531748c44b25072d7495ce0b9bd7e9450a87.

From apps/server:

vp test run src/orchestration-v2/Adapters/AcpAdapterV2.test.ts -t "retains early Grok" --maxWorkers 1
Before: 2 failed, 92 skipped.
Both failed: a task completion without native wake output must not replace the root answer
            expected continuation requests length 0, got 1.
After: 2 passed, 92 skipped.

vp test run src/orchestration-v2/Adapters/AcpAdapterV2.test.ts -t "retains early Grok|staggered pre-settle completion" --maxWorkers 1
After the final test assertions: 3 passed, 91 skipped.

vp run check:changed --concurrency 1 was attempted. It stalled before the check stages in the ignored-file git ls-files junction scan described in #32023. I stopped that retained session and ran every exact selected stage serially; the wrapper itself is not claimed passed.

  • Selected ACP adapter and context-budget files: 96 tests passed.
  • Additional recorded Grok replay: 16 passed; delegated completion delivery: 39 passed.
  • Changed-file format/lint, both Knip passes, and server GraphQL generation check: passed.
  • All 14 selected package typechecks passed, with no cache hits. The resumed native checks used RAYON_NUM_THREADS=1 and tests used one worker.
Exact selected commands

From the repository root:

vp fmt --check --no-error-on-unmatched-pattern apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts packages/provider-acp/src/server/adapter.ts
vp lint --no-error-on-unmatched-pattern apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts packages/provider-acp/src/server/adapter.ts
vp exec knip --include files,dependencies --no-config-hints
vp exec knip --workspace apps/server --workspace apps/desktop --workspace apps/web --workspace packages/client-runtime --workspace packages/contracts --workspace packages/effect-acp --workspace packages/effect-codex-app-server --workspace packages/shared --workspace packages/ssh --workspace packages/tailscale --workspace packages/provider-core --workspace packages/provider-acp --workspace packages/provider-acp-registry --workspace packages/provider-testing --workspace packages/provider-pi --workspace packages/provider-muse --workspace packages/provider-opencode --workspace packages/provider-cursor --workspace packages/provider-fx --workspace packages/provider-grok --workspace packages/provider-kiro --workspace packages/secret-provider-core --workspace packages/secret-provider-definitions --workspace packages/secret-provider-onepassword --workspace packages/source-control-core --workspace packages/source-control-definitions --workspace packages/source-control-azure-devops --workspace packages/source-control-bitbucket --workspace packages/source-control-forgejo --workspace packages/source-control-gitcafe --workspace packages/source-control-github --workspace packages/source-control-gitlab --workspace packages/source-control-testing --exports --preprocessor ./scripts/knip-schemas.ts --no-config-hints
vp run --filter ./apps/server generate --check
vp run --cache --parallel --concurrency-limit 1 --filter @t3tools/client-runtime --filter @t3tools/desktop --filter @t3tools/evals --filter @t3tools/mobile --filter @t3tools/provider-acp --filter @t3tools/provider-acp-registry --filter @t3tools/provider-fx --filter @t3tools/provider-grok --filter @t3tools/provider-kiro --filter @t3tools/provider-pi --filter @t3tools/scripts --filter @t3tools/web --filter t3 --filter t3code-relay typecheck

From apps/server:

vp test run --passWithNoTests src/orchestration-v2/Adapters/AcpAdapterV2.test.ts src/provider/AgentContextBudget.test.ts --maxWorkers 1
vp test run src/orchestration-v2/testkit/GrokReplayFixtures.integration.test.ts --maxWorkers 1
vp test run src/orchestration-v2/DelegatedCompletionDelivery.test.ts --maxWorkers 1

Standalone verifier, native ACP fixture, and reproduction steps.

Actual integrated reproduction used the production T3 CLI with a fresh temporary home, authenticated HTTP/WebSocket RPC, the real Grok adapter and a deterministic ACP subprocess. A parent called T3's real MCP delegate_task; the child sent its background task completion before settling its root answer. The parent's real MCP task_status read the published result, then a network gate released a later native wake. Both runs used byte-identical verifier/fixture scripts; observations came from persisted projections over the real WebSocket connection.

node %TEMP%/slot8-22865-e2e.mjs baseline
published summary: Child task completed without an assistant result.
child runs:        1 completed, 2 completed, 3 completed
child answers:     EARLY_SUCCESS_DONE, LATE_NATIVE_ANSWER

node %TEMP%/slot8-22865-e2e.mjs fixed
published summary: EARLY_SUCCESS_DONE
child runs:        1 completed, 2 completed
child answers:     EARLY_SUCCESS_DONE, LATE_NATIVE_ANSWER

Each CLI used an explicit isolated --base-dir, loopback port, and private bootstrap FD. Both captured server PIDs were stopped in finally. The fixture launches Node directly with a per-provider preload and imports the shipping client's 15-second PING_TIMEOUT; no lifecycle timeout was changed. This verifies the production service/protocol path with deterministic Grok wire traffic, not a live paid Grok turn or UI. The direct Node fixture's separate skill-discovery inspect probe was unavailable; the ACP turn handshake completed.

Implemented with OpenAI GPT-6 via the Codex harness.

Copilot AI balanced review requested due to automatic review settings November 6, 2026 22:58

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Nov 6, 2026
@macroscopeapp

macroscopeapp Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at b9f889c

Macroscope's review found this PR approvable — The change preserves early Grok task answers by waiting for substantive wake output before starting a continuation and retaining pending completion state. Its effects are confined to existing ACP lifecycle handling, with no product-default or permission changes.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The ACP adapter now requires qualifying wake evidence and no running background tasks before offering a continuation. Background task completion notices alone do not count as pending work. Tests cover completion notices, reasoning, and assistant output.

Changes: Background continuation gating

Layer / File(s) Summary
Continuation offer and pending-work checks
packages/provider-acp/src/server/adapter.ts
Continuation offers require qualifying wake evidence and no running background tasks. Completed task IDs no longer make background work pending by themselves.
Continuation behavior tests
apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts
Tests verify that task-completion notices and reasoning alone do not offer a continuation. Assistant output offers one, and the continuation turn receives that output and clears pending work.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant BackgroundTask
  participant ACPAdapter
  participant AssistantOutput
  BackgroundTask->>ACPAdapter: Send task-completion notice
  ACPAdapter->>ACPAdapter: Keep work pending without offering continuation
  AssistantOutput->>ACPAdapter: Provide qualifying wake evidence
  ACPAdapter->>ACPAdapter: Offer continuation when no background tasks are running
Loading

Suggested labels: bugfix

Suggested reviewers: juliusmarminge

Merge Risk: Minimal · up to b9f88

No actionable merge-blocking risk is established for the background-command completion change.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title clearly describes the Grok answer-loss fix.
Description check Passed The description includes the problem, change, scope justification, and detailed verification results. It also states the verification limits and identifies the model and harness.
Linked Issues check Passed [#22865] The adapter requires native wake evidence before it offers a continuation and retains unreported completions while waiting. The changed tests cover early and staggered completions, reasoning-…
Out of Scope Changes check Passed [#22865] The adapter changes address continuation eligibility and retention. The test changes cover the same background-completion behavior. No unrelated changes are evident.
Full details: Linked Issues check

Explanation

[#22865] The adapter requires native wake evidence before it offers a continuation and retains unreported completions while waiting. The changed tests cover early and staggered completions, reasoning-only traffic, duplicate notices, native answer delivery, and pending-work release. The reported integrated reproduction shows that the fixed task_status publishes the root answer instead of the empty-result placeholder.

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 b90e554 and b9f889c.

Files selected for processing: 2

  • apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts
  • packages/provider-acp/src/server/adapter.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 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:S 10-29 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.

[Bug]: Grok unpolled early completion publishes an empty continuation instead of the final answer

2 participants