Skip to content

fix(messaging): let the operator choose the Hermes WhatsApp mode - #8423

Open
hunglp6d wants to merge 15 commits into
mainfrom
fix/whatsapp-mode-input
Open

fix(messaging): let the operator choose the Hermes WhatsApp mode#8423
hunglp6d wants to merge 15 commits into
mainfrom
fix/whatsapp-mode-input

Conversation

@hunglp6d

@hunglp6d hunglp6d commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

The WhatsApp channel manifest rendered WHATSAPP_MODE=bot as a constant, so neither Hermes mode was reachable and a freshly onboarded sandbox could not deliver a message: bot rejects every sender when the allowlist is empty, and onboarding never collects one. The mode becomes a manifest input carrying the Hermes adapter's own self-chat default, so a paired sandbox replies with nothing else configured, and selecting bot stays a deliberate act. OpenClaw is unchanged.

Related Issue

Addresses part of #8312

Changes

  • src/lib/messaging/channels/whatsapp/manifest.ts — add a mode input (envKey: WHATSAPP_MODE, statePath: whatsappConfig.mode, validValues: ["self-chat", "bot"], defaultValue: "self-chat") and render WHATSAPP_MODE={{whatsappConfig.mode}} instead of the constant.
  • src/lib/messaging/channels/whatsapp/template-resolver.ts — resolve whatsappConfig.mode, following the telegramConfig.groupPolicy precedent.
  • src/lib/messaging/channels/whatsapp/rendered-config-parser.ts — list the mode beside the allowlist so channels status shows both. The mode decides whether an empty allowlist matters, and the existing WHATSAPP_ALLOWED_IDS: not set line carried no such context.
  • docs/manage-sandboxes/set-up-whatsapp.mdx — add a Hermes-only "Reply to Other Senders" section, and qualify the existing allowlist sentence, which was written when bot was the only mode.

The input declares no prompt. Onboarding asks nothing extra; bot is selected the same way allowedIds already is, by exporting the variable before channels add. That path is not a new mechanism: manifest-compiler.ts:322 already prefers an input's env value over its default, and workflow-planner.ts:302 already lets an incoming channel replace a stored one. host-state-applier.test.ts now pins that replacement, since the documented reconfiguration flow depends on it.

Two behavior changes worth calling out:

  1. A sandbox already running bot renders self-chat after its next rebuild. Its persisted plan has no mode input, so the manifest default applies. Verified against production code (normalizePersistedInputs plus the resolver). A migration rule keyed on "allowlist present implies bot" was considered and rejected: the documented way to select WhatsApp non-interactively is to export WHATSAPP_ALLOWED_IDS, so that rule would silently place new sandboxes into the mode this issue is about. Affected operators re-run the command in the new docs section.
  2. Exporting WHATSAPP_MODE now selects the channel non-interactively for either agent, including OpenClaw, where the mode is not rendered. WHATSAPP_ALLOWED_IDS already behaves this way; inputs cannot be scoped per agent today (agents: exists on hooks, not on ChannelInputBaseSpec).

Type of Change

  • Code change (feature, bug fix, or refactor)
  • Code change with doc updates
  • Doc only (prose changes, no code sample modifications)
  • Doc only (includes code sample changes)

Quality Gates

  • Tests added or updated for changed behavior
  • Existing tests cover changed behavior — justification:
  • Tests not applicable — justification:
  • Docs updated for user-facing behavior changes
  • Docs not applicable — justification:
  • Sensitive paths changed (security, policy, credentials, preflight, onboarding, inference, runner, sandbox, or messaging)
  • Sensitive-path review completed or maintainer-approved waiver recorded — reviewer/approval link/justification: fix(messaging): let the operator choose the Hermes WhatsApp mode #8423 (comment)
  • Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue:

Documentation Writer Review

  • Documentation writer subagent reviewed the completed changes
  • Result: docs-updated
  • Evidence: docs/manage-sandboxes/set-up-whatsapp.mdx. Codex Desktop re-reviewed the completed revision after adding the legacy rebuild behavior, post-change channels status verification, and explicit wildcard warning. npm run docs passed with 0 errors and 2 repository warnings.
  • Agent: Codex Desktop

DGX Station Hardware Evidence

  • Tested on DGX Station
  • Tested commit:
  • Station profile/scenario:
  • Result:
  • Supporting evidence:

Verification

  • PR description includes a Signed-off-by: line and every commit appears as Verified in GitHub
  • Normal pre-commit, commit-msg, and pre-push hooks passed, or npm run validate:pr passed after refreshing origin/main when hooks were skipped or unavailable
  • Targeted behavior tests pass for the current change set, or tests are marked not applicable above — command/result or justification: npx vitest run --project cli src/lib/messaging/channels/whatsapp/ src/lib/messaging/applier/host-state-applier.test.ts src/lib/messaging/channels/metadata.test.ts src/lib/messaging-channel-config.test.ts src/lib/onboard/messaging-channel-setup.test.ts — 170 passed; npx vitest run --project integration test/generate-hermes-config.test.ts — 54 passed. npx vitest run --changed origin/main --project cli --project plugin --project e2e-support reports 9165 passed and 18 failed; the same 18 fail on a clean origin/main checkout (state-file-key-merge-behavior, state-file-key-merge-file-safety, created-sandbox-finalization) and are unrelated to this change.
  • Applicable broad gate passed — npm test for broad runtime/test-harness changes; npm run check for repo-wide validation/coverage changes — command/result: not applicable; this change is scoped to one channel manifest and its tests. npm run checks:repository passed (layer import boundaries, source architecture budget, vitest project membership, test title style).
  • Quality Gates section completed with required justifications or waivers
  • No secrets, API keys, or credentials committed
  • npm run docs builds without warnings (doc changes only) — Found 0 errors and 2 warnings. Fern does not enumerate the two warnings in the build output; they are not attributable to this page from the build alone.
  • Doc pages follow the style guide (doc changes only)
  • New doc pages include SPDX header and frontmatter (new pages only)

Live verification

Built from this branch on a CPU sandbox (Hermes v0.19.0, OpenShell docker driver) and exercised through the normal commands.

Default onboard, after channels add whatsapp and rebuild:

$ nemoclaw <sandbox> exec -- sh -c 'grep -E "^WHATSAPP_" /sandbox/.hermes/.env'
WHATSAPP_ENABLED=true
WHATSAPP_MODE=self-chat

$ nemoclaw <sandbox> channels status --channel whatsapp
    [ok] Channel registration: whatsapp registered
    [ok] Policy coverage: whatsapp preset applied
    [ok] WHATSAPP_MODE: self-chat (default)
    [info] WHATSAPP_ALLOWED_IDS: not set

The documented reconfiguration, run verbatim on the same sandbox:

$ WHATSAPP_MODE=bot WHATSAPP_ALLOWED_IDS=15551234567 nemoclaw <sandbox> channels add whatsapp
$ nemoclaw <sandbox> rebuild --yes
$ nemoclaw <sandbox> channels status --channel whatsapp
    [ok] WHATSAPP_MODE: bot
    [ok] WHATSAPP_ALLOWED_IDS: 15551234567

That also confirms the stored value is replaced rather than kept.

QR pairing completed on the same sandbox and wrote 892 files to /sandbox/.hermes/platforms/whatsapp/session. An inbound message was not exchanged on this host: the gateway logged [Whatsapp] npm install failed: and left the bridge down, although node_modules is present in both bundled bridge trees. That failure is independent of this change, which only decides the rendered value.


Signed-off-by: Hung Le hple@nvidia.com

Summary by CodeRabbit

  • New Features

    • Added WhatsApp mode selection, with self-chat as the default and bot mode as an alternative.
    • Added visibility for WhatsApp mode and allowed-sender settings.
    • Documented allowlists, sender IDs, wildcard usage, self-chat behavior, and required restart steps.
  • Bug Fixes

    • Fixed WhatsApp configuration updates when changing modes.
    • Added fallback handling for empty or invalid mode values.

The manifest rendered `WHATSAPP_MODE=bot` as a constant, so neither mode was
reachable. Bot mode rejects every sender when the allowlist is empty, and
onboarding never collects one, so a freshly onboarded Hermes sandbox with
WhatsApp paired could not deliver a message.

