Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): show when an answer's delivery to the provider fails #14496

Closedsaphid(GitHub profile, opens in a new tab)wants to merge 6 commits intomain fromrefs/pull/14496/headopened View on GitHub

Model: built with Claude Opus 5.5 in Claude Code.

Problem

When a user answers a question or approval on a V2 thread, dispatch marks the request resolved before the answer is delivered to the provider. If every delivery attempt failed, nothing reported it. The question disappeared, the provider could still be waiting for an answer it never got, and the run spun with nothing to answer and no error.

Change

The last failed runtime-request.respond attempt dispatches a new server-only command, runtime-request.delivery.fail. It adds a failed Answer delivery not confirmed error item to the timeline, on the request's own node: "T3 Code could not confirm that your answer reached the agent. If the run stays stuck, stop it and try again." The answer stays recorded and the run is not marked failed. The item is recorded even when the provider session was detached before the last attempt.

The request is not reopened. A failed delivery does not show whether the provider is still waiting. For example, OpenCode can accept a reply and drop its callback before the HTTP response returns, so a reopened question could be one nobody can answer. Reporting that delivery could not be confirmed is true in every case.

This follows the same pattern as checkpoint.rollback.fail: the last failed attempt tells clients instead of leaving them waiting.

Why it matters

Seen on a Claude thread: the agent asked a question with AskUserQuestion, the user answered, and the delivery effect failed all 5 attempts within about 1.5 s with No pending Claude runtime request <id>. The Claude CLI then blocked on the tool permission callback for 22 minutes while the thread showed "Working" with no question. Only a steer, which aborted the pending tool, got it moving again.

The delivery failed because two servers were running against one data directory, so the effect ran on the server whose Claude session did not hold the pending request. That root cause is #14115, with a fix proposed in #8442. This PR does not address it. It makes a failed delivery visible, whatever the cause.

Verification

  • New RuntimeRequestDelivery.integration.test.ts drives the real orchestrator, outbox and effect worker with a fake provider that asks a live question and refuses every delivery. While retries remain there is no error item. After the fifth failed attempt there is exactly one failed transport_error item on the request's node. It carries the request node's provider thread and turn, the request is still resolved with its answer, and the run is still running. Replaying the failure command adds nothing.
  • A second case detaches the provider session before the last attempt and still gets exactly one item.
  • The first case fails when the worker's dispatch is removed. The detached case fails when the item requires a bound session.
  • Before the rebase, vp test run on RuntimeRequestDelivery.integration, RuntimeRequestService, EffectWorker, runtimeLayer, Orchestrator.control-reads, SteeringCompletion.integration, ThreadMessageIntake and ProviderEventIngestor: 8 files, 108 tests passed.
  • Rebased onto main 7812230572. vp test run on RuntimeRequestDelivery.integration, EffectWorker, RuntimeRequestService and the contracts orchestrationV2 test: 4 files, 51 tests passed. The bound and detached cases are now one it.effect.each, for main's no-test-in-loop lint rule; both pass.
  • apps/server and packages/contracts typecheck clean; lint and format clean on the changed files.
  • Merged with main 9c9ae43d80 on 2026-10-14. Main moved the provider adapter types into @t3tools/provider-core, so the test's imports follow. Two more cases: a delivery that succeeds on the third attempt, and a last attempt that is interrupted rather than refused (the adapter returns an interrupt, standing in for shutdown). Neither records a failure item; the interrupted case fails if the worker's interrupt check is removed. vp test run on RuntimeRequestDelivery.integration, EffectWorker, RuntimeRequestService and the contracts orchestrationV2 test: 4 files, 62 passed.
  • The notice is best effort: if the server process or its database fails at the moment the last attempt fails, the notice can be lost with it.
  • Not exercised in a real client. The item uses the existing error turn item type that web and mobile already render.

Diagnosed, implemented and tested by Claude Opus 5.5 in Claude Code, running inside T3 Code; reviewed by GPT-6 Astra over two rounds (its first round replaced an earlier version that reopened the question).

The 2026-10-05 rebase: Claude Opus 5.5 in T3 Code (Claude Code harness). Independent review: GPT-6.1 Sol (high reasoning) in T3 Code, no actionable findings.

The 2026-10-14 main merge and added cases: Claude Opus 5.5 (Claude Code) via T3 Code; review GPT-6.1 Sol.

