fix(gateway): skip background memory/skill review in group chats - #26850
fix(gateway): skip background memory/skill review in group chats#26850irandoku wants to merge 1 commit into
Conversation
bc47a80 to
d696282
Compare
teknium1
left a comment
There was a problem hiding this comment.
Thanks for identifying a real group-chat safety issue. Current main still schedules automatic review without a chat-type check: memory review is triggered in agent/turn_context.py:306-314, and skill review in both agent/turn_finalizer.py:485-490 and agent/codex_runtime.py:489-496.
Problems
- The
run_agent.pylocations in this PR were moved by54870847c; the patch must cover all three current trigger paths to establish the stated guarantee. group/channelis not the full multi-user taxonomy: LINE emitsroomatplugins/platforms/line/adapter.py:410-411, and Discord emitsthreadatplugins/platforms/discord/adapter.py:4716.- The LINE display-name and message-type changes are unrelated. The display-name helper hardcodes the default Hermes home, conflicting with profile isolation; the current LINE mapping test requires audio to remain
MessageType.VOICE(tests/gateway/test_line_plugin.py:662-672).
Suggested changes
- Re-scope to a shared multi-user predicate at the current review-trigger sites and add regression coverage for group-like and DM paths.
Automated hermes-sweeper review.
| @@ -12279,7 +12279,8 @@ def run_conversation( | |||
| _should_review_memory = False | |||
| if (self._memory_nudge_interval > 0 | |||
| and "memory" in self.valid_tool_names | |||
| and self._memory_store): | |||
| and self._memory_store | |||
There was a problem hiding this comment.
This guard is now stale: current main decides memory review in agent/turn_context.py:306-314, and skill review separately in agent/turn_finalizer.py:485-490 plus agent/codex_runtime.py:489-496. Please rework the fix around all active trigger paths rather than this removed inline location.
| @@ -424,6 +424,24 @@ def _allowed_for_source( | |||
| return False | |||
|
|
|||
|
|
|||
| def _resolve_display_names(chat_id: str, user_id: str) -> Tuple[str, str]: | |||
There was a problem hiding this comment.
This unrelated helper hardcodes the default ~/.hermes path. That bypasses profile isolation; persistent Hermes state must use get_hermes_home() as required by AGENTS.md:1169-1177. Please remove this unrelated change from the review-trigger fix or make it profile-safe in a separately tested PR.
|
Thanks for the careful review. I agree that the issue is still valid, and your comments are correct. I am rechecking the change against current I also found unrelated LINE display-name and message-type changes in the current diff. Those do not belong to this fix and will be removed. I’m rebuilding the change from current |
Gate automatic memory and skill review at the shared scheduler boundary while preserving CLI/direct contexts and external memory synchronization.
d696282 to
84ff3a5
Compare
Implementation updateThis PR has been reworked on current Analysis and design rationaleOn current Applying chat-type checks independently at every trigger site would duplicate The implementation therefore places one guard at This boundary was also selected because:
The policy uses an allowlist for contexts where owner-scoped automatic review is
Gateway-created agents pass their normalized What changed
Preserved behavior
Verification
The complete Codex integration module exceeded the local 600-second runner |
Problem
Built-in memory (MEMORY.md + USER.md + fact_store) is designed for 1-on-1 conversations. In group chats, any member's message can trigger background review, causing identity pollution (e.g., a group member's self-introduction incorrectly written to USER.md as if it were the owner's identity).
External memory plugins (Honcho, Supermemory) handle per-user scoping, but built-in memory lacks this isolation. Since many users rely on built-in memory without external plugins, group chats pose a real privacy/identity risk.
Solution
Add
chat_typeguard to both memory and skill background review triggers. Whenchat_typeis"group"or"channel", skip automatic background review entirely.DMs (
"dm") and CLI sessions continue to review normally.Scope
run_agent.py:_should_review_memory(~line 12279)run_agent.py:_should_review_skills(~line 15932)No changes to:
Testing
chat_typevalues across platforms: Telegram ("dm"/"group"/"channel"/"forum"), LINE ("dm"/"group"/"channel"), Discord, Matrix, Signal all use consistent taxonomy.