The value is also an override. The Hermes adapter reads
`os.getenv("WHATSAPP_MODE", "self-chat")`, and self-chat reads no allowlist at
all, so leaving the key unset is the configuration that works. NemoClaw replaced
that with the one mode that needs a value it never asks for.

Make the mode an input carrying that same default, with no prompt, matching the
shape `allowedIds` already has. Onboarding asks nothing extra and a paired
sandbox replies. Selecting bot stays a deliberate act:

  WHATSAPP_MODE=bot WHATSAPP_ALLOWED_IDS=<number> nemoclaw <sandbox> channels add whatsapp

Verified live on a Hermes sandbox before the change: with self-chat and no
allowlist, a message to the paired account's own chat reached the agent and was
answered; with bot mode and `WHATSAPP_ALLOWED_IDS='*'`, a message from a second
number was answered as well.

`channels status` now lists the mode beside the allowlist, since the mode
decides whether an empty allowlist matters.

Signed-off-by: Hung Le <hple@nvidia.com>
@copy-pr-bot

copy-pr-bot Bot commented Aug 6, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Hermes WhatsApp mode is configurable through WHATSAPP_MODE. The default is self-chat; bot mode remains supported with allowlisted senders. Rendering, state merging, tests, onboarding, runtime checks, and documentation reflect the new behavior.

Changes

Hermes WhatsApp mode configuration

