t3code icon indicating copy to clipboard operation
t3code copied to clipboard

`t3_thread_read`: support reading the newest items of a thread (`beforePosition` or newest-first order)

Open boundsj opened this issue 1 month ago • 3 comments

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: 1 to find positions cheaply, then read the wanted item with itemId (and textOffset=nextTextOffset until it is null).
  • Or rely on positions being dense: thread.itemCount appears to equal the last position + 1, so afterPosition = itemCount - N - 1 reaches the tail. This works today, but it isn't documented, so clients can't depend on it.

Proposal (any one would do)

  • A beforePosition input (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 - 1 is the last position.

Smaller, related

  • When textTruncated is true, a total text length (in the same UTF-16 units as textOffset) would let clients decide whether to fetch the rest.
  • The schema accepts textOffset without itemId, but it is ignored there. Rejecting it or documenting it would avoid confusion.

boundsj avatar Oct 08 '26 01:10 boundsj

+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".

alcxyz avatar Oct 11 '26 23:10 alcxyz

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.

ViperJuice avatar Oct 19 '26 23:10 ViperJuice

[!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.

t3dotgg avatar Oct 21 '26 21:10 t3dotgg