#17779: feat: include group_members in inbound user context metadata
stale
size: XS
Cluster:
Bluebubbles iMessage Fixes
## Summary
- Adds `group_members` to the `conversationInfo` object in `buildInboundUserContextPrefix`, so the LLM can see group participant identifiers (phone numbers, usernames) in the per-message "Conversation info (untrusted metadata)" block
- The `GroupMembers` field was already populated by channel plugins (WhatsApp, iMessage, BlueBubbles) and used in the system prompt via `buildGroupChatContext`, but was missing from the user-role context prefix — meaning the model couldn't see who was in a group chat from the message metadata
## Motivation
In group chats (especially BlueBubbles/iMessage), the model receives `Sender` metadata showing who sent the current message, but has no visibility into the other participants. This makes it impossible to distinguish or address individual members. The system prompt line from `buildGroupChatContext` ("Participants: ...") helps, but only on first message — per-message context should also carry this information since the roster can change.
## Test plan
- [x] Added two test cases to `inbound-meta.test.ts`:
- Verifies `group_members` appears when `GroupMembers` is set
- Verifies `group_members` is omitted when `GroupMembers` is unset
- [ ] Verify existing tests pass (`vitest run src/auto-reply/reply/inbound-meta.test.ts`)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Added `group_members` field to the per-message conversation info metadata block in `buildInboundUserContextPrefix`. The `GroupMembers` context field was already being populated by channel plugins (BlueBubbles, WhatsApp, iMessage) and used in the system prompt via `buildGroupChatContext`, but was missing from the user-role untrusted metadata that accompanies each message. This enables the model to see the complete list of group participants (phone numbers, usernames) in every message's context, not just in the initial system prompt.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The change is a simple one-line addition that follows established patterns in the codebase. It exposes an existing field (`GroupMembers`) that is already being populated by channel plugins and is properly sanitized via `safeTrim`. The implementation is consistent with other fields in the same object, includes comprehensive test coverage, and addresses a legitimate gap in the per-message context metadata.
- No files require special attention
<sub>Last reviewed commit: 78d11ee</sub>
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#18664: fix(imessage): honor groupConfig regardless of allowlistEnabled
by brandonwise · 2026-02-16
75.7%
#23705: BlueBubbles: enrich webhook group participants from chat metadata
by marc726 · 2026-02-22
75.2%
#20301: Security: scrub untrusted metadata from user-facing replies
by ashishc2503 · 2026-02-18
74.8%
#4402: fix: store group messages from non-allowlisted senders as pending c...
by adam91holt · 2026-01-30
74.5%
#23271: fix(chat): strip untrusted metadata blocks from Control UI messages
by lbo728 · 2026-02-22
74.4%
#4390: fix(whatsapp): allow media from allowlisted groups without groupAllow…
by Sarang19114 · 2026-01-30
74.4%
#15148: auto-reply: add message_time and compact inbound metadata JSON
by detecti1 · 2026-02-13
74.4%
#23579: feat(whatsapp): add sender attribution to inbound message logs
by svan058 · 2026-02-22
74.3%
#11611: feat: separate group-level allowlist from sender-level command auth...
by thisnick · 2026-02-08
73.8%
#5665: fix: match group JIDs in groupAllowFrom allowlist
by koala73 · 2026-01-31
73.0%