fix(send_message): sanitize active-wake snippets - #49749
Conversation
(cherry picked from commit 722aedbf85058762686b479328d5c803d556bd89) (cherry picked from commit 7add5c495782d2bbf82dce49ef182db3a99ca5f4)
13eaaa2 to
0049cd9
Compare
teknium1
left a comment
There was a problem hiding this comment.
Thanks for isolating the sensitive-text handling. The current draft needs substantive rework before it can provide the stated active-wake contract.
Problems
tools/send_message_tool.py:120returns the full sanitized text; it never truncates it. The same value is injected into the wake event at:542and:662, so the PR's claimed oversized-fragment behavior is absent.tools/send_message_tool.py:654-656hard-codeschat_type="group"anduser_id="hermes-active-wake". Currentgateway/session.py:936-949derives isolated group sessions from that participant ID, so this can create a synthetic participant session instead of waking the intended operator session. The test currently asserts that synthetic ID attests/tools/test_send_message_tool.py:3217.- The linked integration PR #49593 identifies this same limitation: its active-wake implementation removes the synthetic participant and distinguishes scheduled, accepted, and started receipt states.
Suggested changes
- Bound and test the sanitized wake snippet after redaction.
- Route through the resolved target session and add real session-key coverage for isolated groups, shared groups, threads, and DMs.
- Consolidate the receipt semantics with #49593 rather than retaining scheduling as proof of session acceptance.
Automated hermes-sweeper review.
| # Drop lines that only contained a stripped MEDIA directive. This preserves | ||
| # user-visible prose ("hello") while avoiding synthetic wake clutter. | ||
| cleaned_lines = [line.rstrip() for line in redacted.splitlines() if line.strip()] | ||
| return "\n".join(cleaned_lines).strip() |
There was a problem hiding this comment.
This return never applies a size limit, so an arbitrarily large non-sensitive message is still injected into the synthetic wake event. Please add an explicit post-redaction bound and a regression test; the PR summary specifically promises truncation of oversized fragments.
| chat_id=str(chat_id), | ||
| chat_type="group", | ||
| thread_id=str(thread_id) if thread_id else None, | ||
| user_id="hermes-active-wake", |
There was a problem hiding this comment.
A fixed synthetic participant ID routes isolated group sessions to ...:<chat_id>:hermes-active-wake, not the intended operator session. Current gateway/session.py uses source.user_id when group-per-user isolation is enabled. Route using the resolved target session without this participant identity, and test that path against the real session-key builder.
|
Recommend closing as a duplicate superseded by #37865. This PR re-implements the active-wake path against a pre-#37865 main and reintroduces the exact patterns #37865 removes: SessionSource with chat_type=group and a synthetic user_id='hermes-active-wake' (which forges a participant session instead of waking the operator's real session), plus a model-facing trigger_agent field. Despite the title, _sanitize_active_wake_text only redacts — it never truncates — so the advertised bounded-snippet behavior is absent. #37865 already routes via replayed chat_type/user_id/user_id_alt and wakes with the composed, bounded notification text rather than raw bodies, so no raw-body bound is needed on that path. If any residual oversized-fragment concern remains, it is a ~2-line length cap on #37865's notification composition, not this redaction stack. Proposing duplicate-closure; nothing is closed by this note. (This PR is not closed.) |
Summary
Tests
python3 -m pytest tests/tools/test_send_message_tool.py::TestActiveWakeReceipt -q -o addopts=python3 -m py_compile tools/send_message_tool.py