🤖 Generated with Claude Code

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

    2. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved at 66d551e

      Macroscope's review found this PR approvable — This is a narrowly scoped server bug fix that reports terminal answer-delivery failures without changing successful delivery, retry, interruption, request, or run behavior. The additive internal command is backward-compatible, and comprehensive integration coverage exercises the production worker and orchestrator paths.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. juliusmarminge added labelsmacroscope-review

    4. juliusmarminge closed this

    5. juliusmarminge added labelstriage:keep-open

    6. juliusmarminge reopened this

    7. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration
      • Configuration used: Path: .coderabbit.config.ts
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: 331ce7a5-4554-4e67-a291-9b5dfabad13e
      📥 Commits

      Reviewing files that changed from the base of the PR and between cd63e558f85d2c9313c8a1d5b5ac617df19994a0 and 0ce95ada4b0adbb25534529d493e604c3651925c.

      📒 Files selected for processing (4)
      • apps/server/src/orchestration-v2/EffectWorker.ts
      • apps/server/src/orchestration-v2/Orchestrator.ts
      • apps/server/src/orchestration-v2/RuntimeRequestDelivery.integration.test.ts
      • packages/contracts/src/orchestrationV2.ts

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

      📝 Walkthrough

      The change adds a server-only command to record failed runtime-request answer delivery. After response attempts are exhausted, the worker can dispatch the command, and the orchestrator can append a failed transport_error turn item.

      Changes: Runtime request delivery failure

      Layer / File(s)Summary
      Define and record delivery failures
      packages/contracts/src/orchestrationV2.ts, apps/server/src/orchestration-v2/Orchestrator.ts
      The internal command includes command, thread, and request IDs. The orchestrator routes the command and appends a failed error turn item when the request and its node exist. It records the item for detached sessions and does nothing if either is missing.
      Dispatch after exhausted response attempts
      apps/server/src/orchestration-v2/EffectWorker.ts, apps/server/src/orchestration-v2/RuntimeRequestDelivery.integration.test.ts
      The worker dispatches the command after a final non-interrupt failure when no retry is pending. It uses a stable command ID and logs a warning if failure recording fails. Integration tests cover bound and detached sessions, retry counts, replay, and preservation of the resolved answer.

      Priority: ➖ Normal

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

      Change: Bug fix

      Sequence Diagram(s)

      sequenceDiagram
        participant ProviderAdapter
        participant EffectWorker
        participant Orchestrator
        ProviderAdapter->>EffectWorker: Return response failure
        EffectWorker->>Orchestrator: Dispatch delivery-failure command after final attempt
        Orchestrator->>Orchestrator: Append failed error turn item when request and node exist

      Suggested reviewers: t3dotgg, juliusmarminge

      Merge Risk: ⚪ Minimal · up to 0ce95

      Failed answer delivery is reported after retries are exhausted, with no identified issue requiring a fix before merge.

      Security Architecture Review

      Security architecture risk: 🔵 Low · up to 0ce95

      The change adds a failure notice without granting clients new permissions or automatically resending an answer. Recovery during server or storage failures remains only partially demonstrated.

      Retained concerns No architecture-level concerns identified.

      Security review details

      Security Blast Radius

      • inferred — The new mutation is bounded to timeline state for the originating thread's request node. The inspected path introduces no arbitrary target-node selection, credential access or additional provider authority; wider deployment exposure is not established by this evidence.

      Trust Boundaries and Controls

      • observed — The inspected external dispatch route retains the client-command boundary. Internally, the worker supplies identifiers from its persisted effect, and projection queries bind request, node and optional session context to the same thread rather than trusting a command-supplied node.

      Resilience and Maintainability Implications

      • observed — Failure visibility is best effort, not an atomic delivery-and-reporting guarantee. Recording errors are logged while the exhausted response effect can become failed. Missing request/node context emits no timeline event and is rejected by the outer dispatch path. Existing process-loss reconciliation also cancels process-bound runtime responses without invoking this notice. These limitations do not establish a worsened approval boundary.

      Hardening Proposals

      • proposed — If durable failure visibility is required, give reporting independent recovery ownership and test persistence failure and process interruption. Recovery should replay only the notice, never automatically redeliver an uncertain approval or reopen the request.
      Pre-merge checks: Passed 4
      Passed Passed checks: 4 passed
      Check nameStatusExplanation
      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.
      Title checkPassedThe title clearly and concisely describes the main change: showing when answer delivery to the provider fails.
      Description checkPassedThe description is complete and relevant. It includes the problem, implementation, scope boundaries, detailed verification results, limitations, and agent attribution. The required Scope and approval …
      ✨ Finishing Touches 💡 1
      🛠️ Fix failing CI checks 💡
      • Commit to this branch
      • Create a new PR
      🧪 Generate unit tests (beta)
      • Create a new PR
      • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Comment `@coderabbitai help` to get the list of available commands.
    8. Review requested

      Date (UTC)ReviewerWhere
      2026-10-03JuliusDiscord DM
      Logged so this PR shows when a maintainer was asked to review it.
    9. Review requested

      Date (UTC)ReviewerWhere
      2026-10-06JuliusDiscord DM
      Logged so this PR shows when a maintainer was asked to review it.
    10. juliusmarminge assignedjuliusmarminge

    11. Taking over this one. I’ll reduce the tests to the useful coverage, update the implementation against current main, and verify it before publishing the changes.

    12. juliusmarminge added labelstakeover

    13. juliusmarminge added labelspr:in-progress

    14. Taking over this one

    15. Thank you @saphid for diagnosing the silent answer-delivery failure and establishing the conservative reporting behavior. Rebuilt on current main in #24616, since the takeover is maintained on origin rather than your fork.

      The replacement retains the final-attempt notice, saved-answer/request semantics and detached-session handling, uses the existing module tests instead of the standalone adapter fixture, and adds real isolated-server question/approval recordings plus an independent proof audit. I compared the original diff against the replacement; no intended behavior was omitted. Interruption, replay and detached/null-run cases are covered by the internal harness. Your original description and credit are preserved in the replacement.

    16. juliusmarminge closed this

    17. juliusmarminge removed labelspr:in-progress

Sign in to join this conversation.