Skip to content

[Bug]: Declined delegated-completion steer permanently drops wakeup because steer-follow-up is rejected by isUndeliveredMailboxSteer #41509

Closed

Description

@avanturist888

Summary

When a provider adapter declines an active-run steer (ProviderAdapterSteerDeclinedError, wrapped as steerDeclined: true) for a delegatedCompletion wakeup while the parent run is still running, EffectWorker's command:steer-follow-up:... fallback (dispatchMode: "queue_after_active") is permanently rejected by Orchestrator.ts with "Delegated completion delivery is no longer dispatchable.". All retries then fail with OrchestratorCommandPreviouslyRejectedError, the outbox effect dies in status: "failed", and the parent thread never receives the delegated-task completion wakeup.

This was hit 3 times on T3 Code 0.1.11 with Antigravity continuation turns (whose steerDeclined trigger was later removed in #39767), and the underlying orchestrator bug is still present on main for any adapter that raises ProviderAdapterSteerDeclinedError (e.g. packages/provider-cursor/src/server/adapter.ts).

Root Cause (verified on main)

  1. A delegated child completes while the parent run is running on a provider advertising supportsActiveSteering.
  2. Orchestrator.ts promotes the delegatedCompletion message.dispatch to steer_active, persists the steering message on the active parent run, and enqueues a provider-turn.steer outbox effect.
  3. ProviderTurnControlService.steer catches ProviderAdapterSteerDeclinedError and wraps it with steerDeclined: true.
  4. apps/server/src/orchestration-v2/EffectWorker.ts catches error.steerDeclined === true and dispatches command:steer-follow-up:<effect.id> (message.dispatch, dispatchMode: { type: "queue_after_active" }, steerFollowUpOfRunId: run.id, reusing message.id and delegatedCompletion).
  5. Bug 1 (apps/server/src/orchestration-v2/Orchestrator.ts:7712-7719 & NotificationMailbox.ts):
    (projection.messages.some((candidate) => candidate.id === command.messageId) &&
      !isUndeliveredMailboxSteer(projection, command.messageId))
    isUndeliveredMailboxSteer only returns true if run.status is terminal (completed | failed | interrupted | cancelled | rolled_back) or the latest provider turn is completed. Because steerDeclined happens while the parent run and turn are still running, isUndeliveredMailboxSteer returns false, and command:steer-follow-up:... is rejected with:
    Delegated completion delivery is no longer dispatchable.
    Subsequent outbox retries (attempts 2–5) replay the rejected receipt (OrchestratorCommandPreviouslyRejectedError), leaving the effect failed and the wakeup permanently dropped.
  6. Bug 2 (apps/server/src/orchestration-v2/Orchestrator.ts:7787-7800):
    Even if command.steerFollowUpOfRunId !== undefined passes the check at line 7713, the active-steer promotion block at lines 7787–7800 does not guard command.steerFollowUpOfRunId === undefined, so a steer-follow-up for a delegatedCompletion with completionWake === "always" would immediately be re-promoted from queue_after_active back to steer_active on the same running turn that just declined the steer.

Expected Behavior

  • When command.steerFollowUpOfRunId !== undefined (the steerDeclined fallback for a persisted steering message on a still-running run), Orchestrator.ts should allow reusing command.messageId for delegatedCompletion delivery (consistent with the guard at lines 7217–7228) instead of rejecting it via isUndeliveredMailboxSteer.
  • A steerFollowUpOfRunId dispatch must stay queue_after_active and not be re-promoted into steer_active at lines 7787–7800.

Observed Evidence (T3 Code 0.1.11, Windows x64)

  • orchestration_command_receipts: all 3 command:steer-follow-up:effect:command:fixture:delegated-completion:dispatch:... commands recorded status = 'rejected' (Failed to dispatch orchestration command message.dispatch), while user-sent steer-follow-up commands on the same threads were accepted.
  • orchestration_v2_effect_outbox: provider-turn.steer reached status = 'failed', attempt_count = 5, cause: OrchestratorCommandPreviouslyRejectedError.
  • Parent run completed later with delegatedCompletion.disposition = "open" and no queued follow-up run; the parent remained idle until manual intervention.

Related

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions