Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): attribute usage-limit auto-resume to T3 Code #29838

Mergedshivamhwp(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/29838/headmerged by shivamhwp(GitHub profile, opens in a new tab) View on GitHub

Closes / Refs: Closes https://github.com/pingdotgg/t3code/issues/29746

What's fixed: Automatic usage-limit recovery now attributes its continuation to T3 Code. A resumed child thread still creates a tracked follow-up and delivers its completed result to its parent. Existing stored messages keep their attribution.

Evidence: These recordings use a synthetic quota failure and the real reset scheduler with a free replay provider.

Before, the web client on main automatically resumes after reset and shows the continuation without attribution.

https://github.com/user-attachments/assets/a4a99e61-b116-418b-87e5-8411b8c249e3

After, the web client on this PR shows the reset-triggered continuation as "Sent by T3 Code" and the replay completes.

https://github.com/user-attachments/assets/03554a0c-0fff-4062-99fe-31c091d35c00

After, web

After, native Android on a POCO M3 Pro shows selecting "Resume at reset", the automatic continuation labeled "Sent by T3 Code", and the completed replay.

https://github.com/user-attachments/assets/05a2e563-519a-4550-a776-d79209401d35

After, native Android

After, the Linux desktop app's reset scheduler starts a replay turn, labels the continuation "Sent by T3 Code", and completes the turn.

After, Linux desktop

https://github.com/user-attachments/assets/d632b080-55f2-4a44-b21c-8a4194450947

Delegated child recovery also passed on corex's isolated source server at 8b585884a7b8e388bcaa86a944373baaa965972a, on 2026-11-03 UTC. A free scripted ACP parent called the real scoped delegate_task MCP tool. Its child failed its first provider turn. With the server stopped, the existing error was given a synthetic usage_limit and future reset through EventSinkV2. After restart, the real scheduler armed and resumed the child. The child completed, the ordinary completion worker delivered its result, and the parent provider received and acknowledged it. The persisted follow-up task is delivered, with exactly one recovered-result message and one parent acknowledgement.

Corex server trace and runtime assertions for recovered-child delivery

Extracted fields from the isolated server's event log, projections and ACP process trace. parent and child below refer to the full thread IDs at the top. The initial failure and recovered completion each produced one consumed result transfer.

head 8b585884a7b8e388bcaa86a944373baaa965972a
environment corex / isolated source server / local scripted ACP provider
parentThreadId mcp:0bb574d6-f3ea-4f11-be4c-7094a54a1dde
childThreadId thread:delegated-task:command%3Amcp%3A3c8260f9-3138-426a-a53d-90b618b37567%3Adelegate-task%3A4fd23071-fb06-46bd-af79-59031475e5e6
original task and reset follow-up are distinct; resumed run.delegatedTaskId matches follow-up
fixture: initial ACP error, then usage_limit + resetAt written via EventSinkV2 with server stopped
resetAt 2026-11-03T02:59:07.691Z
2026-11-03T02:58:32.691Z seq=105 turn-item.updated {"thread":"child","failure":{"class":"usage_limit","message":"Synthetic quota reset fixture. No real provider quota consumed.","code":"usageLimitExceeded","retryable":null,"resetAt":"2026-11-03T02:59:07.691Z"}}
2026-11-03T02:58:46.717Z seq=108 thread.metadata-updated {"thread":"child","limitRecovery":{"requestId":"limit-arm:thread:delegated-task:command%3Amcp%3A3c8260f9-3138-426a-a53d-90b618b37567%3Adelegate-task%3A4fd23071-fb06-46bd-af79-59031475e5e6:run:thread:thread%3Adelegated-task%3Acommand%253Amcp%253A3c8260f9-3138-426a-a53d-90b618b37567%253Adelegate-task%253A4fd23071-fb06-46bd-af79-59031475e5e6:ordinal:1:1793674747691","runId":"run:thread:thread%3Adelegated-task%3Acommand%253Amcp%253A3c8260f9-3138-426a-a53d-90b618b37567%253Adelegate-task%253A4fd23071-fb06-46bd-af79-59031475e5e6:ordinal:1","resetAt":"2026-11-03T02:59:07.691Z","autoResume":true,"snooze":false}}
2026-11-03T02:59:11.367Z seq=110 run.created {"thread":"child","ordinal":2,"status":"starting"}
2026-11-03T02:59:11.367Z seq=114 message.updated {"thread":"child","text":"Continue where you left off.","createdBy":"agent","creationSource":"server"}
2026-11-03T02:59:11.367Z seq=116 run.updated {"thread":"child","ordinal":2,"status":"starting","hasFreshDelegatedTaskId":true}
2026-11-03T02:59:11.678Z seq=123 run.updated {"thread":"child","ordinal":2,"status":"running","hasFreshDelegatedTaskId":true}
2026-11-03T02:59:11.785Z seq=134 run.updated {"thread":"child","ordinal":2,"status":"waiting","hasFreshDelegatedTaskId":true}
2026-11-03T02:59:11.806Z seq=141 run.updated {"thread":"child","ordinal":2,"status":"completed","hasFreshDelegatedTaskId":true}
2026-11-03T02:59:11.949Z seq=153 message.updated {"thread":"parent","text":"(Quota reset delivery child) [completed]:\nCHILD_RESULT_29746: recovered delegated child finished successfully.","createdBy":"agent","creationSource":"server"}
2026-11-03T02:59:12.251Z seq=164 message.updated {"thread":"parent","text":"PARENT_ACK_29746: I received CHILD_RESULT_29746 from the recovered child.","createdBy":"agent","creationSource":"provider"}
2026-11-03T02:59:12.341Z seq=178 subagent.updated {"thread":"parent","status":"completed","result":"CHILD_RESULT_29746: recovered delegated child finished successfully.","completionDelivery":{"state":"delivered","observedByRunId":null}}
2026-11-03T02:59:12.246Z provider-process prompt received recovered result: true
ASSERT PASS: resumed child completed with a fresh parent-tracked task
ASSERT PASS: follow-up completionDelivery.state = delivered
ASSERT PASS: exactly 1 recovered-result server message in parent
ASSERT PASS: exactly 1 recovered-result prompt received by parent ACP process
ASSERT PASS: exactly 1 persisted PARENT_ACK_29746 response
ASSERT PASS: 2 consumed result transfers total: initial failure + recovered completion

CI for this head passed. The prior focused Boat run at this head passed check:changed, including 169 tests in 6 files, plus all 15 scripts/check-changed.test.ts tests. No code changed for this additional runtime verification.

Not shown: real provider quota exhaustion, live vendor-specific buffering, or iOS rendering.

Base compatibility was checked on physical corex on 2026-11-04 against main 647bd148b3fbd7c8b57a10fd41ae6d5fc7b35cc1, which includes the wake's 9aa80a0dc412eeee80d12a53d077c2e1cd8939e7. PR head remains 8b585884a7b8e388bcaa86a944373baaa965972a. The clean temporary merge has commit 98074430b21ee2d8ef351e558ffaef59df3d6961 and tree cf4ffbc32d5ea9dbfe3586a15eadd5dc34fc7a27; its diff from main is exactly this PR's four-file patch. No branch update or production edit was needed.

The source review found the attribution worker, shared attribution helper and conversation contracts unchanged. The combined revision passed 65 selected tests covering quota recovery, delegated completion and follow-ups, restart recovery, settled-parent eligibility, bounded SQL history and reader transactions. This also covers main's new message-ID lookup used by startup recovery and settlement. The existing web, Android and Linux captures remain evidence for the unchanged attribution path at PR head; the runtime trace above remains evidence for child delivery at that head.

Startup interruption before provider acceptance still cancels an automatic continuation, as it did before this base move. Main's new held-queue retention applies to user-authored messages. Extending automatic continuations' restart policy is outside this attribution fix.

Latest-base compatibility test output

Environment: physical corex, isolated source integration checkout, all four test files unmodified from the temporary merge above.

vp test run apps/server/src/orchestration-v2/DelegatedCompletionDelivery.test.ts apps/server/src/orchestration-v2/runtimeLayer.test.ts apps/server/src/orchestration-v2/ProviderRuntimeRecoveryService.test.ts apps/server/src/orchestration-v2/ProjectionStore.test.ts -t 'delegated completion|subagent follow-ups|delegated tasks across|usage-limit recovery|recovers .* work after restart|routes full projection reads|reads a fixed SQL turn-item window|does not freshly arm limit recovery'
Test Files  4 passed (4)
Tests  65 passed | 155 skipped (220)
Start at  03:26:34
Duration  37.39s (transform 60%, import 23%, tests 13%, setup 4%)

The earlier integration against main 059804dfdaba54bd6f997355c30e102dae20d3b4 also passed 65 focused tests. That run included delegated projection-index and recorded-follow-up recovery tests, plus two temporary restart-table rows comparing user/server and agent/server quota continuations. The user-authored row was held in the queue, and the agent-authored row, run attempt and root node were cancelled. The temporary fixture delta and its output are retained below so that check can be reproduced. The temporary checkout and fixtures were removed after verification.

vp test run apps/server/src/orchestration-v2/ProviderRuntimeRecoveryService.test.ts -t 'recovers .* work after restart'
Test Files  1 passed (1)
Tests  8 passed | 12 skipped (20)
diff --git a/apps/server/src/orchestration-v2/ProviderRuntimeRecoveryService.test.ts b/apps/server/src/orchestration-v2/ProviderRuntimeRecoveryService.test.ts
index d300cf59ca3..9fef4036d59 100644
--- a/apps/server/src/orchestration-v2/ProviderRuntimeRecoveryService.test.ts
+++ b/apps/server/src/orchestration-v2/ProviderRuntimeRecoveryService.test.ts
@@ -508,12 +508,15 @@ it.effect.each([
   "starting-other-request",
   "starting-own-request",
   "starting-scheduled",
+  "starting-usage-limit-agent",
+  "starting-usage-limit-user",
 ] as const)("recovers $0 work after restart", (scenario) => {
   const status = scenario.startsWith("starting") ? "starting" : scenario;
   const terminalized =
     status === "preparing" ||
     scenario === "starting-own-request" ||
-    scenario === "starting-scheduled";
+    scenario === "starting-scheduled" ||
+    scenario === "starting-usage-limit-agent";
   const threadId = ThreadId.make("thread_queued_restart");
   const runId = RunId.make("run_queued_restart");
   const attemptId = RunAttemptId.make("attempt_queued_restart");
@@ -544,6 +547,9 @@ it.effect.each([
         startedAt: null,
         activeAttemptId: attemptId,
         userMessageId: MessageId.make("message_queued_restart"),
+        ...(scenario.startsWith("starting-usage-limit")
+          ? { usageLimitContinuationOfRunId: RunId.make("failed-quota-run") }
+          : {}),
         queuePosition: 1,
         providerInstanceId: ProviderInstanceId.make("codex"),
         ...(status === "preparing"
@@ -587,7 +593,8 @@ it.effect.each([
         ? [
             {
               id: MessageId.make("message_queued_restart"),
-              createdBy: "user",
+              createdBy: scenario === "starting-usage-limit-agent" ? "agent" : "user",
+              ...(scenario.startsWith("starting-usage-limit") ? { creationSource: "server" } : {}),
               ...(scenario === "starting-scheduled" ? { scheduledTaskId: "scheduled-task" } : {}),
             },
           ]

Original verification output, recovered from fun's saved Boat job on 2026-11-04. These are the two runs already claimed above, not reruns.

  • Revision: 8b585884a7b8e388bcaa86a944373baaa965972a.
  • Environment: Boat Linux, VM bx_3mtx73ba, 8 CPUs, job j_5cgykciumokc2x5mq4ye, stage typecheck-package-29838, attempt 1.
  • Job started 2026-11-03T02:07:46.273Z, finished 2026-11-03T02:17:35.689Z, state succeeded, exit code 0.
  • Changed-file base: FLEET_SOURCE_BASE=65aaf972aef7de82721f52494ac224f803fd7be9, also printed in the command output below.
Original commands and passing output: 169 tests plus 15 script tests

The saved job command was bash -lc 'bash "$FLEET_INPUT_BUILDSCRIPT"'. Its original 297-byte input script was recovered and its SHA-256 verified as 25865e0d9615e6b8d11e05b35478afad4b6f9f86421726f5e64d4cd82e2a654a:

set -euo pipefail
vp i --frozen-lockfile
vp run check:changed "$FLEET_SOURCE_BASE"
vp test run scripts/check-changed.test.ts
vp run dist:desktop:artifact --platform linux --target dir --arch x64 --output-dir out/package
mkdir -p out
tar -C out/package -czf out/linux-desktop.tar.gz linux-unpacked

The saved worker log identifies the revision and input:

== fleet job j_5cgykciumokc2x5mq4ye attempt 1, typecheck-package-29838, 8b585884a7b8e388bcaa86a944373baaa965972a, fleet cbc0536eab88, 8 cpus
== source: 985 commits on top of the template's copy of pingdotgg/t3code at dac8b11ddc25
== input buildscript: sha256 25865e0d9615e6b8d11e05b35478afad4b6f9f86421726f5e64d4cd82e2a654a checked, 297 bytes at /tmp/fleet-job/j_5cgykciumokc2x5mq4ye/inputs/buildscript

Output from vp run check:changed "$FLEET_SOURCE_BASE", with ANSI colour codes removed:

$ node scripts/check-changed.ts 65aaf972aef7de82721f52494ac224f803fd7be9 ⊘ cache disabled
check:changed: 4 files since 65aaf972aef7 (65aaf972aef7de82721f52494ac224f803fd7be9)

> vp format  pass  0.9s
Checking formatting...

All matched files use the correct format.
Finished in 635ms on 4 files using 8 threads.

> vp lint  pass  1.3s
Found 0 warnings and 0 errors.
Finished in 1.1s on 4 files with 200 rules using 8 threads.

> vp knip 1/2  pass  19.7s

> vp graphql (apps/server)  pass  0.5s
~/apps/server$ graphqlgen --check ⊘ cache disabled

> vp knip 2/2  pass  29.3s

> vp typecheck (3 packages)  pass  15.7s
~/scripts$ tsc --noEmit
~/evals$ tsc --noEmit

~/apps/server$ tsc --noEmit


---
vp run: 0/3 cache hit (0%), 3/3 successful. @t3tools/scripts#typecheck not cached because it modified its inputs. (Run `vp run --last-details` for full details)

> vp test (6 files)  pass  29.6s

 RUN  v5.0.5 /tmp/fleet-job/j_5cgykciumokc2x5mq4ye/src

 ✓  t3  src/orchestration-v2/runtimeLayer.test.ts (112 tests) 2989ms
 ✓  t3  src/orchestration-v2/DelegatedCompletionDelivery.test.ts (35 tests) 888ms
 ✓  t3  src/orchestration-v2/Orchestrator.control-reads.test.ts (15 tests) 783ms
 ✓  t3  src/provider/AgentContextBudget.test.ts (1 test) 59ms
 ✓  t3  src/orchestration-v2/UsageLimitRecoveryWorker.test.ts (5 tests) 11ms
 ✓  t3  src/orchestration-v2/Orchestrator.migration.test.ts (1 test) 2ms

 Test Files  6 passed (6)
      Tests  169 passed (169)
   Start at  02:12:44
   Duration  24.54s (transform 48%, import 28%, tests 20%, setup 4%)

check:changed summary
  pass  format  0.9s
  pass  lint  1.3s
  pass  knip 1/2  19.7s
  pass  knip 2/2  29.3s
  pass  graphql (apps/server)  0.5s
  pass  typecheck (3 packages)  15.7s
  pass  test (6 files)  29.6s
  CI also runs: full test suites, build
  unused patch check skipped: no dependency files changed
  pass not cached: files changed during the run

Output from vp test run scripts/check-changed.test.ts, with ANSI colour codes removed:

 ✓  root  scripts/check-changed.test.ts (15 tests) 1551ms
   ✓ checks changed source paths through the Windows launcher 322ms
   ✓ lints an Astro component and runs knip when only it changed 440ms
   ✓ reports a failing install step with its output 314ms
   ✓ reports a failing lint step with its output 301ms

 Test Files  1 passed (1)
      Tests  15 passed (15)
   Start at  02:13:12
   Duration  6.71s (transform 66%, tests 25%, setup 7%, import 3%)

The full job finished successfully after both checks and the desktop package build. The original input and retained log agree with the pinned revision, job metadata and passing counts above.

The live ready check also reviewed main 8b44f42b14c8e273156474a924ccf29680dd7857. Since the integration check at 647bd148b3fbd7c8b57a10fd41ae6d5fc7b35cc1, main changed diff/file metadata, screen layout, status-row alignment and release versions. It did not change the quota worker, orchestration recovery, delegation or attribution helpers. The existing integration results and head recordings remain applicable; the PR still merges cleanly.

Implemented by Opus 5.5 in Claude Code; investigated, tested and reviewed by GPT-6.1 Sol in Codex through T3 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 a79834b

      Macroscope's review found this PR approvable — Usage-limit auto-resume messages are attributed to T3 Code while preserving existing subagent follow-up handling. Existing recovery settings and eligibility safeguards remain unchanged.

      No code changes detected at 8b58588. Prior analysis still applies.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. 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.3 KiB1.3 KiB0 B (0.0%)2.0 KiB✅
      CodexLive turn WebSocket decoded21.6 KiB21.6 KiB0 B (0.0%)24.4 KiB✅
      CodexLive turn messages220 (0.0%)8✅
      ClaudeTotal thread wire5.0 KiB5.0 KiB−18 B (−0.3%)6.8 KiB✅
      ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB−18 B (−1.4%)2.0 KiB✅
      ClaudeLive turn WebSocket decoded21.9 KiB21.9 KiB−41 B (−0.2%)24.4 KiB✅
      ClaudeLive turn messages21−1 (−50.0%)8✅

      Baseline: e0f69e9 · PR result: 8b58588 · 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.

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

      No actionable comments were generated in the recent review.

      Walkthrough

      Usage-limit recovery messages are now attributed to the agent. The orchestrator also accepts these continuations as delegated subagent follow-ups. Tests cover message attribution and parent-task tracking.

      Changes: Usage-Limit Follow-Ups

      Layer / File(s)Summary
      Agent attribution
      apps/server/src/orchestration-v2/UsageLimitRecoveryWorker.ts, apps/server/src/orchestration-v2/runtimeLayer.test.ts
      The recovery worker creates continuation messages as agent messages. The runtime test checks the message text, creator, and creation source.
      Delegated follow-up tracking
      apps/server/src/orchestration-v2/Orchestrator.ts, apps/server/src/orchestration-v2/DelegatedCompletionDelivery.test.ts
      Usage-limit continuations can qualify as subagent follow-ups. The test checks that a resumed child run has a delegated task ID and that its parent task references the child thread with no result.

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

      Change: Bug fix · Severity of issue fixed: Low

      Suggested reviewers: juliusmarminge

      Merge Risk: Minimal · up to a7983

      No actionable merge-blocking risk was identified.

      Pre-merge checks: Passed 4
      Check nameStatusExplanation
      Title checkPassedThe title clearly and concisely identifies the main change: attributing usage-limit auto-resume messages to T3 Code.
      Linked Issues checkPassedIssue [#29746] requires usage-limit auto-resume messages to use T3 Code attribution and preserve child follow-up tracking. UsageLimitRecoveryWorker.ts now sets createdBy: "agent" with `creationSou…
      Out of Scope Changes checkPassedThe changes stay within issue [#29746]. The production edits change usage-limit continuation attribution and preserve delegated child follow-up behavior. The added tests cover those behaviors. No unre…
      Description checkPassedThe description clearly explains the problem and change, links the related issue, documents scope limitations, and provides detailed verification results, recordings, test output, and known gaps. It u…
      Full details: Linked Issues check

      Explanation

      Issue [#29746] requires usage-limit auto-resume messages to use T3 Code attribution and preserve child follow-up tracking. UsageLimitRecoveryWorker.ts now sets createdBy: "agent" with creationSource: "server". runtimeLayer.test.ts verifies the stored continuation attribution. Orchestrator.ts permits usage-limit continuations as subagent follow-ups, and DelegatedCompletionDelivery.test.ts verifies parent tracking. No unmet coding requirement is evident.

      Full details: Out of Scope Changes check

      Explanation

      The changes stay within issue [#29746]. The production edits change usage-limit continuation attribution and preserve delegated child follow-up behavior. The added tests cover those behaviors. No unrelated production behavior or unrelated files are changed.

      Full details: Description check

      Explanation

      The description clearly explains the problem and change, links the related issue, documents scope limitations, and provides detailed verification results, recordings, test output, and known gaps. It uses custom headings instead of the template headings and does not include an explicit maintainer approval comment, but the required information is otherwise substantially present.

      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
      Recent review info
      Run configuration
      Commits

      Reviewing files that changed from the base of the PR and between 30b9c4a956a6c595fda5c8b2c439a6aaebc861b0 and a79834b8e2039f2c05d1af90e0cb65b196ba0b13.

      Files selected for processing: 4
      • apps/server/src/orchestration-v2/DelegatedCompletionDelivery.test.ts
      • apps/server/src/orchestration-v2/Orchestrator.ts
      • apps/server/src/orchestration-v2/UsageLimitRecoveryWorker.ts
      • apps/server/src/orchestration-v2/runtimeLayer.test.ts

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

Sign in to join this conversation.