Skip to content

fix(server): t3_thread_read returns the newest page to outside MCP clients - #41378

Merged
juliusmarminge merged 2 commits into
pingdotgg:mainfrom
mfazekas:fix/thread-read-newest-first-for-mcp-clients
Nov 23, 2026
Merged

juliusmarminge merged 2 commits into
pingdotgg:mainfrom
mfazekas:fix/thread-read-newest-first-for-mcp-clients

Conversation

@mfazekas

Copy link
Copy Markdown
Contributor

Problem

The t3_thread_read description says "Newest first", but a read without a cursor from an outside MCP client such as claude.ai (no calling thread, not a linked environment) returned the oldest items from position 0. Peer forwarding likewise asked older linked environments for the newest page only on behalf of agents.

Change

Every cursorless read now gets the newest page, and peer forwarding requests it for any caller. The t3 thread CLI, the one caller that relied on paging forward, now passes afterPosition: -1 explicitly.

Scope

A small fix for an obvious bug: the tool does not do what its description promises for outside clients.

Verification

Added an outside-client read to OrchestratorMcpService.activity.test.ts and a client read to PeerForwarding.test.ts. The CLI test's fake server now serves the newest page for cursorless reads. All three fail without the change and pass with it. src/mcp, src/cli and src/peer pass, apart from 6 environment-dependent CLI tests that also fail on main.

Model: Claude Opus 5.5 (claude-opus-5-5). Harness: Claude Code, run from T3 Code.

…ients

t3_thread_read is documented as newest first, but a cursorless read from an
outside MCP client such as claude.ai (no calling thread, not a linked
environment) paged forward from position 0. Every cursorless read now gets
the newest page, including reads forwarded to older linked environments.
The t3 thread CLI passes afterPosition -1 to keep paging forward.
@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Nov 23, 2026
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 3c48ed6 and d02056a.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

Cursorless thread reads now select the newest page across caller scopes, including forwarded reads. CLI reads send explicit pagination cursors, and cursorless local timeline reads return the newest matching items.

Changes: Thread Read Pagination

Layer / File(s) Summary
Orchestrator cursorless reads
apps/server/src/mcp/OrchestratorMcpService.ts, apps/server/src/mcp/OrchestratorMcpService.activity.test.ts
readThread now selects newest-first pages for cursorless reads regardless of caller scope. Tests check the outside-client newest page and retain forward-pagination checks for an unlinked CLI caller.
Peer forwarding newest-page selection
apps/server/src/peer/PeerForwarding.ts, apps/server/src/peer/PeerForwarding.test.ts
Cursorless t3_thread_read calls now receive a newest-page cursor regardless of caller scope. Tests check reads from agent and client contexts.
CLI pagination cursors
apps/server/src/cli/thread.ts, apps/server/src/cli/thread.test.ts
CLI reads now send explicit cursors. Cursorless local timeline reads return the newest matching items; reads with afterPosition continue forward scanning.

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

Change: Bug fix

Suggested reviewers: gek0v, shivamhwp, juliusmarminge

Merge Risk: Minimal · previous review 3c48e

Cursorless thread reads from outside MCP clients, including reads forwarded to older linked environments, now return the newest page as the tool description promises. The CLI sends explicit cursors, so its forward paging is unchanged. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: t3_thread_read now returns the newest page to outside MCP clients. It follows conventional commit style, is one sentence, and matches the changeset and PR objectives.
Description check Passed The description follows the template. It has Problem, Change, Scope, and Verification sections, and each is filled in. The problem is stated with reproduction context (outside MCP client without a thr…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description follows the template. It has Problem, Change, Scope, and Verification sections, and each is filled in. The problem is stated with reproduction context (outside MCP client without a thread link). The change explains cursorless reads and peer forwarding, plus the CLI adjustment. Scope justifies the lack of a linked issue as a small obvious bug fix. Verification lists the added tests, pre-fix failures, and a test run with known failures. It also names the model and harness as the template asks. Minor gap: no linked issue is given, though the template allows a justification for small fixes.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • 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 f9f34aa and 3c48ed6.

Files selected for processing: 6

  • apps/server/src/cli/thread.test.ts
  • apps/server/src/cli/thread.ts
  • apps/server/src/mcp/OrchestratorMcpService.activity.test.ts
  • apps/server/src/mcp/OrchestratorMcpService.ts
  • apps/server/src/peer/PeerForwarding.test.ts
  • apps/server/src/peer/PeerForwarding.ts

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

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 23, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@juliusmarminge
juliusmarminge force-pushed the fix/thread-read-newest-first-for-mcp-clients branch from 6805295 to d02056a Compare November 23, 2026 10:59
@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

Created four Replay turns on fresh databases, authorized an outside read-only OAuth MCP client, and compared cursorless limit:2 reads with explicit newest reads. Also read an older page and paginated forward through all eight messages. Real servers and web browser, 1280×800; the labelled inspector shows actual /mcp responses.

Before After
1e088be4b5 d02056ad27
Cursorless read incorrectly returns oldest positions 0,2. Cursorless read returns newest positions 10,11.
Before: outside MCP returns oldest page After: outside MCP returns newest page
Before: four-turn thread After: four-turn thread
Before recording After recording

Scenario driver. scenarios:prove exited 0: failed on base, passed on head.

Not shown:

  • Forwarded reads to an older linked environment were not exercised; this proof used a single isolated environment on each commit.

@juliusmarminge juliusmarminge added takeover:ready Takeover done; auto-lands when gates pass and removed takeover:in-progress A takeover lead is working on this PR labels Nov 23, 2026
@juliusmarminge
juliusmarminge merged commit 2ee7a4f into pingdotgg:main Nov 23, 2026
55 checks passed
@juliusmarminge juliusmarminge removed the takeover:ready Takeover done; auto-lands when gates pass label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants