Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): delegated completions wait behind a parent usage limit #41892

Closedzs-andy(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/41892/headopened View on GitHub

Problem

When a delegated subagent finishes while its parent thread is blocked on a provider usage limit, dispatchMessage sees no active run and starts the completion wake immediately. That new turn hits the same usage limit right away and replaces the latest failed run, which drops any armed auto-resume on the parent.

Fixes #41583.

Change

When an automatic delegated completion arrives with queue_after_active and no active run, Orchestrator.dispatchMessage now checks whether the target provider instance is currently blocked on a usage limit whose reset is still in the future (or already has armed auto-resume for that failed run). When it is, the wake is queued behind the limited run instead of starting immediately, keeping the parent's limitRecovery intact until the reset resumes the thread and drains the queue.

Scope

Bug fix for #41583, scoped to Orchestrator.ts and a focused regression test in DelegatedCompletionDelivery.test.ts.

Verification

  • Added a regression test in DelegatedCompletionDelivery.test.ts where a parent fails with usage_limit, arms auto-resume, receives a delegated completion before reset, and later resumes at reset: fails on main (wake starts immediately as "starting") and passes here (wake stays "queued", armed limitRecovery stays intact, and auto-resume dispatches cleanly at reset).
  • Ran DelegatedCompletionDelivery.test.ts (69/69 passed), usage-limit recovery tests in runtimeLayer.test.ts (31/31 passed), and vp run check:changed origin/main (format, lint, knip, graphql, and typecheck passed; two unrelated Orchestrator.control-reads.test.ts cases failed locally because Node v25.7.0 lacks statement.stat).

Written with Gemini 4 Neon in T3 Code.

    1. tanstack-source added labelsbug

    2. Looks like #41888 beat me to this by a few minutes and already covers the same fix (plus notification wakes) — closing this to avoid a duplicate.

    3. juliusmarminge added labelstakeover:in-progress

    4. juliusmarminge added labelstakeover:blocked

    5. juliusmarminge removed labelstakeover:in-progress

Sign in to join this conversation.