Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): settling a parent cancels its delegated child's armed usage-limit resume #30175

Openjuliusmarmingewants to merge 9 commits intomain fromrefs/pull/30175/headopened View on GitHub

juliusmarmingecommented

Problem

A delegated child that fails on a usage limit while its parent is open gets an auto-resume armed for its reset. If the parent is settled before the reset, the armed resume still runs the child, and the child's delegated-completion wake reopens the settled parent and starts a new run on it. https://git.cafe/pingdotgg/t3code/pulls/27951 only stopped new arms for children of settled parents; an already-armed resume still fired. Reproduced on main (cefb544af3) with the runtime test below, through the real orchestrator.

Change

The usage-limit continuation guard in Orchestrator.dispatchMessage now also refuses a resume when the thread is a subagent whose direct parent is settled. The parent row is read only for subagents, only on this path, and inside the child's serialized dispatch, so a parent settled after the sweep read it is covered.

When the refused command still matches the thread's armed recovery (same run and request id), the refusal retires it: autoResume: false with a fresh request id, the same state as "Cancel auto-resume". Reopening the parent later does not revive it, and the sweep has nothing left to offer for that thread. A stale resume whose request id no longer matches (the user re-armed in the meantime) takes the existing no-op path, so it never overwrites a newer choice. If the parent is reopened before the reset, the child resumes as before.

The user guide's usage-limit section now says a delegated task's continuation is cancelled if its parent is still settled when the reset arrives.

Scope and approval

Fixes pingdotgg/t3code#30144

Triaged via the automated issue flow.

Verification

Server-only change with no visible surface, so no captures. Proof is one regression in runtimeLayer.test.ts, "retires a usage-limited subagent resume once its parent settles", through the real orchestrator: child armed while the parent is open → parent settled → reset passes → the sweep's resume is dispatched. It asserts no new child run, the parent still settled, the recovery disarmed; that unsettling the parent afterwards yields no limit-resume: and no limit-arm:; that re-dispatching the same saved resume does not leave the child armed but stuck; and that a stale resume after an explicit re-arm leaves the user's recovery untouched.

Red with main's Orchestrator.ts (the child starts a second run):

FAIL  runtimeLayer.test.ts > usage-limit recovery > retires a usage-limited subagent resume once its parent settles
AssertionError: expected [ { …(16) }, { …(16) } ] to have a length of 1 but got 2

Green at this head:

vp test run runtimeLayer.test.ts -t "limit"                            Tests  21 passed | 92 skipped (113)
vp test run ProjectionStore.test.ts UsageLimitRecoveryWorker.test.ts   Tests  56 passed (56)
vp run check:changed                                                    passed (format, lint, knip, typecheck, tests)

Not checked: a live provider hitting a real usage limit through child completion and parent wake (no test environment can trigger a real Claude limit), and the reporter's macOS desktop build. The change is server-side and platform-independent. Delegation to a linked environment uses a different lineage and is not covered by this change (the same scope as https://git.cafe/pingdotgg/t3code/pulls/27951).

Claude Opus 5.5 (Claude Code in T3 Code), with reviews by GPT-6.1 Sol (Codex) and Claude Opus 5.5.

🤖 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 941a497

      Macroscope's review found this PR approvable — Settled parent threads now prevent delegated usage-limit continuations from restarting, and matching scheduled resumes are cancelled to prevent replay. The change is confined to automatic recovery of explicitly settled work; manual continuation and product defaults remain unchanged.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Explain Change →

      No actionable comments were generated in the recent review.

      Walkthrough

      The usage-limit continuation path now rejects a delegated child’s resume when its parent is settled. For a matching recovery, it disables autoResume and updates the recovery request ID. Tests cover the rejected continuation, and the thread sidebar documents the cancellation behavior.

      Changes: Delegated usage-limit continuation

      Layer / File(s)Summary
      Parent settlement check and recovery handling
      apps/server/src/orchestration-v2/Orchestrator.ts, apps/server/src/orchestration-v2/runtimeLayer.test.ts, docs/user/thread-sidebar.md
      The orchestrator checks whether a delegated child’s parent is settled before accepting a usage-limit continuation. If a matching recovery is rejected for this reason, it disables autoResume and updates the request ID. The test verifies that the child does not restart after the parent is unsettled and the original command is retried. The sidebar guidance describes cancellation of the continuation.

      Estimated code review effort: 2 (Simple) | ~12 minutes

      Change: Bug fix · Severity of issue fixed: Medium

      Possibly related PRs

      Suggested reviewers: t3dotgg, maria-rcks, fixfon

      Merge Risk: Minimal · up to 941a4

      Delegated usage-limit continuations are cancelled when the parent remains settled at reset. No actionable risk introduced by this change remains.

      Pre-merge checks: Passed 4

      Check nameStatusExplanation
      Title checkPassedThe title clearly and concisely describes the main change: cancelling an armed usage-limit resume when the parent is settled.
      Description checkPassedThe description covers the problem, change, linked issue, and focused verification. The Scope and approval section does not state explicit maintainer approval or explain why the fix qualifies without …
      Linked Issues checkPassedIssue #30144 requires an armed usage-limit resume to be cancelled or skipped when its delegated child’s direct parent is settled, while the parent stays settled. In Orchestrator.dispatchMessage, the…
      Out of Scope Changes checkPassedThe changes to Orchestrator.ts, runtimeLayer.test.ts, and docs/user/thread-sidebar.md implement, test, and document issue #30144. No unrelated change appears in the whole-PR diff.
      Full details: Description check

      Explanation

      The description covers the problem, change, linked issue, and focused verification. The Scope and approval section does not state explicit maintainer approval or explain why the fix qualifies without it, but the rest is substantially complete.

      Full details: Linked Issues check

      Explanation

      Issue #30144 requires an armed usage-limit resume to be cancelled or skipped when its delegated child’s direct parent is settled, while the parent stays settled. In Orchestrator.dispatchMessage, the usage-limit continuation path checks the direct parent for subagents and rejects the continuation if that parent is settled. If the recovery still matches the run and request IDs, the handler disables autoResume and replaces the request ID. The regression in runtimeLayer.test.ts verifies that the child does not start another run, the parent stays settled, later reopening does not restore the recovery, and replay does not start the child. The documentation describes the cancellation behavior. Linked-environment delegation is outside the issue’s stated scope.

      Finishing Touches

      Generate docstrings

      • Commit to this branch
      • Create a new PR
      Generate unit tests (beta)

      • Commit to this branch
      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

      Usage-based review receipt

      Note

      This review was completed with usage-based billing: files reviewed beyond your plan's included limits are billed at $0.25/file. View usage-based billing.

      Recent review info

      Run configuration

      Commits

      Reviewing files that changed from the base of the PR and between 0b048fa480d46da8c4c23114f9b01bbcc37f6a9d and 941a497b8e7e8f25e144903b9c407ca7ea837676.

      Files selected for processing: 3

      • apps/server/src/orchestration-v2/Orchestrator.ts
      • apps/server/src/orchestration-v2/runtimeLayer.test.ts
      • docs/user/thread-sidebar.md

      Limit details: You’ve used all 10 included reviews currently available.

      • Fix comments: Fix CodeRabbit comments on this PR
    4. github-actions[bot](GitHub profile, opens in a new tab)commented

      Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ℹ️ The exact PR base did not have a successful artifact. Baseline uses the latest successful main measurement shown below.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      CodexLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      CodexLive turn WebSocket decoded21.5 KiB21.5 KiB0 B (0.0%)24.4 KiB✅
      CodexLive turn messages110 (0.0%)8✅
      ClaudeTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      ClaudeLive turn WebSocket decoded21.9 KiB21.9 KiB0 B (0.0%)24.4 KiB✅
      ClaudeLive turn messages110 (0.0%)8✅

      Baseline: d91915d · PR result: 941a497 · Source CI: success

      Scenario and decoded snapshot size

      10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

      • Codex decoded thread snapshot: 108.5 KiB
      • Claude decoded thread snapshot: 108.8 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    5. juliusmarminge added labelsbugfix

    6. juliusmarminge added labelspr:gate-failed

    7. The automated pipeline stopped on this pull request and will not merge it:

      the proof has no capture anyone can open:

      • Permanent blocker: first-party Claude OAuth usage-limit and renewal flows are unavailable on this VM, preventing the prescribed reproduction on both commits.
      • Unverified: the base dispatches the armed child recovery and its completion reopens the settled parent.
      • Unverified: the head keeps the child stopped, cancels its matching recovery, and keeps the parent settled.
      • Unverified: reopening the parent does not revive the cancelled recovery.
      • No captures exist, so no ghdrop upload was attempted and no public evidence URLs are available.

      It stays open for a person to finish or close.

    8. tanstack-source added labelsbug

Sign in to join this conversation.