fix(server): t3_thread_read keeps a usage-limit failure's class and reset time #35380
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
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XS
Approvability#
Verdict: Approved at
1ca6f55Macroscope'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).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.tsThread detail includes nullable lastErrorClassandusageLimitResetAtfields. 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:
bugfixSuggested reviewers:
t3dotgg,maria-rcks
Merge Risk:
Minimal · up to1ca6f-
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:
4-
Check name Status Explanation Title check 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… Description check 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…Linked Issues check [ #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 check The changed files are: the MCP service ( lastErrorClassandusageLimitResetAton thread detail;failureon error timeline items;effect/Structimport), 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
#35270as 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
failureto OrchestratorMcpThreadTimelineItem, typed as OrchestrationV2ProviderFailure withmessageomitted. apps/server/src/mcp/OrchestratorMcpService.ts timelineItem() setsfailure: Struct.omit(item.failure, ["message"])whenitem.type === "error". The client receives class, code, retryable and resetAt. The message stays intext. This matches the issue's examplefailure: { class, code, resetAt }.(2) Thread object: OrchestratorMcpThreadDetail adds optional nullable
lastErrorClassandusageLimitResetAt. 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 requiremessagein the typed failure, andtextstill 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.omitapplying to a non-null failure value, but I did not confirm the nullability of error itemfailurein the schema.
Full details: Out of Scope Changes check
-
Explanation
The changed files are: the MCP service (
lastErrorClassandusageLimitResetAton thread detail;failureon error timeline items;effect/Structimport), the MCP contract (matching optional fields and imports), the activity test file (one regression test for usage-limit failure fields), and packages/contracts-independent fixtureapps/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#
- Mode: Continue automatically
- Reviewed files: 3
- Charged: $0.75
- View usage details
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-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: factory/issue-35270
- File: .coderabbit.config.ts
- Commit: 1ca6f55
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Team
- Run ID:
2a06c5f0-354c-4863-ae32-bb939cdd04ed
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.tsapps/server/src/peer/RemoteDelegation.test.tspackages/contracts/src/orchestratorMcp.ts
Limit details: You’ve used all 10 included reviews currently available.
-
-
Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Provider Metric Main baseline This PR Impact PR ceiling Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅ Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅ Codex Live turn WebSocket decoded 21.5 KiB 21.5 KiB 0 B (0.0%) 24.4 KiB ✅ Codex Live turn messages 1 1 0 (0.0%) 8 ✅ Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅ Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅ Claude Live turn WebSocket decoded 21.9 KiB 21.9 KiB 0 B (0.0%) 24.4 KiB ✅ Claude Live turn messages 1 1 0 (0.0%) 8 ✅ Other scenarios#
All 64 scenario measurements match
main.All 64 scenario measurements
Provider Scenario Metric Main baseline This PR Impact PR ceiling Codex short turn resumeWebSocket decoded10.5 KiB 10.5 KiB 0 B (0.0%) 12.7 KiB ✅ Codex short turn resumeWebSocket messages2 2 0 (0.0%) 2 ✅ Codex long turn running, cold openHTTP decoded281.7 KiB 281.7 KiB 0 B (0.0%) 302.7 KiB ✅ Codex long turn running, cold openrows75 75 0 (0.0%) 75 ✅ Codex long turn running, history pageHTTP decoded92.4 KiB 92.4 KiB 0 B (0.0%) 107.4 KiB ✅ Codex long turn running, history pagerows75 75 0 (0.0%) 75 ✅ Codex long turn finished, cold openHTTP decoded381.5 KiB 381.5 KiB 0 B (0.0%) 410.2 KiB ✅ Codex long turn finished, cold openrows151 151 0 (0.0%) 151 ✅ Codex long turn finished, socket cold openWebSocket decoded381.6 KiB 381.6 KiB 0 B (0.0%) 410.2 KiB ✅ Codex long turn finished, socket cold openWebSocket messages2 2 0 (0.0%) 2 ✅ Codex long turn finished, socket cold openrows151 151 0 (0.0%) 151 ✅ Codex long turn finished, work pageHTTP decoded186.2 KiB 186.2 KiB 0 B (0.0%) 200.2 KiB ✅ Codex long turn finished, work pagerows150 150 0 (0.0%) 150 ✅ Codex idle thread resumeWebSocket decoded65 B 65 B 0 B (0.0%) 200 B ✅ Codex idle thread resumeWebSocket messages1 1 0 (0.0%) 1 ✅ Codex fleet shell snapshotHTTP decoded41.6 KiB 41.6 KiB 0 B (0.0%) 53.7 KiB ✅ Codex fleet shell snapshotrows27 27 0 (0.0%) 27 ✅ Codex fleet shell subscribeWebSocket decoded65 B 65 B 0 B (0.0%) 200 B ✅ Codex fleet shell subscribeWebSocket messages1 1 0 (0.0%) 1 ✅ Codex fleet shell resume checkHTTP decoded18 B 18 B 0 B (0.0%) 100 B ✅ Codex fleet shell resume checkrows0 0 0 0 ✅ Codex stale shell reloadHTTP decoded41.6 KiB 41.6 KiB 0 B (0.0%) 53.7 KiB ✅ Codex stale shell reloadrows27 27 0 (0.0%) 27 ✅ Codex stale shell resumeWebSocket decoded140 B 140 B 0 B (0.0%) 400 B ✅ Codex stale shell resumeWebSocket messages2 2 0 (0.0%) 2 ✅ Codex stale todo list cold openHTTP decoded72.4 KiB 72.4 KiB 0 B (0.0%) 83.0 KiB ✅ Codex stale todo list cold openrows75 75 0 (0.0%) 75 ✅ Codex stale todo list cold opennodes2 2 0 (0.0%) 4 ✅ Codex stale todo list cold opensubagents2 2 0 (0.0%) 4 ✅ Codex stale todo list cold openplans1 1 0 (0.0%) 2 ✅ Codex stale todo list cold openproviderTurns1 1 0 (0.0%) 2 ✅ Codex stale todo list cold opencheckpoints1 1 0 (0.0%) 2 ✅ Claude short turn resumeWebSocket decoded10.6 KiB 10.6 KiB 0 B (0.0%) 12.7 KiB ✅ Claude short turn resumeWebSocket messages2 2 0 (0.0%) 2 ✅ Claude long turn running, cold openHTTP decoded283.3 KiB 283.3 KiB 0 B (0.0%) 302.7 KiB ✅ Claude long turn running, cold openrows75 75 0 (0.0%) 75 ✅ Claude long turn running, history pageHTTP decoded93.4 KiB 93.4 KiB 0 B (0.0%) 107.4 KiB ✅ Claude long turn running, history pagerows75 75 0 (0.0%) 75 ✅ Claude long turn finished, cold openHTTP decoded384.2 KiB 384.2 KiB 0 B (0.0%) 410.2 KiB ✅ Claude long turn finished, cold openrows151 151 0 (0.0%) 151 ✅ Claude long turn finished, socket cold openWebSocket decoded384.3 KiB 384.3 KiB 0 B (0.0%) 410.2 KiB ✅ Claude long turn finished, socket cold openWebSocket messages2 2 0 (0.0%) 2 ✅ Claude long turn finished, socket cold openrows151 151 0 (0.0%) 151 ✅ Claude long turn finished, work pageHTTP decoded188.1 KiB 188.1 KiB 0 B (0.0%) 200.2 KiB ✅ Claude long turn finished, work pagerows150 150 0 (0.0%) 150 ✅ Claude idle thread resumeWebSocket decoded66 B 66 B 0 B (0.0%) 200 B ✅ Claude idle thread resumeWebSocket messages1 1 0 (0.0%) 1 ✅ Claude fleet shell snapshotHTTP decoded42.2 KiB 42.2 KiB 0 B (0.0%) 53.7 KiB ✅ Claude fleet shell snapshotrows27 27 0 (0.0%) 27 ✅ Claude fleet shell subscribeWebSocket decoded66 B 66 B 0 B (0.0%) 200 B ✅ Claude fleet shell subscribeWebSocket messages1 1 0 (0.0%) 1 ✅ Claude fleet shell resume checkHTTP decoded18 B 18 B 0 B (0.0%) 100 B ✅ Claude fleet shell resume checkrows0 0 0 0 ✅ Claude stale shell reloadHTTP decoded42.2 KiB 42.2 KiB 0 B (0.0%) 53.7 KiB ✅ Claude stale shell reloadrows27 27 0 (0.0%) 27 ✅ Claude stale shell resumeWebSocket decoded140 B 140 B 0 B (0.0%) 400 B ✅ Claude stale shell resumeWebSocket messages2 2 0 (0.0%) 2 ✅ Claude stale todo list cold openHTTP decoded73.4 KiB 73.4 KiB 0 B (0.0%) 83.0 KiB ✅ Claude stale todo list cold openrows75 75 0 (0.0%) 75 ✅ Claude stale todo list cold opennodes2 2 0 (0.0%) 4 ✅ Claude stale todo list cold opensubagents2 2 0 (0.0%) 4 ✅ Claude stale todo list cold openplans1 1 0 (0.0%) 2 ✅ Claude stale todo list cold openproviderTurns1 1 0 (0.0%) 2 ✅ Claude stale todo list cold opencheckpoints1 1 0 (0.0%) 2 ✅ Baseline:
4e48d9e· PR result:1ca6f55· Source CI: successScenario 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.
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:XS
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
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.
tanstack-source added labelsbug
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed