`t3_thread_read`: support reading the newest items of a thread (`beforePosition` or newest-first order)
Problem
t3_thread_read pages forward only: items come oldest first, continuing with afterPosition=nextPosition. An MCP client that wants the most recent assistant reply of a long thread (a common need for an orchestrating agent checking on another thread) has no direct way to get it. t3_thread_wait returns status only, and t3_thread_list returns no message text.
Example
A thread with a few hundred timeline items, most of them tool calls and reasoning:
t3_thread_read({ "threadId": "<id>", "view": "messages", "limit": 2 })
// -> items at positions 0 and 9 (the first user message and the first reply), hasMore: true
To reach the latest reply the client must keep paging with afterPosition=nextPosition to the end. With the default maxCharsPerItem (20,000) every page can carry a lot of text the caller doesn't want.
Current workarounds
- Page forward with
maxCharsPerItem: 1to find positions cheaply, then read the wanted item withitemId(andtextOffset=nextTextOffsetuntil it is null). - Or rely on positions being dense:
thread.itemCountappears to equal the last position + 1, soafterPosition = itemCount - N - 1reaches the tail. This works today, but it isn't documented, so clients can't depend on it.
Proposal (any one would do)
- A
beforePositioninput (exclusive) that returns the items just before it, newest last or with a stated order, so the same paging works in both directions; or - An
order: "desc"(newest first) option; or - At minimum, document whether positions are dense and whether
itemCount - 1is the last position.
Smaller, related
- When
textTruncatedis true, a total text length (in the same UTF-16 units astextOffset) would let clients decide whether to fetch the rest. - The schema accepts
textOffsetwithoutitemId, but it is ignored there. Rejecting it or documenting it would avoid confusion.
+1, with a concrete case where the dense-positions workaround isn't enough.
We have an orchestrating agent that summarizes many threads with cheap reader subagents. Each reader wants the last N user and assistant messages of a thread. With view: "messages", afterPosition counts every timeline item but the view filters after it, so in a tool-heavy thread there is no way to know how far back to start: itemCount - 40 may hold only 3 messages, and starting further back (say itemCount - 340) returns the oldest messages of that window, not the newest. On one real thread, a read like that stopped about 85 positions short of the end and skipped the user's two latest requests. The only fix on the client side is to keep paging forward, which costs extra reads and tokens for text the caller then throws away.
A beforePosition (exclusive) that returns the last limit items of the selected view before that position would solve it in one call. Omitting afterPosition together with beforePosition: itemCount would then mean "the newest N messages".
Related pagination use case: discovering item IDs and provenance without receiving item text.
At main commit 012e4ec0566c6653095672b1ea98c2bea4b0ad83, maxCharsPerItem accepts positive integers only. The messages view filters out intermediate items, while activity returns their summarized text. Consequently, maxCharsPerItem: 1 reduces volume but still returns part of each item's text; it cannot provide complete, text-suppressed metadata enumeration. The returned item type is also advertised as an unrestricted string rather than the server's supported type vocabulary.
This matters for a parent that needs to discover the original dispatch/terminal item and detect later inbound messages or inherited history while reading only those two selected texts. Forward paging works, but the current contract cannot express that privacy requirement. This is a missing capability, not a claim that ordinary thread reading is broken.
I closed pingdotgg/t3code#22025 and am leaving the use case here alongside the existing pagination report. A documented metadata-only read, with stable positions/provenance and the supported item-type vocabulary, would help this use case if it fits the maintainers' direction. We will adapt our orchestration workflow to the existing interface in the meantime.
[!NOTE] 🤖 Claude Opus 5.5 responding on behalf of Theo
Thanks for the idea. Feature requests and proposals belong in Ideas discussions, where others can find and vote on them and maintainers track direction, so we close them here (see CONTRIBUTING.md). If this still matters to you, please post it there and link this issue.