Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(client): load earlier turns works for MCP threads over T3 Connect #17599

Mergedjuliusmarmingemerged 1 commit intomain fromrefs/pull/17599/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

Over T3 Connect, "Load earlier turns" on a thread created through MCP tools (id mcp:…) failed with "The environment rejected this client's credentials (invalid_credential)." The server log showed environment.dpop.failure_code: "url_mismatch".

The DPoP proof signed /api/orchestration/threads/mcp:…/history with the raw id, while the HttpApi client sent the percent-encoded path /threads/mcp%3A…/history. The environment compares the proof against the URL it received, so it rejected the request. The credential refresh-and-retry signed the same wrong URL, so it failed too. Thread snapshot and bounded snapshot requests built their URLs the same way.

The fix encodes the thread id in all three signed URLs. A new test loads each one with an mcp: id and checks that the signed URL equals the URL actually fetched. Without the fix the test fails.

Possible follow-up: the signed URL and the sent URL are still built separately. Signing the request URL the client actually sends would rule out this whole class of bug.

Done by Claude Opus 5.5 in Claude Code (via T3 Code).

🤖 Generated with Claude Code

Fixes #15772


Devin Review
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. juliusmarminge added labelsmacroscope-review

    3. Approvability

      Verdict: Approved at 231683b

      Macroscope's review found this PR approvable — This is a focused client bug fix that aligns DPoP-signed URLs with the percent-encoded URLs actually sent for MCP thread IDs. It touches only three existing request paths and adds targeted regression coverage for all of them.

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

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration
      • Configuration used: Path: .coderabbit.config.ts
      • Review profile: CHILL
      • Plan: Team
      • Run ID: e54543fa-e6c1-4456-b60c-88bffd82262a

      📥 Commits

      Reviewing files that changed from the base of the PR and between 454b94a13aea918f27bb060d8d054d4cfb791bc2 and 231683b19b991d30853510e11779ba4645dcb7a4.


      📒 Files selected for processing (4)
      • packages/client-runtime/src/state/boundedThreadSnapshotHttp.ts
      • packages/client-runtime/src/state/environmentHttpAuth.test.ts
      • packages/client-runtime/src/state/threadHistoryHttp.ts
      • packages/client-runtime/src/state/threadSnapshotHttp.ts

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



      📝 Walkthrough

      Walkthrough

      Snapshot, bounded snapshot, and history request paths now percent-encode thread IDs. Added tests use an ID containing a colon and verify the encoded request path and DPoP proof URL.

      Changes

      Thread ID path encoding

      Layer / File(s)Summary
      Encode thread IDs in request paths
      packages/client-runtime/src/state/threadSnapshotHttp.ts, packages/client-runtime/src/state/boundedThreadSnapshotHttp.ts, packages/client-runtime/src/state/threadHistoryHttp.ts, packages/client-runtime/src/state/environmentHttpAuth.test.ts
      Snapshot, bounded snapshot, and history request paths encode thread IDs before URL interpolation. Tests check encoded paths and confirm that the DPoP proof URL matches the sent URL without its query string.

      Priority: ⬇️ Low

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

      Change: Bug fix


      Merge Risk: ⚪ Minimal · up to 23168

      No actionable issue is established for the reported MCP thread-ID fix. The change is mergeable after normal checks.

      Pre-merge checks | Passed 4
      ✅ Passed checks (4 passed)
      Check nameStatusExplanation
      Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
      Title checkPassedThe title clearly identifies the fix for loading earlier turns in MCP threads over T3 Connect.
      Description checkPassedThe description explains the problem, the URL-encoding change, and the added test. It links issue #15772, but does not state that the issue is triaged or include maintainer approval. It also does not …


      ✨ 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

      Comment `@coderabbitai help` to get the list of available commands.
    5. juliusmarminge merged thisa1db449

    6. juliusmarminge closed this

    7. 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 decoded20.9 KiB20.9 KiB0 B (0.0%)29.3 KiB✅
      CodexLive turn messages220 (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.2 KiB21.2 KiB0 B (0.0%)29.3 KiB✅
      ClaudeLive turn messages220 (0.0%)8✅

      Baseline: 454b94a · PR result: 231683b · 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.

Sign in to join this conversation.