Layer / File(s) Summary
Define WhatsApp mode configuration
src/lib/messaging/channels/whatsapp/manifest.ts, src/lib/messaging/channels/whatsapp/rendered-config-parser.ts, src/lib/messaging/channels/*/metadata.test.ts, src/lib/messaging-channel-config.test.ts
The manifest defines self-chat and bot modes with a self-chat default. Hermes configuration visibility and key tests include WHATSAPP_MODE.
Render and merge configured mode
src/lib/messaging/channels/whatsapp/template-resolver.ts, src/lib/messaging/channels/whatsapp/manifest.ts, src/lib/messaging/applier/host-state-applier.test.ts, test/messaging-plan-test-helper.ts
Template resolution accepts supported persisted modes and falls back to self-chat. Hermes renders the configured mode. Configuration merging replaces the stored WhatsApp mode. Test helpers propagate the mode to Hermes environment output.
Validate setup and document behavior
src/lib/messaging/channels/whatsapp/template-resolver.test.ts, test/generate-hermes-config.test.ts, src/lib/onboard/messaging-channel-setup.test.ts, test/e2e/live/channels-stop-start-helpers.ts, docs/manage-sandboxes/set-up-whatsapp.mdx
Tests cover default, explicit, invalid, and persisted modes. Onboarding and runtime checks expect self-chat. Documentation describes bot-mode allowlists, sender IDs, wildcard usage, rebuilds, and gateway restarts.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Onboarding
  participant WhatsAppManifest
  participant HostState
  participant HermesConfig
  Onboarding->>WhatsAppManifest: seed mode self-chat
  Onboarding->>HostState: store mode and allowlist
  HostState->>HermesConfig: render WhatsApp settings
  HermesConfig-->>HermesConfig: use self-chat or bot mode
Loading

Possibly related PRs

  • NVIDIA/NemoClaw#7718: Updates messaging onboarding plan handling and plan-derived configuration behavior.

Suggested labels: bug-fix, area: messaging, integration: whatsapp, integration: hermes

Suggested reviewers: senthilr-nv

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR adds configurable Hermes mode and self-chat defaults but omits several #8312 requirements, including onboarding prompts, allowlist clearing, health diagnostics, and OpenClaw wiring. Implement the remaining #8312 requirements or split them into linked follow-up changes with explicit scope.
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Out of Scope Changes check ✅ Passed The documentation, implementation, configuration tests, integration tests, and regression tests directly support the WhatsApp mode objective.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: making the Hermes WhatsApp mode configurable.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/whatsapp-mode-input

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

@github-code-quality

github-code-quality Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall coverage in commit 7d241c0 in the fix/whatsapp-mode-in... branch remains at 96%, unchanged from commit c31724f in the main branch.


Updated August 07, 2026 10:56 UTC

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

PR Review Advisor — No blocking findings reported

Advisor assessment: No blocking advisor findings reported
Next action: Review the warnings below.
Findings: 0 blockers · 1 warning · 0 suggestions

Model lanes

  • GPT-5.6 Terra (primary): Completed · high confidence · 0 blockers · 1 warning · 0 suggestions
  • Nemotron 3 Ultra (second opinion): Failed after a partial review · low confidence · 0 blockers · 0 warnings · 0 suggestions

Second-opinion terminology and E2E selections are advisory. Live E2E does not run automatically for pull requests.

3 semantic terminology decisions

Terminology decisions are advisory. They affect the assessment only when a separate finding identifies concrete semantic impact.

  • define — self-chat at docs/manage-sandboxes/set-up-whatsapp.mdx:92: Keep the changed documentation definition and contrast with bot mode.
  • define — bot mode at docs/manage-sandboxes/set-up-whatsapp.mdx:103: Keep the changed documentation definition, including the empty-allowlist result.
  • established — sender allowlist at docs/manage-sandboxes/set-up-whatsapp.mdx:73: Keep the established term and the added mode-specific qualification.

E2E guidance

Advisory only. A maintainer can dispatch the default E2E suite against this exact revision.

Recommended E2E: cloud-inference, cloud-onboard, managed-image-multiarch-startup, security-posture, channels-add-remove, channels-stop-start

1 warning · 0 suggestions

Warnings

Warnings do not block.

PRA-1 Warning — Add direct coverage for WhatsApp rendered configuration visibility

  • Location: src/lib/messaging/channels/whatsapp/rendered-config-parser.ts:13
  • Category: tests
  • Problem: The parser now exposes the WhatsApp mode status key, but no focused test verifies the Hermes key set, OpenClaw exclusion, or mode-value extraction.
  • Impact: A future change can omit the mode from Hermes status, expose it for OpenClaw, or read the wrong environment value without a focused test failure.
  • Recommendation: Add a WhatsApp rendered-config parser test that asserts Hermes returns mode and allowedIds, OpenClaw returns no keys, and getValue reads WHATSAPP_MODE from an env source.
  • Verification: Read a new whatsapp rendered-config parser test and confirm it invokes listConfigVisibilityKeys for both agents and getValue with WHATSAPP_MODE=bot.
  • Test coverage: A unit test for whatsappRenderedConfigParser that checks the Hermes and OpenClaw key sets and extracts WHATSAPP_MODE=bot.
  • Evidence: src/lib/messaging/channels/whatsapp/rendered-config-parser.ts:11-24 adds the mode visibility key and preserves the Hermes-only branch. src/lib/messaging/channels/manifests.test.ts:51-73 validates key ownership but does not assert WhatsApp's returned key set or getValue behavior. src/lib/messaging/channels/telegram/rendered-config-parser.test.ts:8-108 demonstrates focused parser key and extraction coverage for another channel.

Workflow run details

This automated review informs maintainers. Warnings and suggestions do not require a response. A maintainer decides whether to merge.

@copy-pr-bot

copy-pr-bot Bot commented Aug 6, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@hunglp6d
hunglp6d marked this pull request as ready for review August 6, 2026 07:00

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/manage-sandboxes/set-up-whatsapp.mdx`:
- Line 90: In the WhatsApp adapter sentence, replace the American-English
spelling “afterwards” with “afterward,” preserving the rest of the wording and
meaning.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 57bf1b12-3439-465a-9313-127f69b703af

📥 Commits

Reviewing files that changed from the base of the PR and between 2f29784 and 0c57526.

📒 Files selected for processing (12)
  • docs/manage-sandboxes/set-up-whatsapp.mdx
  • src/lib/messaging-channel-config.test.ts
  • src/lib/messaging/applier/host-state-applier.test.ts
  • src/lib/messaging/channels/metadata.test.ts
  • src/lib/messaging/channels/whatsapp/manifest.ts
  • src/lib/messaging/channels/whatsapp/rendered-config-parser.ts
  • src/lib/messaging/channels/whatsapp/template-resolver.test.ts
  • src/lib/messaging/channels/whatsapp/template-resolver.ts
  • src/lib/onboard/messaging-channel-setup.test.ts
  • test/e2e/live/channels-stop-start-helpers.ts
  • test/generate-hermes-config.test.ts
  • test/messaging-plan-test-helper.ts

Comment thread docs/manage-sandboxes/set-up-whatsapp.mdx Outdated
Signed-off-by: Hung Le <hple@nvidia.com>
A rebuild renders from the persisted plan, and neither persistence path
re-applies the input's validValues: normalizeFullInputs copies `value`
verbatim, and inputReferenceFromManifest copies `persisted.value` onto the
manifest spec. A stale or hand-edited registry entry could therefore render a
WHATSAPP_MODE the bundled bridge cannot serve, leaving a channel that reports
itself configured and answers nobody.

Re-check the value where it is rendered and fall back to the mode the Hermes
adapter already defaults to.

The earlier fallback test exercised the env-to-compiler path, where validValues
already drops an unusable value, so it could not have caught this. Both
persistence paths now have a case.

Signed-off-by: Hung Le <hple@nvidia.com>
"Refer to the section below" and "set both values together" both left the
reader to infer the target. Name the section and the two environment variables
instead.

Signed-off-by: Hung Le <hple@nvidia.com>
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
@apurvvkumaria

Copy link
Copy Markdown
Collaborator

Maintainer security and gate audit completed for revision b0f04cde7.

Review area Result Evidence
Secrets and credentials Pass No secret material or credential handling changed. The new mode is ordinary non-secret configuration.
Input validation Pass The manifest accepts only self-chat or bot; the renderer independently falls back to self-chat for missing, empty, or invalid persisted values.
Authentication and authorization Pass The change does not widen sender access. Bot mode still relies on the existing sender allowlist, and an empty allowlist denies other senders.
Dependencies and supply chain Pass No dependencies, installers, workflows, or package metadata changed.
Error handling and observability Pass with scope note Channel status now reports the mode and allowlist. A richer warning for bot mode with no allowed senders remains part of the broader issue.
Cryptography Not applicable No cryptographic behavior changed.
Configuration and migration Human decision required Existing persisted WhatsApp plans have no mode, so a sandbox previously using bot behavior will render self-chat after rebuild. The PR documents this but intentionally does not migrate legacy state.
Tests Pass 170 focused CLI tests and 54 Hermes config integration tests pass; CLI typecheck and the documentation build also pass.
Holistic review Human decision required #8312 also describes interactive prompting, clearing a stored allowlist, OpenClaw wiring, and stronger diagnostics. This PR intentionally implements a narrower Hermes configuration path.

No actionable security defect was found. Before approval, a maintainer should explicitly accept both the legacy-mode behavior and the narrower issue scope. I am changing the PR description from auto-closing #8312 to describing this as a partial implementation, so the remaining work is not closed accidentally.

GitHub Actions jobs are currently queued or cancelled during the reported service degradation. I have not rerun them.

Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
@apurvvkumaria

Copy link
Copy Markdown
Collaborator

Documentation follow-up completed in revision ea42af0e9:

  • documented that older persisted WhatsApp plans fall back to self-chat after rebuild and how to restore bot mode;
  • added the channels status verification and acceptance criterion;
  • added an explicit warning that the wildcard allowlist permits every sender.

npm run docs passes with 0 errors and the same 2 repository warnings. The documentation writer re-review now reports docs-updated, and the refreshed receipt validates successfully. The remaining maintainer decisions about legacy behavior and the narrower #8312 scope are unchanged.

@sandl99 sandl99 added area: messaging Messaging channels, bridges, manifests, or channel lifecycle and removed v0.0.104 release-target labels Aug 7, 2026
@sandl99 sandl99 added integration: whatsapp WhatsApp integration or channel behavior enhancement New capability or improvement request labels Aug 7, 2026

@cv cv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cover explicit Hermes bot mode through the complete channel lifecycle. Seed WHATSAPP_MODE=bot with a nonempty sender allowlist, then assert the persisted input and rendered WHATSAPP_MODE=bot before stop, after rebuild, and after start. This mode changes sender authorization, so complete the nine-category security review for the final head. Refresh onto current main and rerun the managed-runtime activation and required checks after adding the lifecycle evidence.

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

Labels

area: messaging Messaging channels, bridges, manifests, or channel lifecycle enhancement New capability or improvement request integration: whatsapp WhatsApp integration or channel behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants