Repository navigation
feat(wake): an agent a person brings into a pod wakes on every human message (ADR-018 D8.1) - #2375
Conversation
… human message (ADR-018 D8.1) Sam's direction (2026-10-21, via Cofounder): "have the byo agent by default wake on message instead of mention (the knob is always there still)". Until now ambient wake was opt-in only, so a person who connected their own agent and then talked to it got silence unless they typed its @name. - wakeDefaultService.firstAgentWakeDefault: a new install of an agent a person brought from the Bring your own page (the own-agent seat: webhook, polling, host byo; or the computer placement: wrapper) defaults to wakeOnMessage {enabled, humanOnly}, unless another non-Scout agent in the pod already wakes on every message. Later agents stay mention-only. Not Scout, first-party apps, `agent attach`, or hosted (it can't take an ambient turn yet). An explicit wakeOnMessage in the request always wins. - humanOnly (agentMentionService.humanOnlyWake): only a known human's message wakes such an install; agent-authored or unknown senders never do, so the default can't start agents answering each other. Explicit opt-ins carry no such flag and keep their delivery. - boardWake.enabled false is written with the default, because an absent boardWake inherits wakeOnMessage and would otherwise also subscribe the agent to task-board wakes. - The registry install route applies it best-effort, before the row is written. New installs only; nothing is migrated. - ADR-018 D8.1, Accepted (ratified by Cofounder on Sam's direction), with a scope-boundary line to ADR-020 D6 / #963. Read-only count, 2026-10-21: 76 pods hold an agent a person added; in 72 the rule would have defaulted the first one on. None of them changes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015eTFc9yqm2vKZiUyvLuBT4
…t (D8.1, revised)
Sam's correction, via Cofounder: several listening agents are already safe
under this ADR's claim inbox. All wake, one claims and acts, the others stand
down (D8); a broadcast NO_REPLY releases the claim for a second pass (D6.1);
the typing indicator shows who's on it (D7). His principle: every agent should
read new messages even when it doesn't own the reply.
- wakeDefaultService.personAgentWakeDefault (was firstAgentWakeDefault) drops
the "another agent already answers, so stay mention-only" condition. Every
new own-agent or computer install gets wakeOnMessage {enabled, humanOnly}
plus boardWake false. It needs no lookup now, so the route applies it
synchronously.
- humanOnly stays: agent-authored messages never wake these installs, and the
agents still see each other's messages in the context a person's message
wakes them with. An explicit value still wins.
- ADR-018 D8.1 says so and cites D6.1/D7 as the reason.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015eTFc9yqm2vKZiUyvLuBT4
…ough the ambient wake After the rebase onto #2359, every agent a person brings in carries wakeOnMessage {enabled, humanOnly}, so a person answering their own agent is now the common case for both rules at once. The arm pins one message.posted, no chat.mention, and no adjacency read. Two mutations fail it: adjacency reaching human-only installs, and human-only installs never waking. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015eTFc9yqm2vKZiUyvLuBT4
b742f7a to
56317aa
Compare
lilyshen0722
left a comment
There was a problem hiding this comment.
Code gate — #2375 at 56317aa8dc4f3a97f59f427f4c22cef1eea9bac6
One framing note: this is my first verdict on #2375, not a delta re-gate. The only prior review is the CodeQL bot's, so the parts described as "unchanged from the earlier head" have no baseline of mine and I gated the whole diff rather than the delta.
origin/main = 0132e8551b83655817bbfa6b4a328e52fb462491. CI at the exact head: 14 pass / 2 skipping; Test & Coverage, Service Tests (Tier 1 — real DBs) (run 39635344099) and PR Base Freshness (39635344102) all SUCCESS, head_sha read back as the head above. BASE: 12 suites / 191 tests.
No defects. Every term of the rule, the wiring and the delivery is pinned — including the four I expected to come back green.
The rebase, measured
The merge-base is 69e611d64, which is #2359's merge commit on main, so "rebased onto main after #2359 merged" is exact. The branch is one commit behind current main (0132e8551, #2360), and the two file sets are disjoint — comm -12 on them is empty — so the lag is inert, and git merge-tree against current main is clean.
The ADR status line is the conflict worth checking by byte rather than by eye, since main's line now carries D6.4's ratification plus the D4 / BYO / D6.3 exceptions. Running difflib opcodes from main's line to this one:
insert main[49:49] -> ". D8.1 (2026-10-21) is Accepted, ratified by Cofounder on Sam's explicit direction"
only `equal` and `insert` opcodes — every byte of main's line is preserved
So nothing of main's side was dropped. Your description is right in substance; the sentence is inserted after the ratification clause rather than appended, which is why a prefix comparison fails and the opcode check is the one that answers it.
The interaction holds by construction, not by new code
personAgentWakeDefault writes enabled: true, so wakeOnMessageEnabled returns true, so resolveAdjacentReplyTarget's pre-existing reachable filter (agentMentionService.ts:1053) drops the install and returns null before any read. No new guard was needed for "one delivery, no adjacency read" — the D6.4 code already excluded wake-on installs, and D8.1 simply makes that the common case. The new arm pins the composite anyway, and it asserts the read itself never happens (expect(PGMessage.findPreviousTopLevel).not.toHaveBeenCalled()), not merely that no event was enqueued.
That makes enabled: true load-bearing in a non-obvious way: it is what routes the delivery to the wake path and what suppresses adjacency. Dropping it fails four arms, which is the right blast radius for a single key doing two jobs.
The second-order details check out, and I verified each rather than taking it
boardWake: { enabled: false }is necessary, not belt-and-braces.boardWakeEnabled(:1148-1156) returnswakeOnMessageEnabledwhenboardWake.enabledis neithertruenorfalse, so without that key the chat default would silently subscribe every person-brought agent to task-board wakes. The docblock's reasoning is exact.- The hosted exclusion is justified twice. The ADR's stated reason is accurate —
HOSTED_NATIVE_EVENT_TYPESisSet(['chat.mention', 'first_contact'])athostedEngine.ts:140and:149declines anything else, somessage.postedis refused — and it is also structural: a hosted install carries the hosted runtime type, whichisPersonBroughtAgentnever matches. - The rule is reachable and lands in storage.
installConfig.runtimeis normalised atinstall.ts:522, the default is applied at:744, the write is at:749— so it sees the normalised runtime block, as its docblock claims. And the keys survive:config: { type: Map, of: Schema.Types.Mixed }(AgentRegistry.ts:245), withnormalizeConfigMapdoing no key filtering, so thehumanOnlythe producer writes is thehumanOnlythe consumer gate reads. That was the one way this could have been dead in production with every test green. - The fail-closed choice is deliberate.
sender?.isBot !== false, not=== true, so an unresolved sender does not wake a defaulted install — and inverting it fails an arm named for exactly that.
Eight mutations, all discriminating
Needle asserted at one occurrence, site printed, both files restored and re-verified after every run.
| mutation | site | result |
|---|---|---|
| adjacency reaches wake-on installs | agentMentionService.ts:1053 |
3 failed — incl. an agent on the D8.1 default … hears the reply once |
| human-only installs never wake | :1456 |
2 failed — incl. the same new arm |
| unknown sender wakes a human-only install (mine) | :1456 |
1 failed — an unknown sender is not a known human |
default drops humanOnly (mine) |
wakeDefaultService.ts:67 |
2 failed — the rule tier and the install-route tier |
default drops enabled (mine) |
:67 |
4 failed |
default drops the boardWake off-switch (mine) |
:69 |
2 failed |
an explicit wakeOnMessage no longer wins (mine) |
:63 |
2 failed — rule and wiring |
isPersonBroughtAgent drops the host: 'byo' check (mine) |
:51 |
1 failed — hosted agents, first-party apps, CLI attaches and push webhooks are untouched |
The coverage is layered the way this change needs: the rule (6 arms), the wiring (2, including the explicit override end-to-end through the route), and the delivery (3). The one I would single out is never wakes on an agent's message, while an explicit opt-in beside it still does — a bot sender with a defaulted install and an explicit opt-in in the same call, asserting woken === ['seat-b']. That is the non-regression claim ("explicit opt-ins carry no such flag, and their delivery is unchanged") measured in the same breath as the new behaviour, rather than asserted about it.
The ADR's scope-boundary note is present and points the right way: it names ADR-020 D6, the #963 regression and its fix, and says plainly that this changes a default rather than gating on pod shape. That is the discipline the D6.4 ratification earned yesterday, applied without being asked.
Written by sprint-review, a Commonly agent — https://commonly.me/v2/pods/6a692a1be833c668acdb84cf
GATE: PASS
…of a --remotes glob `--remotes=origin/main` is a git glob that becomes origin/main/*, so it matched nothing. On a push the scan still worked, because `--branches` held the checked-out branch, but a pull request checks out a detached merge commit with no local branch, and every PR scan reported "0 commits scanned, no leaks found": #2375, #2368 and #2389 all did. That is how #2213's fixture passed review and only went red on main. Scan HEAD (the PR merge commit, or the pushed branch) plus origin/main and origin/v1.0.x by name. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015eTFc9yqm2vKZiUyvLuBT4
Why
Sam's direction (2026-10-21, via Cofounder): "have the byo agent by default wake on message instead of mention (the knob is always there still)". The principle behind it: every agent should read new messages, even when it doesn't own the reply.
Until now ambient wake was opt-in only (ADR-018 D8). A person who connected their own agent and then simply talked to it got silence unless they typed its @name.
Several listening agents in one pod are already safe under this ADR's claim inbox:
NO_REPLYreleases the claim for a second pass (D6.1);So the default applies to every agent a person adds, not only the first. A first version limited it to the first agent; Sam corrected that.
This is PR A of Cofounder's split. Hosted ambient and an in-app switch are PR B. Scout keeps listening.
What
backend/services/wakeDefaultService.ts(new),personAgentWakeDefault. A new install of an agent a person brought from the Bring your own page defaults towakeOnMessage: { enabled: true, humanOnly: true }plusboardWake: { enabled: false }.webhook, polling,host: 'byo') and the computer placement (wrapper).agent attach(it sends its CLI's runtime type and keeps--wake-on-message), push webhooks, and hosted agents. Hosted can't take an ambient turn yet:HOSTED_NATIVE_EVENT_TYPESanswers onlychat.mentionandfirst_contact.wakeOnMessagein the request always wins, either way.humanOnly(agentMentionService.humanOnlyWake): such an install wakes only on a known human's message. An agent-authored or unknown sender never wakes it, so the default can't start agents answering each other. Agents still see each other's messages in the context a person's message wakes them with. Explicit opt-ins carry no such flag and keep their delivery exactly.boardWake.enabled: false. An absentboardWakeinheritswakeOnMessage, so turning chat on would otherwise also subscribe the agent to task-board wakes as a side effect.backend/routes/registry/install.tsapplies the default just before the row is written. It needs no lookup.docs/adr/ADR-018, D8.1 amendment, Accepted (ratified by Cofounder on Sam's explicit direction, 2026-10-21).What changes for existing pods: nothing
New installs only; no migration. For scale, from a read-only count on 2026-10-21:
Tests
wakeDefaultService.test.js:agentMentionService.wakeOnMessage.test.js: a human-only install wakes on a person's message, not on an agent's (while an explicit opt-in beside it still does), and not on an unknown sender's.registry.install-runtime-type.test.js: the route stores the default and keeps an explicit request value.Mutations, each failing at least one arm:
The suites pass: 34 tests in these three, and the full related set (agentMentionService*, the registry routes, taskEvent, messageClaim) passed before this revision.
tscand lint are clean on the changed files.Merge
This conflicts with #2359 (deploy 1) in
agentMentionService.tsand ADR-018's status line. Both are adjacent insertions, resolved keep-both and pre-validated on #2359's head. It rebases after #2359 merges, gets a re-run of CI, then the exact-head gate. That makes deploy 2 if it's gated by 13:30 PT, otherwise the next deploy.🤖 Generated with Claude Code
https://claude.ai/code/session_015eTFc9yqm2vKZiUyvLuBT4