Skip to content

feat(whatsapp): Allow whatsapp to share context - #104825

Closed
lisajlau wants to merge 2 commits into
NousResearch:mainfrom
lisajlau:whatsapp/group-context
Closed

lisajlau wants to merge 2 commits into
NousResearch:mainfrom
lisajlau:whatsapp/group-context

Conversation

@lisajlau

@lisajlau lisajlau commented Sep 7, 2026 •

Copy link
Copy Markdown

What does this PR do?

Adds opt-in observed-context sharing for the WhatsApp platform.

WhatsApp can now retain unmentioned messages from authorized group chats as
context, without dispatching those messages to the agent. When enabled, that
observed context can be supplied to future addressed messages in other
authorized WhatsApp groups and to an explicit allowlist of DM senders.

Related Issue

#38710
#38750
#104245

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • Add WhatsApp config support for:
    • observe_unmentioned_group_messages
    • share_observed_group_context
    • observed_group_context_dm_allow_from
    • observed_group_context_retention_days
  • Persist unmentioned messages from authorized WhatsApp groups as observed
    transcript entries rather than invoking the agent.
  • Preserve per-group observed context for later addressed messages in that
    group.
  • Optionally maintain a shared observed-context pool across authorized
    WhatsApp groups.
  • Attach shared context to eligible addressed group messages and allowlisted
    DMs as per-turn context, without modifying the system prompt or persisting
    it as user-authored content.
  • Label observed context and the current message so the model treats historic
    group chatter as context only, not as instructions.
  • Ensure the WhatsApp bridge applies DM allowlist checks only to DMs; group
    authorization remains governed by group_policy and group_allow_from.
  • Add coverage for passive observation, cross-group sharing, owner-DM access,
    retention expiry, and config bridging.

New behavior

With observe_unmentioned_group_messages: true, Hermes records messages from
authorized WhatsApp groups even when the bot is not mentioned, but does not
respond to those messages.

With share_observed_group_context: true, recent observed messages are shared
between authorized WhatsApp groups. They are also available in DMs only for
senders listed in observed_group_context_dm_allow_from.

Observed context is bounded by
observed_group_context_retention_days (default: 30 days) and is injected as
untrusted, context-only material for the current turn.

How to Test

Test in this order:

  1. Send a normal, untagged message in Dobbie House.
  2. Confirm Hermes stays silent.
  3. Send another untagged message.
  4. Mention Hermes in the group, or DM it from your approved number and ask for a summary.

Example of config.yaml to test

Start of yaml

platforms:
whatsapp:
enabled: true

  # Only observe/serve these trusted groups.
  group_policy: allowlist
  group_allow_from:
    - "120363001234567890@g.us"

  # Store non-mentioned messages without responding to them.
  observe_unmentioned_group_messages: true

  # Make observed context available across allowed WhatsApp groups,
  # and to explicitly approved DM senders.
  share_observed_group_context: true
  observed_group_context_dm_allow_from:
    - "owner@s.whatsapp.net"

  # Ignore observed messages older than this when assembling context.
  observed_group_context_retention_days: 30

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform:

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

For New Skills

  • This skill is broadly useful to most users (if bundled) — see Contributing Guide
  • SKILL.md follows the standard format (frontmatter, trigger conditions, steps, pitfalls)
  • No external dependencies that aren't already available (prefer stdlib, curl, existing Hermes tools)
  • I've tested the skill end-to-end: hermes --toolsets skills -q "Use the X skill to do Y"

Screenshots / Logs

@lisajlau lisajlau changed the title Allow whatsapp to share context feat(whatsapp): Allow whatsapp to share context Sep 7, 2026
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/gateway Gateway runner, session dispatch, delivery platform/whatsapp WhatsApp Business adapter area/config Config system, migrations, profiles sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages labels Sep 7, 2026
@alt-glitch

Copy link
Copy Markdown

This was generated by AI during triage.

Related: #104245 (broader observed-context implementation incl. shared gateway/observed_context.py) and #38750 both target the same #38710 feature. Competing approaches — flagging so reviewers can pick one rather than merge overlapping WhatsApp context-sharing paths.

@lisajlau
lisajlau force-pushed the whatsapp/group-context branch from 7d98c9b to 455b55e Compare September 8, 2026 06:58
@lisajlau

lisajlau commented Sep 9, 2026

Copy link
Copy Markdown
Author

Seems like there is now a pre_gateway_dispatch hook which runs whenever an inbound messaging event arrives. Let me know whether this change is still a good change, otherwise I'll just build this plugin.

@lisajlau lisajlau closed this Sep 22, 2026
@lisajlau
lisajlau deleted the whatsapp/group-context branch September 22, 2026 03:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have platform/whatsapp WhatsApp Business adapter sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants