fix(approval): explain requested action and permission - #51397
Conversation
Related / competing-PR cluster for plain-language approval explanations (all address #34625 / #6959 / #27604):
Not marking any as a duplicate — the platform-specific PRs could build on this shared layer. Flagging the cluster so a maintainer can pick a canonical direction. |
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Approved
Excellent UX improvement: approval prompts now explain what Hermes is trying to do and what permission the approval grants. This is implemented consistently across all platform adapters (CLI, Discord, Feishu, Matrix, Slack, Telegram, ACP).
Looks Good
- New
build_approval_explanation()intools/approval.pyprovides platform-neutral wording - All 7 platform adapters receive the explanation via
metadata["approval_explanation"] - CLI panel correctly accounts for explanation height in layout calculations
- Tests cover both the ACP bridge and Telegram adapter
- The explanation text is clear and actionable for end users
Reviewed by Hermes Agent
teknium1
left a comment
There was a problem hiding this comment.
Thanks for tackling a real approval-UX gap. Current main still renders only the command and detector reason in CLI (cli.py:11706-11812), gateway fallback (gateway/run.py:18669-18674), and ACP (acp_adapter/permissions.py:83-91).
Problems
tools/approval.py:1668in this PR builds a user-visible explanation from rawcommand/combined_desc. The helper includes the description in its permission text, but current redaction is deliberately applied before callback and gateway rendering (tools/approval.py:1707-1718,gateway/run.py:18624-18630). This introduces an unredacted egress for secrets contained in a detector description;tests/tools/test_approval.py:2400-2418covers that exact redaction contract.- The generic dispatch reaches every adapter with
send_exec_approval(gateway/run.py:18635-18643), but WhatsApp (gateway/platforms/whatsapp_cloud.py:801), Teams (plugins/platforms/teams/adapter.py:1094), QQBot (gateway/platforms/qqbot/adapter.py:2664), and the TUI approval event/render path are not updated.
Suggested changes
- Derive the explanation from redacted display values, or redact explanation fields at every egress boundary; add a secret-description regression test.
- Carry the structured explanation through all existing approval adapters and the TUI/API approval payload contract, with sibling-path tests.
Automated hermes-sweeper review.
| "pattern_key": primary_key, | ||
| "pattern_keys": all_keys, | ||
| "description": combined_desc, | ||
| "explanation": build_approval_explanation(command, combined_desc), |
There was a problem hiding this comment.
combined_desc is raw here, and build_approval_explanation() appends it to the externally rendered permission text. Current main deliberately redacts approval command and description before display (prompt_dangerous_approval, gateway egress); construct this from the same redacted fields or redact explanation before every send, then add a secret-in-description regression test.
Summary
Test plan