Skip to content

feat(threads): an agent reads, waits on, messages, steers and stops a thread it launched on another computer - #1310

Merged
bvsr365 merged 4 commits into
masterfrom
thread-tools-reach-other-computers
Nov 15, 2026
Merged

bvsr365 merged 4 commits into
masterfrom
thread-tools-reach-other-computers

Conversation

@bvsr365

@bvsr365 bvsr365 commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

After thread_create with computer, 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_steer and thread_interrupt now 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.

  • Which threads. Each handler branches at its top on a qualified id and hands the call to a new service, RemoteLaunchedThreads. Its reach() is the one place that decides: a remote_launches row 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_respond refuses a qualified id.
  • Reading. Uses the existing routed read rows and asks for the tool's page. thread.messages (version 3) takes index, textOffset and textMax: 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.from included.
  • Waiting. One new routed read row, 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 asks runs.get every 4 s. The result says needs_input / needsInput: true when 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).
  • Messaging. Marked orchestrator.send and orchestrator.steer from 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 keeps delivery. A write the computer did not confirm answers status: "uncertain". notify on such a send is still refused, with clearer wording.
  • Stop. thread_interrupt is a marked orchestrator.abort; a run a person there took over is refused. A person's Stop, deletion or expiry of the launcher stores a Stop in each remote_launches row (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.
  • Working cap. 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.
  • Reachability. Each call reaches the computer first, with its own 10 s deadline, then runs with the call's deadline. A call that cannot reach the computer is tried once more a second later. A refusal names the reason and the computer from that call's answer (computer_offline, computer_not_shared, computer_outdated, computer_not_allowed, remote_thread_gone).

How to review

  1. 475426ac9: the owner side. The two row changes in src/shared/bridge/routed.ts, runs.wait and the index page in src/mms/protocol/handlers.ts, src/mms/run/runWait.ts, and messageRows.ts (the rows thread_read already built, moved so both computers build them).
  2. 36a2dc093: the caller side. Start with src/mms/orchestrator/RemoteLaunchedThreads.ts (reach, call, follow, the Stop pass), then the branches in src/mms/run/mcp/appTools/thread.ts, then the wiring in OrchestratorService (Stop cascade, mark, working count) and MmsProfileServices (delete, expiry). Migration 22 adds the stop columns.
  3. 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 master a7f68778c:

  • npx vitest run on 29 files, 600 tests passed (601 before the rebase; master changed botThreadTools.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 typecheck passed. 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 and textOffset reading on; a wait that finishes when the run ends there and one that answers needs_input; the polling fallback when the far computer lacks runs.wait; a send that arrives as the agent's with origin.from, whose replay with the same request id makes one run; notify refused; a steer into a looser run refused; thread_interrupt stopping 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.from included.
  • After the rebase: fix(threads): the service releases thread runtimes nothing uses, instead of keeping one for every thread it touched #1309's release of unused thread runtimes does not touch this work. Kept Stops and follow() read only remote_launches rows and the Bridge port, and the Stop cascade runs from the threads stopSubtree returns, whether or not a runtime is loaded.
  • Not checked: a real provider turn (turns are stood in for, as in feat(bridge): an agent's calls to another computer are marked, and that computer treats them more strictly than a person's #1235 and feat(threads): thread_create starts a thread on another of the user's computers #1290), expiry through 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: runDatabase 21 → 22 (stop columns on remote_launches); botsDb stays at master's 10. Routed rows: thread.messages 2 → 3, new runs.wait 1. PR 11 (notify across computers) can call RemoteLaunchedThreads.follow; PR 12 widens RemoteLaunchedThreads.reach.

Refs #1160

🤖 Generated with Claude Code

bvsr365 and others added 4 commits November 16, 2026 03:35
…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
bvsr365 force-pushed the thread-tools-reach-other-computers branch from 2c84f8a to f3e48f1 Compare November 15, 2026 22:08
@bvsr365
bvsr365 merged commit 2a0084a into master Nov 15, 2026
7 checks passed
@bvsr365
bvsr365 deleted the thread-tools-reach-other-computers branch November 15, 2026 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant