Skip to content

feat(agentMentionService): unified inline cue composition (supersedes #416 + #417) - #420

Merged
samxu01 merged 1 commit into
mainfrom
feat/inline-cues-unified
May 22, 2026
Merged

feat(agentMentionService): unified inline cue composition (supersedes #416 + #417)#420
samxu01 merged 1 commit into
mainfrom
feat/inline-cues-unified

Conversation

@samxu01

@samxu01 samxu01 commented May 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Supersedes #416 (consultation cue) and #417 (reply-mechanics cue) per code-review feedback. Those two PRs both replaced the same const content = ... line in enqueueMentions — whichever landed second would hit a guaranteed merge conflict. Plus #416 didn't gate on eventType, so thread.mention events erroneously got the consultation cue.

This PR composes both cues in one place with explicit per-event-type gating.

Composition matrix (the cue layering rules)

Event type Target Cues prepended
chat.mention non-specialist (openclaw, etc.) Pod-context + Consultation + Reply-mechanics
chat.mention specialist (codex / cloud-codex / claude-code) Pod-context + Reply-mechanics (skip consultation — recursive self-consult is noise + loop risk)
thread.mention non-specialist Pod-context + Consultation (skip reply-mechanics — thread replies post via a different openclaw path with no clobber race)
thread.mention specialist Pod-context only

API

buildContentForTarget(podId, rawContent, eventType, targetAgentName)

Single helper called from all 3 enqueueMentions enqueue sites (direct-match, agentName fallback, mention-autoJoin).

Tests

5 cases in agentMentionService.test.js:

  • chat.mention + openclaw → all three cues present
  • chat.mention + codex → pod + reply, NO consultation
  • thread.mention + openclaw → pod + consultation, NO reply-mechanics
  • thread.mention + codex → pod only
  • claude-code parity (specialist gating works for claude-code too)

What's borrowed from #416 / #417 (now superseded)

Token cost

Per-event:

  • chat.mention + non-specialist: ~150 tokens (3 cues × ~50)
  • chat.mention + specialist: ~120 tokens (2 cues)
  • thread.mention + non-specialist: ~120 tokens (2 cues)
  • thread.mention + specialist: ~70 tokens (1 cue, unchanged)

Action for #416 + #417

Once this PR is reviewed + merged, close #416 and #417 with a "superseded by #420" comment.

🤖 Generated with Claude Code

samxu01 added a commit that referenced this pull request May 21, 2026
…artbeat templates (#419)

Adds a tight 'Consultation — when to phone a code specialist'
section to the heartbeat templates of theo (dev-pm), pixel
(frontend-engineer), and ops (devops-engineer). Nova (backend-
engineer) already has an elaborate sam-local-codex delegation
pattern, untouched here.

Per the user-reinforced strategic frame: openclaw agents stay
first-class for routine work; they CONSULT codex/claude-code
specialists via 1:1 DM only when their own tools hit a limit.
This is collaboration, NOT delegation.

Composes with PR #420 (unified inline cue composition for
chat.mention/thread.mention payloads) — heartbeat-template covers
autonomous heartbeats, payload cue covers @-mentions.

Per registry.js source-of-truth: fresh installs pick this up; live
dev agents with curated HEARTBEAT.md keep their version unless
config.customizations.heartbeat is force-overridden.

Closes #419.
…416 + #417)

Per code-review feedback on PR #416 + #417: those two PRs touch the
same content-build expression in enqueueMentions and have a mechanical
merge conflict — whichever lands second hits it. Plus #416 didn't gate
on eventType, so thread.mention events got the consultation cue
erroneously.

This PR composes both cues in one place with the correct 4-way matrix:

  chat.mention + non-specialist  → [Pod] [Collab] [Reply] body
  chat.mention + specialist      → [Pod] [Reply] body
  thread.mention + non-specialist→ [Pod] [Collab] body
  thread.mention + specialist    → [Pod] body

Rules:
- Pod-context cue: ALWAYS (existing behavior, untouched)
- Consultation cue: WHEN target agent is NOT a code specialist
  (codex / cloud-codex / claude-code). Both chat.mention AND
  thread.mention paths — code-help is a useful affordance in either
  context.
- Reply-mechanics cue: ONLY for chat.mention. thread.mention replies
  post via a different openclaw path and don't have the heartbeat-
  clobber race shape.

New helper: buildContentForTarget(podId, rawContent, eventType,
targetAgentName) — single place to extend the cue composition in
future iterations. Applied at all 3 enqueue paths (direct-match,
agentName fallback, mention-autoJoin).

Tests cover all 5 combinations (4 from the matrix + claude-code
parity check for specialist gating).

Closes #416 and #417 — both supersede here.

Also incorporates reviewer's suggestion to soften the 403 case in
the consultation cue: 'if you get a 403, they're not [a peer] —
skip', so agents don't silently fail when a specialist isn't in any
shared pod.
@samxu01
samxu01 force-pushed the feat/inline-cues-unified branch from be0db9d to 158d81b Compare May 22, 2026 10:01
@samxu01
samxu01 marked this pull request as ready for review May 22, 2026 10:19
@samxu01
samxu01 merged commit ffb0a83 into main May 22, 2026
10 checks passed
@samxu01
samxu01 deleted the feat/inline-cues-unified branch May 22, 2026 10:19
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