Repository navigation
feat(threads): an agent reads, waits on, messages, steers and stops a thread it launched on another computer - #1310
Merged
Conversation
…ent's read on another computer The owner side of reading and waiting on a thread from another computer's agent (issue #1160): - runs.wait, a new routed read row: waits at most 40 s for a run of the thread to end or to wait on a person (needs_input), answered from the owner's run events. Without runId it waits on the run that is active or paused, or the one preparing; a thread with a message in its queue is never answered idle. The caller gives the call a 50 s deadline, under the minute an MCP client waits. - thread.messages version 3 takes index, textOffset and textMax: the page thread_read shows, built by the owner with the same rows its own agents get (messageRows), each text cut and the page held to 64 KB, so a long transcript does not cross. Refs #1160 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… thread it launched on another computer thread_read, thread_wait, thread_send, thread_steer and thread_interrupt take the qualified id thread_create with computer returns. Each handler branches at its top and hands the call to RemoteLaunchedThreads, whose reach() is the one place that decides which ids a caller reaches: a remote_launches row launched by the caller or a thread of its lineage; any other is refused with a code, never a bare not-found. approval_respond refuses a qualified id. - Reads use the routed read rows and ask for the tool's page; every id in a result is named the way this computer names it, origin.from included. - thread_wait waits there with runs.wait (polling runs.get every 4 s on an older computer) and says needsInput when the run waits on a person there. follow() is the same wait for a later follower. - Sends and steers are the marked orchestrator.send and orchestrator.steer, keyed by the request key; an unconfirmed write is uncertain. notify on such a send stays refused. - A person's Stop, deletion or expiry of the launcher sends a marked Stop to each launched thread. One not delivered is kept in its row (run database 22), survives a restart, is sent when the link returns and is given up after a day; the launcher's note says the run there may still be going. - The working-at-once cap of thread_create counts what each computer says is working. - Every call has a connect deadline apart from its own, and is tried once more a second later before the computer is called offline; refusals name the reason and the computer from that call's answer. Refs #1160 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…emons Reads with ids qualified, a wait that finishes and one that needs input, the polling fallback on an older computer, a send as the agent's and its replay, a steer into a looser run, a Stop of an agent's run and of a person's, a person's Stop of the launcher with the link up and down (delivered after a restart), the launcher deleted, the working count, and refusals: not launched here, offline after a retry, not allowed. Refs #1160 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… launched on another computer Refs #1160 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bvsr365
force-pushed
the
thread-tools-reach-other-computers
branch
from
November 15, 2026 22:08
2c84f8a to
f3e48f1
Compare
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.
Problem
After
thread_createwithcomputer, an agent holds the thread's qualified id (<node>:<id>), but no other thread tool accepts it. The agent cannot read the thread, wait for it, send it a follow-up, steer it or stop it, and a person's Stop of the launcher does not reach the work it started there.Change
thread_read,thread_wait,thread_send,thread_steerandthread_interruptnow work on a thread the calling thread (or a thread of its lineage) launched on another computer, and a person's Stop of the launcher reaches it.RemoteLaunchedThreads. Itsreach()is the one place that decides: aremote_launchesrow launched by the caller or its lineage, from a thread that is not private. Any other qualified id is refused with a code (not_launched_here,launch_abandoned,private_thread), never a bare not-found, and nothing is sent.approval_respondrefuses a qualified id.thread.messages(version 3) takesindex,textOffsetandtextMax: the owner builds the same rows its own agents get, each text cut and the page held to 64 KB, so a long transcript does not cross. The existing row could only page by message id, so an index page needed the new keys. The feat(threads): thread_read is bounded and reads on; agent messages are capped per sender #1222 bounds apply. Every id in a result is named the way this computer names it,origin.fromincluded.runs.wait: the owner waits at most 40 s on its run events and answers when the run ends or waits on a person. The caller's deadline is 50 s. A thread with a run preparing or a queued message is never idle. On a computer without the row, the wait asksruns.getevery 4 s. The result saysneeds_input/needsInput: truewhen the run waits on a person there.RemoteLaunchedThreads.follow()is the same wait, for the watch PR 11 adds (feat(threads): an agent that asks with notify is told when the other thread settles #1232's watch table is unchanged).orchestrator.sendandorchestrator.steerfrom feat(bridge): an agent's calls to another computer are marked, and that computer treats them more strictly than a person's #1235, keyed by the tool's request key; the result keepsdelivery. A write the computer did not confirm answersstatus: "uncertain".notifyon such a send is still refused, with clearer wording.thread_interruptis a markedorchestrator.abort; a run a person there took over is refused. A person's Stop, deletion or expiry of the launcher stores a Stop in eachremote_launchesrow (run database 22) and sends it. A Stop that is not delivered survives a restart, is resent when the link returns, and is dropped after a day; until then the launcher's note says the run there may still be going. A later message from here to that thread replaces a waiting Stop. An agent's own Stop does not cascade.thread_create's "10 launched threads working" now counts the threads each computer says are working. A thread on a computer that cannot be asked counts as working.computer_offline,computer_not_shared,computer_outdated,computer_not_allowed,remote_thread_gone).How to review
475426ac9: the owner side. The two row changes insrc/shared/bridge/routed.ts,runs.waitand theindexpage insrc/mms/protocol/handlers.ts,src/mms/run/runWait.ts, andmessageRows.ts(the rowsthread_readalready built, moved so both computers build them).36a2dc093: the caller side. Start withsrc/mms/orchestrator/RemoteLaunchedThreads.ts(reach,call,follow, the Stop pass), then the branches insrc/mms/run/mcp/appTools/thread.ts, then the wiring inOrchestratorService(Stop cascade, mark, working count) andMmsProfileServices(delete, expiry). Migration 22 adds the stop columns.6d74f17fb: the two-daemon test.f3e48f150: SPEC and the threat model.Where the risk is: the reach decision (the only gate before a call), the uncertain/offline split for writes (a send whose link drops after the connect step is reported uncertain and not retried), and a kept Stop that arrives late. A kept Stop asks the owner to stop only runs this computer's agents started, and a later message supersedes it.
Verification
Tier 5 (networking, persistence). All on
f3e48f150, rebased on mastera7f68778c:npx vitest runon 29 files, 600 tests passed (601 before the rebase; master changedbotThreadTools.test.ts):tests/net/bridge/routed/{threadToolsRemote,threadCreateRemote,agentMark,table,ids,paging,routerCalls,access,remoteSubagents}.test.ts,tests/run/{agentThreadReach,threadActionsTools,threadActionsDaemon,threadCreateTools,threadCreateDaemon,stopThread,mcpToolRegistry,appToolListing,botThreadTools,botAppTools,appToolBotGate,threadSettleNoticeDaemon,mousseMcpServer,subagentPolicy,profileDatabase,remoteSubagentEngine}.test.ts,tests/{gitAccessTable,contractVersions,threadPaging,mmsProtocolServer}.test.ts.npm run typecheckpassed. The first commit also typechecks on its own.tests/net/bridge/routed/threadToolsRemote.test.ts(new) runs the tools on two real daemons linked by Bridge. It covers events and messages read with ids qualified andtextOffsetreading on; a wait that finishes when the run ends there and one that answersneeds_input; the polling fallback when the far computer lacksruns.wait; a send that arrives as the agent's withorigin.from, whose replay with the same request id makes one run;notifyrefused; a steer into a looser run refused;thread_interruptstopping an agent's run and leaving a person's; a person's Stop of the launcher with the link up and with it down, delivered after a restart; the launcher deleted while idle; the working count (busy, idle, cannot be asked); a thread not launched here refused for all five tools with nothing sent; offline named after one retry; and not allowed after the switch was turned off. A table covers how ids are named,origin.fromincluded.follow()read onlyremote_launchesrows and the Bridge port, and the Stop cascade runs from the threadsstopSubtreereturns, whether or not a runtime is loaded.ThreadExpiryService(the hook is one line in its quiesce), and the one-day give-up of a kept Stop (REMOTE_STOP_DEADLINE_MS).Notes
Contract bump:
runDatabase21 → 22 (stop columns onremote_launches);botsDbstays at master's 10. Routed rows:thread.messages2 → 3, newruns.wait1. PR 11 (notifyacross computers) can callRemoteLaunchedThreads.follow; PR 12 widensRemoteLaunchedThreads.reach.Refs #1160
🤖 Generated with Claude Code