Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): t3_thread_read keeps a usage-limit failure's class and reset time #35380

Openjuliusmarmingewants to merge 3 commits intomain fromrefs/pull/35380/headopened View on GitHub

juliusmarmingecommented

t3_thread_read turned an error turn item into text using only failure.message, and the MCP thread detail did not include the shell's lastErrorClass and usageLimitResetAt. An MCP client could not tell a usage limit, or when it resets, from any other failed turn. In packages/contracts/src/orchestratorMcp.ts, OrchestratorMcpThreadTimelineItem gets an optional failure (the existing OrchestrationV2ProviderFailure schema: class, message, code, retryable, resetAt). OrchestratorMcpThreadDetail gets optional lastErrorClass and usageLimitResetAt, typed the same as the thread shell's fields. In OrchestratorMcpService, timelineItem() now passes item.failure through for error items, and threadDetail() copies lastErrorClass and usageLimitResetAt from the shell it already receives (null when absent). Existing fields are unchanged and nothing visible in the app changes. No regex or parser was added.

Fixes pingdotgg/t3code#35270

Reproduction on main

Commit fd8e386f7f (origin/main). No usage-limited provider account is available, so I used the existing usage-limit integration harness from TaskCancelUsageLimit.integration.test.ts (real OrchestratorV2, effect worker, projections and OrchestratorMcpService, fake provider adapter) in a scratch test. I created a parent thread, delegated a child, and had the provider fail the child's turn with failure { class: 'usage_limit', resetAt: now+1min }, then called OrchestratorMcpService.readThread on the child with the default view and with view 'activity'. Observed: the stored error item has failure { class: 'usage_limit', code: null, retryable: null, resetAt: '1970-01-01T00:01:00.000Z', message }. The activity view's error item has only type 'error', status 'failed', title 'Usage limit reached', text 'Claude usage limit reached.' and ids, with no class and no resetAt. The default view returned no error item. The thread object in both views had no lastErrorClass or usageLimitResetAt. I then added one failing test to apps/server/src/mcp/OrchestratorMcpService.activity.test.ts. It fails on main (thread lacks lastErrorClass/usageLimitResetAt); the other 6 tests in the file pass.

Evidence

Being captured: before and after in the real app. This section is filled in before the pull request can merge.

Tests

Without the fix, vp test run src/mcp/OrchestratorMcpService.activity.test.ts (apps/server) fails 1 of 7 tests, the repro test. With the fix, vp test run src/mcp/ (apps/server) passes 26 files and 364 tests. vp run check:changed passes format, lint, knip, graphql, typecheck (37 packages) and tests (4 files, 81 tests).

Not in this change

  • The reporter saw t3_thread_read's default view return no error item at all; only the activity view shows it. This looks like deliberate view filtering and was not changed.
  • The thread detail does not include the shell's lastErrorCode; the error item's failure.code already carries the code.

