GeezerVison is showing github.com — fix(pi): retry T3 tool discovery with a fresh session by StiensWout · Pull Request #42612 · pingdotgg/t3code
Conversation
A temporary tool discovery failure at startup could leave Pi without T3 tools until the session was reloaded. Pi now attempts to close the previous MCP session with an authenticated request and a separate one-second timeout, then gives the fresh handshake and discovery their full ten-second deadline. After discovery, Pi reconciles the active tool loadout so recovered tools are ready to use.
Related: #37521, #37839, #36336, #30996
Reproduction on main
Commit 4e6b1fa771 (main). Pi’s startup retry is rejected, leaving it without the T3 tools for that session. Expected: Pi retries tool discovery and can use the T3 tool to list available providers.
The cause is at packages/provider-pi/src/server/mcpExtensionSource.ts:196. Ran cd packages/provider-pi && pnpm exec vp test run src/server/mcpExtensionSource.test.ts with the repro test added: it failed in 2 of 2 runs on a clean checkout, with expected undefined to deeply equal [ { type: 'text', …(1) } ] in the output.
Evidence
Environment: Linux x64, the repository's own tests.
Proven: the repro fails at the test commit 366ca22204 and passes on the head 9d85035db7, both on main 6632511cd8.
|
Before |
After |
| Commit |
366ca22204 |
9d85035db7 |
| Result |
failed with "expected undefined to deeply equal [ { type: 'text', …(1) } ]" |
passed |
Outside view: not shown in the running app. The bug fails the rule that every step is the person's or the world's and that the app gets there by itself. The stuck session only exists after a stand-in fetch returns one error for the tool list once initialize has kept a session id, then rejects the retry initialize because that id is still sent; opening a Pi thread does not make T3's own tool list fail and recover between those two calls, and the startup warning is dropped while no turn is active.
Tests
- 366ca22204 adds the failing test, alone, before the fix.
pnpm exec vp run check:changed 6632511cd8f523c2b9439272d776fb44c2bce110 passed on head.
Not in this change
- The retry count and startup warning behavior are outside the scope of this change.
- The regression tests exercise Pi against a simulated HTTP transport and verify the bearer token on the cleanup request. Live client behavior was outside the test scope.
Who did the work
- Repro written by GPT 6.2 Sol, in Codex
- Outside view by Grok 4.7, in Grok
- Duplicate check judged by Claude Opus 5.5, in Claude Code
- Written by GPT 6.2 Sol, in Codex
- Trimmed by Claude Opus 5.5, in Claude Code
- Reviewed by Claude Opus 5.5, in Claude Code, and by GPT 6.2 Sol, in Codex, and by Gemini 4 Neon, in Antigravity
- Reproduction, checks and proof run by a program on base and head, not by an agent
Made in T3 Code by GPT 6.2 Sol, Claude Opus 5.5, Grok 4.7 and Gemini 4 Neon
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
connect is only called with ensureStarted's timeout signal.
Co-authored-by: Claude Opus 5.5 <[email protected]>
The recorded session ID already proves which session was released.
Co-authored-by: Claude Opus 5.5 <[email protected]>
coderabbitai
Bot
commented
Nov 25, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

No actionable comments were generated in the recent review.
Walkthrough
-
The MCP client closes an existing session before connecting. The session-start handler now completes startup and reports connection errors before reconciling discovery. The test bridge and extension tests cover startup discovery failures and session termination outcomes.
Changes: MCP Session Startup Recovery
| Layer / File(s) |
Summary |
Session lifecycle and startup ordering packages/provider-pi/src/server/mcpExtensionSource.ts |
The client sends a best-effort DELETE for an existing session and clears its session ID. Startup closes the previous session before connecting. The session-start handler reports startup errors before reconciling discovery. |
Startup retry test coverage packages/provider-pi/src/server/mcpBridge.testkit.ts, packages/provider-pi/src/server/mcpExtensionSource.test.ts |
The test bridge simulates session initialization, discovery failures, and DELETE responses or network errors. Tests check the termination attempt, active tools, and preview-snapshot result. |
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Suggested labels: bugfix
Suggested reviewers: juliusmarminge
Merge Risk: Minimal · up to d7ac3
-
This change closes a stale MCP session before retrying startup, so tool discovery recovers after a failed first attempt. The new regression tests cover both a successful and an offline session close. No concrete merge-blocking risk remains. Live client behavior is not tested, but the change is small and easy to revert.
Pre-merge checks: 4
-
| Check name |
Status |
Explanation |
| Title check |
 |
The title names the fix (retrying T3 tool discovery with a fresh session) and the affected package (pi). The raw summary shows the change closes the previous MCP session before startup discovery and r… |
| Description check |
 |
The description covers the problem (startup tool discovery failure leaving Pi without T3 tools), the change (closing the previous session, separate timeout, reconciliation after discovery), reproducti… |
| Linked Issues check |
 |
Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check |
 |
Check skipped because no linked issues were found for this pull request. |
Full details: Title check
-
Explanation
The title names the fix (retrying T3 tool discovery with a fresh session) and the affected package (pi). The raw summary shows the change closes the previous MCP session before startup discovery and reconciles tools on session start, so the title matches the main change. It is specific and follows conventional commit format.
Full details: Description check
-
Explanation
The description covers the problem (startup tool discovery failure leaving Pi without T3 tools), the change (closing the previous session, separate timeout, reconciliation after discovery), reproduction steps and environment, verification (failing test before the fix, passing on head, check:changed run), and scope notes. It also lists related issues and the authors. It does not follow the template strictly: the Scope section does not clearly say why no issue is linked beyond the 'Related' issue list, and the Verification section includes a claim about an 'Outside view' that is hard to verify and uses non-standard prose. The description is mostly complete, so the check passes, but the Scope section should state explicitly that the change is a bug fix and link the issue that shows the bug.
Finishing Touches
-
Generate unit tests (beta)
-
- 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 9d85035 and d7ac350.
Files selected for processing: 2
-
packages/provider-pi/src/server/mcpBridge.testkit.ts
packages/provider-pi/src/server/mcpExtensionSource.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Evidence
Evidence from Linux Chromium, Pi 1.6.0 / Claude Haiku 5.5, fresh databases, identical light theme and viewport. A fault proxy held the first tools/list beyond the 10-second discovery deadline, then forwarded subsequent traffic to the real T3 MCP endpoint. Asked for orchestrator_capabilities, then asked again in the same thread after recovery.
Fault-injection driver · Reproduction instructions. Captures crop out the environment details panel while retaining the chat and composer.
Not shown:
- The failed/offline DELETE fallback was not exercised; the real endpoint returned 204.
- Used a deterministic tools/list timeout instead of literal SIGSTOP/SIGCONT of the server. The real Pi bridge, retry, session validation, discovery, and tool execution were exercised.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This branch has not been deployed
No deployments
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|