Skip to content

feat(threads): an agent that asks with notify is told when the other thread settles - #1232

Merged
bvsr365 merged 1 commit into
masterfrom
thread-settle-notice
Nov 15, 2026
Merged

bvsr365 merged 1 commit into
masterfrom
thread-settle-notice

Conversation

@bvsr365

@bvsr365 bvsr365 commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

An agent that messages another thread (thread_send, or thread_create with a first message) gets back only a run id. To hear the result it must call thread_wait in the same turn. An agent that ends its turn never learns that the other thread finished, and one that waits holds its own turn open for minutes.

Change

thread_send and thread_create take notify: true. Mousse then keeps one durable watch for that message and tells the sending thread when the work settles. The result says what to do next: "Mousse will tell you when it settles. Do not call thread_wait or thread_read to check. End your turn when nothing else is left."

  • Keyed on the message, not the run. The watch follows the message through a usage-limit pause into the run that continues it. For a queued message it follows the queue item through a person's edit (the drain gives the item a fresh queue:<itemId> run), a promotion to a steer, and a steer handed back. A queued message removed before it ran ends as "never ran".
  • At most two notices per watch: one the first time the work waits on a person (a question or an approval of that thread while the message's run is active), one when it ends. The first never uses up the second. After 24 hours the watch ends and the sender is told once, without starting a turn, that the work is still going.
  • A notice kind of its own (ChatMessage.settleNotice), written by Mousse. It carries the status, the reply cut to 2,000 characters with a pointer to thread_read, and the thread's mousse://thread/<id> link. The chat and the queue show it as a notice row: the thread as its thread chip (title and live status, a click opens it) and what happened there, not the person's message or an agent's bubble.
  • Delivery reuses the queue path that /goal turns use: a queue item with source thread-notice. It starts a turn when the sender is idle and runs after the current turn when the sender is busy. Notices that meet in the queue are delivered as one turn. A notice never starts a turn in a subagent's thread, in a sender a person stopped after it subscribed, in a sender kept in Plan, or for the 24-hour notice. There it waits in the queue (heldNotice) until a person sends it, the person's next turn (outside Plan) lets it run after, or a notice that may start a turn joins it. In a subagent's thread the waiting text joins the next continue_subagent follow-up.
  • Hops. The turn a notice starts carries the watched run's count of agent messages in a row and adds none of its own (noticeHops on the run). A sender and a target can go back and forth three times before a person must step in, and a thread that started several threads hears from each of them.
  • The limits on agent messages do not apply to a notice. The per-sender and total caps on queued agent messages (feat(threads): thread_read is bounded and reads on; agent messages are capped per sender #1222) count only queue items whose origin is an agent's, and the repeat refusal (duplicate_message) and the caps are checked only on an agent's send and queue commands. A notice item has no origin and is written into the sender's queue by Mousse (queueSettleNotice), so it is never refused by them and never takes an agent's place under the caps. The thread_send result keeps delivery (feat(threads): thread_read is bounded and reads on; agent messages are capped per sender #1222) and adds notify: { watchId, next }.
  • Wording. The thread_send and thread_create descriptions say to set notify when the result is needed. thread_wait is described as only for a turn that cannot continue without the answer. The agent instructions, SPEC §15.1 and the glossary match.

The watch's target (target_thread_id, target_node) is stored apart from the way it learns about the run (WatchTarget in src/mms/run/settle/follow.ts). The later notice for a thread on another computer adds a follower without changing the table.

How to review

  1. src/mms/run/settle/follow.ts, how a message is followed between runs, with its table in tests/run/settleFollow.test.ts.
  2. src/mms/run/settle/ThreadWatches.ts and migration 20 (thread_watches). Each decision is written as due before delivery and as sent after, so a restart delivers what was decided.
  3. src/mms/orchestrator/settleNotices.ts: when to tell, what the notice says, when it is held, and expiry.
  4. OrchestratorService.ts: startSettleNotices, queueSettleNotice, releaseHeldNotices, heldNoticesOf (the continue_subagent fold), the settleNotice field carried from the queue item to the turn's message, and Send now releasing a held notice. ThreadMessageQueue.ts: mergeSettleNotice, and the drain skipping held notices.
  5. thread.ts: the notify argument and the result wording.
  6. Renderer: the notice row in message-list.tsx, SubagentNotice.tsx and QueuedMessages.tsx.

Where the risk is: the queue drain now skips heldNotice items (claimNextNormal). A person's turn releases them only outside Plan and outside subagent threads.

Verification

Tier 5 (run engine and persistence). Tested commit: e9395f541, rebased on origin/master 9bcedd70c.

Run locally with npx vitest run --maxWorkers=3 <files>. All 33 files passed (860 tests):

  • New, one file per part of the claim:
    • tests/run/threadSettleNoticeDaemon.test.ts: a real orchestrator, run engine, effect worker and MCP server with scripted runtimes. It covers:
      • the end notice fires once, in a turn of its own, with the reply cut to 2,000 characters and the thread's link;
      • a needs-input notice comes first and does not use up the end notice;
      • the watch follows a person's edit of the queued message into its fresh run;
      • notices wait behind a busy sender and two of them run as one turn carrying the watched hop count;
      • the three-round hop limit;
      • no turn starts after a person's Stop (the person's next turn lets it run after), in Plan or in a subagent thread;
      • across a crash, the next daemon resumes a paused target and the sender hears once, about the continuation run.
    • tests/run/settleFollow.test.ts: the follow rules, including the pause continuation, a steer joined and a steer handed back.
    • tests/run/settleNoticeExpiry.test.ts: 24 hours tell the sender once, held; the work's later end tells nothing more.
    • tests/renderer/settleNoticeRow.test.ts: the mounted chat shows a notice row with the thread's chip, which opens it, not a user bubble and not the model's text.
    • tests/renderer/queuedMessagesInChat.test.ts: a queued notice row offers no Edit.
  • Existing files that touch the changed code: threadActionsDaemon, threadActionsTools, threadCreateDaemon, queueEditDaemon, threadCreateTools, mcpToolRegistry, queueHoldAfterStopRestart, usageLimitPause, profileDatabase, queueJournal, threadMessageQueue* (4 files), threadTitleText, queueTools, stopThread, botThreadTools, leaseRaceQueuedSend, queueSteerExactlyOnce, continueAfterRestart, nextSteerableQueueItem, findInThread, mcpAttachment, botThreadsDaemon, remoteSubagents, contractVersions (run database 19 → 20), and delegationGuidance (its inline snapshot of the agent instructions changes on purpose).
  • npx tsc --noEmit for tsconfig.node.json and tsconfig.web.json, and eslint on the changed files.

Not checked:

  • The real app: no screenshot of the notice row; it is the subagent notice row's look with the thread chip from feat(threads): a thread an agent started says so, and the thread that started it links to it #1224.
  • A real Claude Code or Codex agent reading the new wording and ending its turn instead of polling. The tests use hand-authored scripted runtimes.
  • The steer hand-back and the pause continuation without a restart are covered by the followMessage table, not end to end.
  • The 24-hour timer firing inside a running daemon. expireDue is called directly; the daemon arms the timer at start and on each new watch.
  • The continue_subagent fold of held notices has no test.

Notes

The watch table is run database migration 20 (18 is #1220's, 19 is #1235's). The notice for a thread on another computer is PR 11 of #1160 and builds on this.

Refs #1160

🤖 Generated with Claude Code

@bvsr365
bvsr365 force-pushed the thread-settle-notice branch from 763f005 to 1db25f2 Compare November 15, 2026 15:41
…thread settles

thread_send and thread_create take notify: true. Mousse keeps one durable
watch per message (run database v20, thread_watches) that follows it through
a re-queue, a steer handed back and a usage-limit pause, and tells the sender
once when the work waits on a person and once when it ends, or once without
a turn after 24 hours. The notice is Mousse's own kind (settleNotice), shows
the thread as its thread chip, goes through the sender's queue like a goal
turn, never starts a turn in a subagent, a stopped sender or one kept in Plan,
and carries the watched run's count of agent messages in a row.

Refs #1160

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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