AI-assisted; verified with the tests and tools listed above.

    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 1ca6f55

      Macroscope's review found this PR approvable — Thread-read responses now preserve structured failure details and usage-limit reset times for MCP clients. The change adds metadata without altering execution, permissions, persistence or default views.

      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

      MCP thread details now expose the last error class and usage-limit reset time. Error timeline items now include typed failure details without duplicating the failure message. Tests cover the usage-limit response and update an error-item fixture.

      Changes: MCP thread failure details

      Layer / File(s)Summary
      Add typed failure fields to thread responses
      packages/contracts/src/orchestratorMcp.ts, apps/server/src/mcp/OrchestratorMcpService.ts, apps/server/src/mcp/OrchestratorMcpService.activity.test.ts, apps/server/src/peer/RemoteDelegation.test.ts
      Thread detail includes nullable lastErrorClass and usageLimitResetAt fields. Error timeline items include failure details without the message, which remains in the item text. Tests check usage-limit details and use a complete failure record in the remote-delegation fixture.

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

      Change: Bug fix · Severity of issue fixed: Medium

      Possibly related issues

      • Issue 31057: This PR exposes failure class and reset time through MCP. It does not address the issue’s other requests.
      • Issue 33247: This PR exposes the thread failure fields through MCP. It does not fix the incorrect Pi failure classification described in the issue.

      Suggested labels: bugfix

      Suggested reviewers: t3dotgg, maria-rcks

      Merge Risk: Minimal · up to 1ca6f

      This change adds typed failure details to MCP thread reads. The new fields are optional and existing fields are unchanged, so no actionable merge risk remains.

      Pre-merge checks: Passed 4

      Check nameStatusExplanation
      Title checkPassedThe title names the fix and the affected surface: t3_thread_read keeps a usage-limit failure's class and reset time. The changeset adds failure, lastErrorClass, and usageLimitResetAt to the MCP thread…
      Description checkPassedThe description follows the template's main sections: Problem, Change, Scope, Verification, and an AI-assistance note. The Problem and Change sections are clear and specific. Scope links issue #35270 …
      Linked Issues checkPassed[#35270] The issue asks that MCP clients identify a usage-limit failure and its reset time through typed fields, without parsing message text. The PR implements the first accepted option and also the …
      Out of Scope Changes checkPassedThe changed files are: the MCP service (lastErrorClass and usageLimitResetAt on thread detail; failure on error timeline items; effect/Struct import), the MCP contract (matching optional field…
      Full details: Title check

      Explanation

      The title names the fix and the affected surface: t3_thread_read keeps a usage-limit failure's class and reset time. The changeset adds failure, lastErrorClass, and usageLimitResetAt to the MCP thread read output, which matches. It is a conventional commit title in plain language and is specific enough for a teammate scanning history.

      Full details: Description check

      Explanation

      The description follows the template's main sections: Problem, Change, Scope, Verification, and an AI-assistance note. The Problem and Change sections are clear and specific. Scope links issue #35270 as the bug. Verification gives focused test commands and observed results, and it states what was not checked. The Evidence section says before/after captures are pending and that the section must be filled before merge. The template asks for before/after screenshots for UI changes. This change is not a UI change, so the pending capture is not a required gap, but the placeholder should be removed or completed before merge.

      Full details: Linked Issues check

      Explanation

      [#35270] The issue asks that MCP clients identify a usage-limit failure and its reset time through typed fields, without parsing message text. The PR implements the first accepted option and also the second.

      (1) Error timeline items: packages/contracts/src/orchestratorMcp.ts adds optional failure to OrchestratorMcpThreadTimelineItem, typed as OrchestrationV2ProviderFailure with message omitted. apps/server/src/mcp/OrchestratorMcpService.ts timelineItem() sets failure: Struct.omit(item.failure, ["message"]) when item.type === "error". The client receives class, code, retryable and resetAt. The message stays in text. This matches the issue's example failure: { class, code, resetAt }.

      (2) Thread object: OrchestratorMcpThreadDetail adds optional nullable lastErrorClass and usageLimitResetAt. threadDetail() copies them from the thread shell with ?? null.

      The PR description says the failure schema includes message. The code omits it. This is a documentation mismatch only. The issue does not require message in the typed failure, and text still carries it.

      The Evidence section of the PR description is pending. It is documentation, not a coding requirement. The regression test is reported by the author as failing on main and passing with the fix. I did not run the tests. The typecheck result reported by the author is consistent with Struct.omit applying to a non-null failure value, but I did not confirm the nullability of error item failure in the schema.

      Full details: Out of Scope Changes check

      Explanation

      The changed files are: the MCP service (lastErrorClass and usageLimitResetAt on thread detail; failure on error timeline items; effect/Struct import), the MCP contract (matching optional fields and imports), the activity test file (one regression test for usage-limit failure fields), and packages/contracts-independent fixture apps/server/src/peer/RemoteDelegation.test.ts. The RemoteDelegation fixture change gives error timeline items a complete failure record (class, message, code, retryable). It supports the new error item shape and is connected to #35270. The PR description does not mention this file. The default view's error-item filtering is unchanged, as the PR description states. No parser, UI change, or unrelated behavior change was found.

      Finishing Touches

      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 1c79e5dd1598155c0e4c1747db8c2b05e83bf743 and 1ca6f55154e7b191d5ac75aee2d3e39bd8f891c8.

      Files selected for processing: 3

      • apps/server/src/mcp/OrchestratorMcpService.ts
      • apps/server/src/peer/RemoteDelegation.test.ts
      • packages/contracts/src/orchestratorMcp.ts

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

    4. github-actions[bot](GitHub profile, opens in a new tab)commented

      Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      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✅

      Other scenarios

      All 64 scenario measurements match main.

      All 64 scenario measurements
      ProviderScenarioMetricMain baselineThis PRImpactPR ceiling
      Codexshort turn resumeWebSocket decoded10.5 KiB10.5 KiB0 B (0.0%)12.7 KiB✅
      Codexshort turn resumeWebSocket messages220 (0.0%)2✅
      Codexlong turn running, cold openHTTP decoded281.7 KiB281.7 KiB0 B (0.0%)302.7 KiB✅
      Codexlong turn running, cold openrows75750 (0.0%)75✅
      Codexlong turn running, history pageHTTP decoded92.4 KiB92.4 KiB0 B (0.0%)107.4 KiB✅
      Codexlong turn running, history pagerows75750 (0.0%)75✅
      Codexlong turn finished, cold openHTTP decoded381.5 KiB381.5 KiB0 B (0.0%)410.2 KiB✅
      Codexlong turn finished, cold openrows1511510 (0.0%)151✅
      Codexlong turn finished, socket cold openWebSocket decoded381.6 KiB381.6 KiB0 B (0.0%)410.2 KiB✅
      Codexlong turn finished, socket cold openWebSocket messages220 (0.0%)2✅
      Codexlong turn finished, socket cold openrows1511510 (0.0%)151✅
      Codexlong turn finished, work pageHTTP decoded186.2 KiB186.2 KiB0 B (0.0%)200.2 KiB✅
      Codexlong turn finished, work pagerows1501500 (0.0%)150✅
      Codexidle thread resumeWebSocket decoded65 B65 B0 B (0.0%)200 B✅
      Codexidle thread resumeWebSocket messages110 (0.0%)1✅
      Codexfleet shell snapshotHTTP decoded41.6 KiB41.6 KiB0 B (0.0%)53.7 KiB✅
      Codexfleet shell snapshotrows27270 (0.0%)27✅
      Codexfleet shell subscribeWebSocket decoded65 B65 B0 B (0.0%)200 B✅
      Codexfleet shell subscribeWebSocket messages110 (0.0%)1✅
      Codexfleet shell resume checkHTTP decoded18 B18 B0 B (0.0%)100 B✅
      Codexfleet shell resume checkrows0000✅
      Codexstale shell reloadHTTP decoded41.6 KiB41.6 KiB0 B (0.0%)53.7 KiB✅
      Codexstale shell reloadrows27270 (0.0%)27✅
      Codexstale shell resumeWebSocket decoded140 B140 B0 B (0.0%)400 B✅
      Codexstale shell resumeWebSocket messages220 (0.0%)2✅
      Codexstale todo list cold openHTTP decoded72.4 KiB72.4 KiB0 B (0.0%)83.0 KiB✅
      Codexstale todo list cold openrows75750 (0.0%)75✅
      Codexstale todo list cold opennodes220 (0.0%)4✅
      Codexstale todo list cold opensubagents220 (0.0%)4✅
      Codexstale todo list cold openplans110 (0.0%)2✅
      Codexstale todo list cold openproviderTurns110 (0.0%)2✅
      Codexstale todo list cold opencheckpoints110 (0.0%)2✅
      Claudeshort turn resumeWebSocket decoded10.6 KiB10.6 KiB0 B (0.0%)12.7 KiB✅
      Claudeshort turn resumeWebSocket messages220 (0.0%)2✅
      Claudelong turn running, cold openHTTP decoded283.3 KiB283.3 KiB0 B (0.0%)302.7 KiB✅
      Claudelong turn running, cold openrows75750 (0.0%)75✅
      Claudelong turn running, history pageHTTP decoded93.4 KiB93.4 KiB0 B (0.0%)107.4 KiB✅
      Claudelong turn running, history pagerows75750 (0.0%)75✅
      Claudelong turn finished, cold openHTTP decoded384.2 KiB384.2 KiB0 B (0.0%)410.2 KiB✅
      Claudelong turn finished, cold openrows1511510 (0.0%)151✅
      Claudelong turn finished, socket cold openWebSocket decoded384.3 KiB384.3 KiB0 B (0.0%)410.2 KiB✅
      Claudelong turn finished, socket cold openWebSocket messages220 (0.0%)2✅
      Claudelong turn finished, socket cold openrows1511510 (0.0%)151✅
      Claudelong turn finished, work pageHTTP decoded188.1 KiB188.1 KiB0 B (0.0%)200.2 KiB✅
      Claudelong turn finished, work pagerows1501500 (0.0%)150✅
      Claudeidle thread resumeWebSocket decoded66 B66 B0 B (0.0%)200 B✅
      Claudeidle thread resumeWebSocket messages110 (0.0%)1✅
      Claudefleet shell snapshotHTTP decoded42.2 KiB42.2 KiB0 B (0.0%)53.7 KiB✅
      Claudefleet shell snapshotrows27270 (0.0%)27✅
      Claudefleet shell subscribeWebSocket decoded66 B66 B0 B (0.0%)200 B✅
      Claudefleet shell subscribeWebSocket messages110 (0.0%)1✅
      Claudefleet shell resume checkHTTP decoded18 B18 B0 B (0.0%)100 B✅
      Claudefleet shell resume checkrows0000✅
      Claudestale shell reloadHTTP decoded42.2 KiB42.2 KiB0 B (0.0%)53.7 KiB✅
      Claudestale shell reloadrows27270 (0.0%)27✅
      Claudestale shell resumeWebSocket decoded140 B140 B0 B (0.0%)400 B✅
      Claudestale shell resumeWebSocket messages220 (0.0%)2✅
      Claudestale todo list cold openHTTP decoded73.4 KiB73.4 KiB0 B (0.0%)83.0 KiB✅
      Claudestale todo list cold openrows75750 (0.0%)75✅
      Claudestale todo list cold opennodes220 (0.0%)4✅
      Claudestale todo list cold opensubagents220 (0.0%)4✅
      Claudestale todo list cold openplans110 (0.0%)2✅
      Claudestale todo list cold openproviderTurns110 (0.0%)2✅
      Claudestale todo list cold opencheckpoints110 (0.0%)2✅

      Baseline: 4e48d9e · PR result: 1ca6f55 · 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. The automated pipeline stopped on this pull request and will not merge it:

      the fix is written and reviewed, but proving it needs something no worker has:

      • Permanent blocker: a usage-limited first-party Claude or ChatGPT OAuth account is needed for the live reproduction; neither is available on this VM. The brief prohibits working around unavailable provider access.
      • Typed failure fields in default and activity MCP reads remain unverified on both commits. Both verdict booleans are false because neither outcome was observed.

      It stays open for a person to finish or close.

    6. tanstack-source added labelsbug

Sign in to join this conversation.