feat: trust whatsapp_from_owner flag for /takeback recognition - #4
Conversation
Profiles where the owner notification platform is Telegram but the human owner actually types from the same WhatsApp Business account as the bot (e.g. basketball-jersey-demo) couldn't deactivate handover via /takeback because the rule only matched on (platform, sender_id) against the configured owner. With the WHATSAPP_FORWARD_OWNER_MESSAGES flag now propagating metadata["whatsapp_from_owner"] from the bridge LRU classifier, any inbound with that flag set is by definition owner-equivalent - same trust model as the implicit-owner-activate branch shipped in PR #3. No new config. Pre-existing platform/sender_id matching path is unchanged for profiles that don't enable owner forwarding.
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Motivation
In profiles where the owner notification destination is Telegram but the human owner actually types replies from the same WhatsApp Business account as the bot (e.g.
basketball-jersey-demo),/takebackfrom the owner's phone is not recognized as owner-issued —_is_owner_messageonly matched on(handover.owner.platform, handover.owner.chat_id). Result: the bot only resumes when the sliding TTL expires.Design
Extend
rules/handover.py::_is_owner_messagewith a metadata short-circuit before the legacy platform/sender check:The bridge LRU classifier in hermes-agent (
WhatsAppAdapter._build_message_event, gated byWHATSAPP_FORWARD_OWNER_MESSAGES) only sets that flag for inbounds that came from the bot's own WhatsApp account — by definition the owner. Same trust model as the implicit-owner-activate branch shipped in #3.The legacy
(platform, sender_id)path is unchanged for profiles that don't enable owner forwarding.No config change
No new keys, no schema bump. Profiles opt in via the existing
WHATSAPP_FORWARD_OWNER_MESSAGESenv in hermes-agent.Dependencies
metadata['whatsapp_from_owner'](merged intopebble/mainasb1e7628d7).whatsapp_from_ownerconsumer pattern.Tests
Two new tests in
tests/test_rules.py::TestHandover:test_takeback_via_whatsapp_from_owner_flag_alone_deactivates— owner configured for Telegram,/takebackarrives via WhatsApp withmetadata['whatsapp_from_owner']=True→ handover ends.test_takeback_without_owner_flag_from_stranger_does_not_deactivate— no flag, non-owner sender,/takebacktext → falls through to the active-handover silent-ingest path; handover stays active.Existing 42 tests remain green; suite is now 44.