Repository navigation
fix(wake): the pod host stands down while a person's own agent greets them - #4224
commonly-agent wants to merge 1 commit into
Conversation
… them (F562) A person who starts their own hosted agent and writes at once got two answers to one message: the pod host, woken by the unaddressed message, and their agent's first-contact greeting. A hosted greeting always sees that message (hosted native turns inline recent pod messages, and the unseen-messages hold catches one that lands mid-turn). Its cue now tells it to answer what the person wrote, and its first_contact event is marked hostedGreeting. While such a greeting from the sender's own agent is in flight (pending, folding or delivered, under 60 s old), the host takes the message as a digest instead of a wake. Only the host stands down, only for a human sender, never when it is @mentioned, and a failed lookup wakes it as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MDs9DNuyu8j1BUsdEuiKcF
|
Caution Review failedThe pull request is closed. Walkthrough
Merge Risk:
|
commonly-agent
left a comment
There was a problem hiding this comment.
HEAD: 159a60f — GATE: HOLD
One review round, from an Opus subagent with a fresh context. Two findings block this.
-
The person can end up with no reply. The host turns its wake into a digest on the bet that the greeting will answer. Every first-contact greeting gets
hostedGreeting: truewhen the agent is provisioned on the native engine. But a greeting turn can exit without posting:- the daily turn cap, per install or per user, is reached;
- turns are configured to zero;
- the model is unavailable, the call fails or hits the wall clock;
- the model ends with NO_REPLY.
None of these exits posts for a first_contact, and none hands the message back to the host. Before this change, the host answered. That is a worse failure than the duplicate reply this PR removes.
-
Backend lint fails on an accidental
installKey =(edit.
Minor findings:
- A message can land between the greeting's freshness check and its ack.
- The lookup has no fitting index.
- The welcome-wake path still double-replies.
- The tests are mock-only.
A safe version needs a hand-back: wake the host on the person's unaddressed messages when a hosted first-contact run ends without posting. That means touching every decline exit in the native runtime, or holding the host's wake until the greeting's outcome is known. That costs more than the duplicate reply does. Today the second reply already sees the first, since the guard re-decides after an unseen message.
Closing this unmerged and parking the issue with that design note.
GATE: HOLD
|
Closing unmerged per the HOLD above. Deferring the host is only safe with a hand-back for every way a greeting can end without posting, and that costs more than the duplicate reply it removes. Parked with that design note. |
What was wrong
A person starts their own hosted agent in a pod and writes right away, mentioning nobody. Two things answer:
So the person gets two replies to one first message. In the case that surfaced this, the two runs started 163 ms apart.
The fix
The greeting answers the message. A hosted greeting always sees the person's message, by one of two paths:
HOSTED_NATIVE_RECENT_MESSAGES);agentSendFreshness) stops a post when a message landed after the turn started reading.Seeing it isn't answering it, so the hosted first-contact cue gains one line: if the person already wrote in this pod, answer that in the greeting. The event is also marked
hostedGreeting: true.The host stands down while that greeting runs. In
enqueueWakeOnMessage, the host's wake becomes a digest when four conditions hold:hostedGreetingfirst_contact that is pending, folding or delivered;The host still receives the message, just not as a turn, the same way the loop dampener demotes a wake.
Unchanged:
@scoutmention;A failed lookup wakes the host, so delivery wins when unsure.
Proof
New
agentMentionService.hostDefersToGreeting.test.js(6 cases), plus 2 cases infirstContactService.test.js. Related suites, containerized: 28 suites, 504 tests pass.Reverse check: main's
agentMentionService.tsandfirstContactService.tsswapped in, the fix's tests rerun:With the fix restored, all 42 pass.
Backend only, so it reaches prod with the next roll.
🤖 Generated with Claude Code
https://claude.ai/code/session_01MDs9DNuyu8j1BUsdEuiKcF