fix(client): load earlier turns works for MCP threads over T3 Connect #17599
main fromrefs/pull/17599/head·merged by juliusmarminge View on GitHubOver 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
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
juliusmarminge added labelsmacroscope-review
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
Approvability#
Verdict: Approved at
231683bMacroscope'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).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.tspackages/client-runtime/src/state/environmentHttpAuth.test.tspackages/client-runtime/src/state/threadHistoryHttp.tspackages/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.tsSnapshot, 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
23168No actionable issue is established for the reported MCP thread-ID fix. The change is mergeable after normal checks.
Pre-merge checks |
4✅ Passed checks (4 passed)
Check name Status Explanation 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. Title check The title clearly identifies the fix for loading earlier turns in MCP threads over T3 Connect. Description check The 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.juliusmarminge merged thisa1db449
juliusmarminge closed this
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 20.9 KiB 20.9 KiB 0 B (0.0%) 29.3 KiB ✅ Codex Live turn messages 2 2 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.2 KiB 21.2 KiB 0 B (0.0%) 29.3 KiB ✅ Claude Live turn messages 2 2 0 (0.0%) 8 ✅ Baseline:
454b94a· PR result:231683b· 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.
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes