Skip to content

feat(agents): wake-on-message kernel producer — ADR-018 D8 - #899

Merged
lilyshen0722 merged 1 commit into
mainfrom
feat/wake-on-message-producer
Aug 12, 2026
Merged

lilyshen0722 merged 1 commit into
mainfrom
feat/wake-on-message-producer

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

What

The missing kernel half of ADR-018 D8. Sam asked whether the fleet does per-message attention yet — it didn't: wakeOnMessage appeared nowhere in the backend. This adds the producer.

Per-install opt-in: config.wakeOnMessage.enabled === true, default off, revertible (a setting, not a ratchet — D8 verbatim). On every message post, opted-in installs in the pod get a message.posted event. The claim layer does the coordination: kernel CAS (#892) + wrapper claim-before-act (#894) mean all wake, one acts — and CAS losers never even spawn, so arbitration costs zero model turns for everyone but the winner.

Guards, each tested:

  • Zero-cost default: no opt-ins → no queries beyond the installations array enqueueMentions already loads (asserted: Pod.findById never called).
  • Never self: an agent doesn't wake on its own post.
  • Mention wins: targets the mention path already enqueued are excluded — double delivery would burn a second turn on one trigger.
  • DM pods excluded: enqueueDmEvent already routes every message there.
  • Wake-storm dampener: bot-authored wakes are suppressed past Agent↔agent @mention acknowledgment loops aren't guarded (token waste) #508's threshold/window, counted on the message.posted type. Human messages are never dampened.

The inline frame (payload.content, not metadata) tells the woken agent it was not named, silence is the default, and acting starts with commonly_claim_message.

No driver change needed: message.posted is already in the CLI wrapper's prompt set and claimable set — deployed wrappers hear this the moment the kernel emits it (D5: no new event type).

Result-shape note

enqueueMentions now returns an additive woken: string[]. Two existing exact-shape assertions were extended with woken: [] — their intent (nothing enqueued) is unchanged, no assertion inversions.

Tests

7 new unit tests through the enqueueMentions boundary; 61/61 green across both mention suites. Mutation-checked: dropping the mention-dedup pass-through reddens exactly the double-delivery test.

Piloting after merge

Flip config.wakeOnMessage.enabled on the four Sharpen seat installs (no UI yet — deliberate; the pod-level "everyone always acts" mode composes later per D8), deploy, and post an unaddressed message in Sharpen: all four wake, one claims and answers, three ack claim-held without spawning.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XeUH4HVDsDHYPsHJthXjB8

Per-install opt-in (config.wakeOnMessage.enabled === true, default off,
revertible). On every message post, opted-in installs in the pod are woken
with a message.posted event; the claim layer (#892 kernel, #894 wrapper)
arbitrates who acts — all wake, one acts, and with claim-before-act the CAS
losers never even spawn.

The fan-out is deliberately dumb and cheap: zero opt-ins costs nothing
beyond the installations array the mention path already loads. Guards:
sender's own identity never wakes on its own post; mention-enqueued targets
are excluded (the mention is the stronger cue — double delivery would burn
a second model turn on one trigger); DM-shaped pods are excluded
(enqueueDmEvent already routes every message there); and bot-authored wake
storms are dampened on the message.posted count with #508's window and
threshold. Human-authored messages are never dampened.

The inline frame tells the woken agent it was NOT named, that silence is
the default, and that acting starts with a claim — payload.content, not
metadata, per the inline-cue rule. message.posted is already in the CLI
wrapper's prompt and claimable sets, so deployed wrappers hear this with no
driver change (D5).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XeUH4HVDsDHYPsHJthXjB8
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