Skip to content

A first message in a pod reaches no agent — the mention gate returns before enqueue #834

Closed

Description

@lilyshen0722

A member's first message in a pod notifies nobody. Observed live in Commonly HQ on 2026-08-04: a new member posted 这个是什么 at 08:17Z and it sat unanswered for 13 hours.

Not a heartbeat problem, and not an agent-behavior problem — the event is never created. backend/services/agentMentionService.ts:621:

if (!podId || (rawMentions.length === 0 && !replyToMessageId)) {
  return { enqueued: [], implicit: [], skipped: [] };
}

A top-level message with no @mention and no replyTo returns before anything is enqueued. The implicit path added in #703 sits at line 899 and is gated on replyToMessageId, so it only ever covers replies — a first message is by definition neither.

Why this case specifically

HQ's pinned welcome promises "a support agent is a member of this pod and will usually answer within a minute." That promise holds only for people who know to type @commonly-support. Someone asking "what is this" definitionally does not know that yet, so the addressing burden lands on exactly the wrong party: the newcomer has to know the magic word in order to receive the answer that would have taught them the magic word.

HQ also auto-joins at verify/OAuth, so these members did not choose the room — they were placed in it and then asked to self-serve the introduction.

Shape of a fix

Narrow version: treat a member's first-ever message in a given pod as an implicit mention of that pod's support agent. It fires at most once per (member, pod), so it cannot degrade into the hourly-tick spam that #833 just closed, and it fits alongside the existing implicitReply branch rather than introducing a new mechanism.

General version belongs to ADR-017 / #769 — "unaddressed, but should wake someone" is precisely the attention-routing problem, and this is a concrete instance to design against rather than a hypothetical. Worth deciding there whether the narrow fix is the right permanent shape or just the stopgap.

Related: #769 (ADR-017 attention routing), #703 (implicit reply mention), #833 (heartbeat opt-in).

Activity

  1. lilyshen0722 commented on Aug 4, 2026

    @lilyshen0722
    ContributorAuthor

    Line numbers in the description are stale — corrected. The gate is agentMentionService.ts:721, not 621, and the #703 implicit path is :999, not 899. I read them from a worktree that was behind main, and they drifted further when #815 (which touches this file) merged about thirty minutes after this was filed. The code is unchanged; only the citations were wrong. Caught by @fable-lead on review.

    Verdict from review: ship the narrow fix, separately, now. The argument against absorbing it into ADR-017:

    Proxies calcify when the successor can't reproduce what users depend on. Here any future wake policy strictly supersedes "first message from a new member is wake-worthy" — it gets absorbed, not ripped out. It's a floor, not a ceiling.

    And a naming requirement that comes with it: call this first-message welcome wake, not "route unaddressed messages," and state the known miss in scope — the member whose day-30 question goes unanswered is not covered here.

    The principle that makes fire-once defensible, which I could not articulate when filing this: edge-triggered, not level-triggered. The trigger is a monotone state transition (never-spoken → spoken), so total fires are bounded by the state space — members × pods, amortized one per join — independent of traffic. Message-arrival and clock triggers are bounded only by traffic, and taming those needs the budget machinery ADR-017/#832 haven't shipped. #800's incident was a clock trigger: 11 wakes, 0 edges.

    That yields a reusable test for every future point-fix in this area: if the fire count is bounded by a finite state space, it can ship before the policy layer; if it's bounded only by traffic, it waits for budgets.

    Spec, sharpened

    1. Marker keyed (userId, podId) with a unique index and $setOnInsert upsert — no double-fire on races.
    2. Set the marker on the first message regardless of addressing; fire the wake only when the message is unrouted. Otherwise @codex help as message one makes message two trigger a welcome.
    3. Sender must be human — same isBot === false guard as :999, or an agent's first post in a pod seeds a loop.
    4. "The pod's support agent" is not first-class today. It needs an explicit designation (an AgentInstallation flag or pod config); without one this rule silently no-ops, which must be a stated precondition rather than a surprise.

    Item 4 is the one that could make this land as a no-op in production while passing every test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions