You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(server): an agent's t3_thread_read on a linked environment starts at the newest page - #40094
An agent calling t3_thread_read on a linked environment's thread with no position got the oldest page, though the tool says it reads newest first. A read forwarded over a link reaches the linked server as a client call with no thread, and those page forward. The fix makes forwarded agent reads ask for the newest page explicitly, and makes sure that page still carries the first-page pull request preview.
PeerForwarding.call adds beforePosition: Number.MAX_SAFE_INTEGER to an agent's forwarded t3_thread_read that gives no afterPosition, beforePosition or itemId. The linked server then serves the newest page.
OrchestratorMcpService.readThread counts a read with a beforePosition at or past the thread's end as the first page. The forwarded read therefore keeps pullRequests and openPullRequestCount, as a local cursorless read does.
Commit f2ec853 (origin/main). Set up two real servers on fresh databases. Server B was the worktree dev server (T3CODE_DEV_SEED=0 vp run dev, Linked environments enabled). Server A was node apps/server/src/bin.ts serve on its own --base-dir, with Linked environments and OpenCode enabled. On B: t3 project add, then t3 thread start --provider devReplay --model multi-turn and 24 t3 thread send --wait, giving one thread with 50 messages (thread.itemCount 76). Linked A to B with t3 environment link --pairing-code <from t3 pair on B> --access full-access. On A, an OpenCode agent (xai/grok-4.3) called t3_thread_read with {environmentId: B, threadId, limit: 35}. Result: 35 items at positions 0..52 starting with 'message 1', earlierPosition null, nextPosition 52, hasMore true. On B, an OpenCode agent made the same call locally with {threadId, limit: 35}. Result: items at positions 23..74 (the newest), earlierPosition 23, hasMore false. Two attempts to show the reporter's beforePosition comparison over the link failed: the model sent maxCharsPerItem instead of beforePosition, so that half is shown by the code path, not observed. Failing test: PeerForwarding.test.ts. An agent on the laptop reads the box's thread with limit 35. The box's ThreadManagement.getTimelinePage receives {limit: 35, view: 'messages'} with no beforePosition, so it serves the oldest page. 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
vp test run src/mcp/OrchestratorMcpService.activity.test.ts src/peer/PeerForwarding.test.ts src/peer/RemoteDelegation.test.ts src/mcp/OrchestratorMcpService.test.ts (apps/server): 4 files, 166 tests passed
vp test run src/mcp/OrchestratorMcpService.activity.test.ts with the readThread change reverted: the new newest-page assertion fails (1 failed, 9 passed)
vp run check:changed: format, lint, knip, graphql, typecheck (3 packages) and tests (4 files) all pass
Not in this change
The CLI's t3_thread_read with no position still pages oldest first, as documented.
…nment reads the newest page
Fails on main: the forwarded read reaches the linked server without a
thread scope, so it pages from the oldest item.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… at the newest page
A read forwarded over a link arrives as a client call with no thread, so
a cursorless read paged from the oldest item. The linked server now
treats a read made for a linked environment's thread (T3-Sender-Thread)
as an agent read and serves the newest page. The delegated-task result
scan, which pages forward, asks for the start explicitly.
Fixes#39932
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d_read
Reading newest first on the linked server whenever a sender thread was
attached also changed what older delegated-task result scans got, and
the scan's new afterPosition: -1 is invalid for servers before #33428.
Leave readThread and RemoteDelegation as on main, and instead add
beforePosition to an agent's forwarded read that gives no position or
item, so the linked server serves the newest page.
Fixes#39932
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…pull requests
The forwarded read names the newest page with beforePosition, which the
linked server took for a later page and so dropped the open pull request
preview. A beforePosition at or past the thread's end is the first page.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
So on current main, a forwarded agent read may already return the newest page without the beforePosition this PR injects. This branch is 73 commits behind main, so please rebase and re-run the two-server repro against current main. If it passes without the injection, the PeerForwarding.call change is redundant.
The firstPage change is a separate question: check that a linked read on the newest page keeps pullRequests on current main.
Not tested: the two-server repro, the CLI path, and the 166-test run on a rebased branch.
This review covers only an added test assertion about the open pull-request count on the newest activity page. It does not change runtime behavior and no actionable merge risk was found. Rebasing onto current main is still advisable, because main may already include an equivalent fix.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: an agent's forwarded t3_thread_read on a linked environment now starts at the newest page instead of the oldest. It matches the changeset, which adds beforePosition to…
Description check
The description follows the template's main sections: Problem, Change, Scope (issue link Fixes #39932), and Verification with specific test commands and results. It explains the proble…
Linked Issues check
The only directly linked issue, #39932, is closed. Its state is marked as historical context only. No active directly linked target remains, so no linked-issue coding requirements apply. The PR object…
Out of Scope Changes check
The change since the previous reviewed head (c2c90d3) adds one assertion to apps/server/src/mcp/OrchestratorMcpService.activity.test.ts. The assertion checks that a newest-page read of readThread r…
Full details: Title check
Explanation
The title names the main change: an agent's forwarded t3_thread_read on a linked environment now starts at the newest page instead of the oldest. It matches the changeset, which adds beforePosition to forwarded reads in PeerForwarding.call and handles that cursor in OrchestratorMcpService.readThread. The title follows the conventional commit format from the template. It is 88 characters, slightly long, but still clear.
Full details: Description check
Explanation
The description follows the template's main sections: Problem, Change, Scope (issue link Fixes #39932), and Verification with specific test commands and results. It explains the problem, the fix, and the reproduction on main. It also states what was not checked and names the agents involved, as the template asks. The Evidence section is an unfilled placeholder that says before/after capture is still in progress, and the description says it must be filled before merge. The Scope section does not explain why the change is a bug fix rather than a feature, and the reviewer comments in the objectives say the branch is 73 commits behind main and that a rebased two-server repro is needed. Those gaps are real but the description is mostly complete.
Full details: Linked Issues check
Explanation
The only directly linked issue, #39932, is closed. Its state is marked as historical context only. No active directly linked target remains, so no linked-issue coding requirements apply. The PR objectives reach the same conclusion. No acceptance criteria were assessed as PR objectives.
Full details: Out of Scope Changes check
Explanation
The change since the previous reviewed head (c2c90d3) adds one assertion to apps/server/src/mcp/OrchestratorMcpService.activity.test.ts. The assertion checks that a newest-page read of readThread reports openPullRequestCount of 7. This tests the readThread first-page rule that the PR fixes, so it is connected to the stated objective. The whole-PR scope (PeerForwarding.call injection of beforePosition: Number.MAX_SAFE_INTEGER, the readThread first-page rule, and their tests) was established in the previous review. It matches the PR description. I did not rerun a whole-PR diff against the current head 3de5787, so the whole-PR file list rests on the previous assessment and the supplied summary. No unrelated change was demonstrated.
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
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
Thanks for this. Main has the change since #40003.
Main now selects the newest page for cursorless agent reads on linked environments and preserves the pull request preview and open count. Comparing the PR branch against main leaves only one additional openPullRequestCount test assertion; its runtime fixes are already covered by the merge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
size:XS0-9 changed lines (additions + deletions).vouch:trustedAuthor is trusted by repo permissions or the VOUCHED list.
2 participants
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.
An agent calling
t3_thread_readon a linked environment's thread with no position got the oldest page, though the tool says it reads newest first. A read forwarded over a link reaches the linked server as a client call with no thread, and those page forward. The fix makes forwarded agent reads ask for the newest page explicitly, and makes sure that page still carries the first-page pull request preview.PeerForwarding.calladdsbeforePosition: Number.MAX_SAFE_INTEGERto an agent's forwardedt3_thread_readthat gives noafterPosition,beforePositionoritemId. The linked server then serves the newest page.OrchestratorMcpService.readThreadcounts a read with abeforePositionat or past the thread's end as the first page. The forwarded read therefore keepspullRequestsandopenPullRequestCount, as a local cursorless read does.Fixes #39932
Reproduction on main
Commit f2ec853 (origin/main). Set up two real servers on fresh databases. Server B was the worktree dev server (T3CODE_DEV_SEED=0 vp run dev, Linked environments enabled). Server A was
node apps/server/src/bin.ts serveon its own --base-dir, with Linked environments and OpenCode enabled. On B:t3 project add, thent3 thread start --provider devReplay --model multi-turnand 24t3 thread send --wait, giving one thread with 50 messages (thread.itemCount 76). Linked A to B witht3 environment link --pairing-code <from t3 pair on B> --access full-access. On A, an OpenCode agent (xai/grok-4.3) called t3_thread_read with {environmentId: B, threadId, limit: 35}. Result: 35 items at positions 0..52 starting with 'message 1', earlierPosition null, nextPosition 52, hasMore true. On B, an OpenCode agent made the same call locally with {threadId, limit: 35}. Result: items at positions 23..74 (the newest), earlierPosition 23, hasMore false. Two attempts to show the reporter's beforePosition comparison over the link failed: the model sent maxCharsPerItem instead of beforePosition, so that half is shown by the code path, not observed. Failing test: PeerForwarding.test.ts. An agent on the laptop reads the box's thread with limit 35. The box's ThreadManagement.getTimelinePage receives {limit: 35, view: 'messages'} with no beforePosition, so it serves the oldest page. 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
vp test run src/mcp/OrchestratorMcpService.activity.test.ts src/peer/PeerForwarding.test.ts src/peer/RemoteDelegation.test.ts src/mcp/OrchestratorMcpService.test.ts(apps/server): 4 files, 166 tests passedvp test run src/mcp/OrchestratorMcpService.activity.test.tswith thereadThreadchange reverted: the new newest-page assertion fails (1 failed, 9 passed)vp run check:changed: format, lint, knip, graphql, typecheck (3 packages) and tests (4 files) all passNot in this change
Who did the work
Run by the t3code factory in T3 Code.