Repository navigation
fix(server): thread reads can take the latest items and waits return on approvals - #177
Merged
Merged
Conversation
…on approvals
t3_thread_read with limit:1 returned the first item, so listeners got a
child's opening brief instead of its final reply. A new tail option takes
the last `limit` matching items, still in position order; only those
payloads are decoded. hasMore then means older items exist.
t3_thread_wait with returnOnQuestion only returned on live questions, so
callers polled t3_get_pending_questions for approvals. returnOnQuestion now
also returns on a live approval and reports the oldest as pendingApproval
({requestId, kind}). It reports only; it never approves.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 03:13
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.
Two bugs in the thread MCP tools that Captain's listeners hit.
t3_thread_readlimit:1tail:truereturns the lastlimititems, in position ordert3_thread_waitreturnOnQuestiont3_get_pending_questionspollpendingApproval: {requestId, kind}How
ProjectionTimelinePageOptions.tailslices the end of the matching index rather than the start, so only the returned items' payloads are decoded. The lightweight index (ids/types, no payloads) is still read in full, as forward reads already do. Positions depend on fork merging and visibility across the whole index, soLIMITcan't move into SQL without breaking them.afterPositionstill applies (it gives the latest N after X).nextPositionis still the last returned position. Withtail,hasMoremeans older items exist. Gateway reads (remoteThreads.ts) support it too, and linked environments forward it unchanged.returnOnQuestion(default true) now covers both kinds of person-blocking request, rather than adding a second option. The wait already subscribes toruntime-request.updated, so an approval that becomes pending wakes it at once. It reports only and never approves. Likedelegate_task, only live approvals count, and the oldest is reported.Not changed: without
runIdthe wait follows the run that was latest at call time and returns when it ends. A run that starts later on the thread (a background continuation) is not followed unlessuntilDelegatedWorkSettledis set.Evidence
Each new assertion fails on
main:ProjectionStore.test.ts› "keeps fork visible items stable…":expected [ { position: +0, … } ] to deeply equal [ … ](the tail read got the first item)ThreadManagementService.test.ts› "waitForThread returns early…": hung until the project timeout (120 s), because an approval never ended the waitWith the fix, ThreadManagementService, ProjectionStore, McpHttpServer and OrchestratorMcpService pass (128/128). Server, contracts, client-runtime and evals typecheck clean, and lint and format are clean.
Merge risk
Low. All new fields are optional. A default
t3_thread_waitnow also returns early when the thread is waiting on an approval. That was intended: the thread is blocked on a person in both cases. Internal waits (settleAfterRun, remote delegation withreturnOnQuestion:false) are unaffected. Tool descriptions changed; the mcp-tool-use evals were not run because they are paid.Claude Opus 5.5 via Claude Code.
🤖 Generated with Claude Code