Repository navigation
perf(mcp-gateway): t3_list_threads returns the latest 20 chats unless asked for more - #176
Merged
Merged
Conversation
… asked for more t3_list_threads fetched every chat on every environment and returned all of them, with full profile snapshots and model selections; one unfiltered call returned 7.4 MB. It now sorts newest update first and returns 20 compact rows by default, with limit (max 100) and a keyset cursor (nextCursor/hasMore) to page further. updatedAfter, updatedBefore and createdAfter pick a time window. Each environment filters and trims to one page before the merge, and includeQuestions reads details only for the rows returned. Also corrects the t3_task_watch description: task changes never wake the owner; the call only holds the current turn. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: Scenario and decoded snapshot size10 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.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
jayleaton
marked this pull request as ready for review
October 31, 2026 02:48
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
The gateway MCP tool
t3_list_threadsreturned every chat on every environment, with full profile snapshots and model selections, and had no limit or cursor. One unfiltered call returned 7.4 MB. It now returns the 20 most recently updated chats by default.limit(1–100, default 20),cursor(a keyset cursor over updatedAt, environmentId, and id, so pages never overlap), andupdatedAfter,updatedBefore, andcreatedAfter(ISO). The existing filters are unchanged.profileSnapshotbecomesprofileIdandprofileName, andmodelSelectionbecomesproviderInstanceIdandmodel.latestRunIdandactiveRunIdare dropped.t3_get_threadreturns the full chat.listThreadsreads the client's in-memory shell snapshot and accepts no filter arguments. Each environment filters and trims to one page before the merge, so the output stays bounded.t3_task_watchsentence "Wakes already arrive as messages". Task changes never wake the owner; the call only holds the current turn.docs/user/remote-access.md(defaults, paging, and the row fields).The server's
t3_thread_listis untouched.Evidence
tools.ts) and After (this branch) on the same synthetic fixture, 2 environments × 1,000 chats,t3_list_threads {}, run throughcallGatewayToolwith node:vp test run src/tools.test.ts src/server.test.tsinpackages/mcp-gateway: 125 passed. The newbounded thread listtests cover: the default of 20 newest first;limitwithcursorpaging through 60 chats whose timestamps tie across environments, with no overlap or gaps; the time windows; combined filters across two environments before truncation; invalid limit, cursor, and time inputs; andincludeQuestionsreading only rows on the page.tsc --noEmit(mcp-gateway),vp lint, andvp fmt --checkon the touched files: clean.Merge Danger
Door: two-way
Stateless read tool; a revert restores the old output.
Blast Radius: consumers
Agents that call the gateway's
t3_list_threadswithout paging now see at most 20 chats, and rows no longer carryprofileSnapshot,modelSelection,latestRunId, oractiveRunId. Nothing in the repo reads those fields from this tool's output.🤖 Generated with Claude Code