fix(discord): schedule approval boxes on the gateway loop - #74471
fix(discord): schedule approval boxes on the gateway loop#74471peacockesq wants to merge 2 commits into
Conversation
teknium1
left a comment
There was a problem hiding this comment.
Thanks for the focused gateway-loop repair. The requested approval-box symbols are still absent from current main, so this is not stale, but two changes are needed before this can safely land.
Problems
tools/discord_approval_box_tool.py:145always readsrunner.adapters[Platform.DISCORD]. In multiplex mode, secondary adapters live in_profile_adapters;gateway/authz_mixin.py:71-97deliberately fails closed rather than falling back to the default bot. Resolve usingHERMES_SESSION_PROFILEand the profile-aware adapter path, with regression coverage for a secondary profile.- The
toolsets.pychange places a Discord-only, live-gateway-only capability in_HERMES_CORE_TOOLS. Since all CLI and messaging bundles inherit that list (toolsets.py:31-82,435-465), expose it only through the Discord platform bundle instead.
Suggested changes
- Add a multiplex-profile routing test and a schema-scope test alongside the existing loop scheduling coverage.
Automated hermes-sweeper review.
| from gateway.config import Platform | ||
| runner = _gateway_runner_ref() | ||
| adapter = runner.adapters.get(Platform("discord")) if runner is not None else None | ||
| except Exception: |
There was a problem hiding this comment.
runner.adapters is only the active/default adapter map in multiplex mode. Read HERMES_SESSION_PROFILE and use the profile-aware resolver (which fails closed if that profile lacks Discord), otherwise a secondary profile can send this approval through the default profile's bot.
| # Approval-gated external delivery on Discord (available only when a | ||
| # Discord bot is configured; check_fn keeps it off other installations). | ||
| "discord_approval_box", | ||
| ] |
There was a problem hiding this comment.
Please keep this Discord-only live-adapter tool out of _HERMES_CORE_TOOLS: every CLI and messaging platform inherits that schema. Add it to the hermes-discord platform bundle instead, so non-Discord sessions never advertise a tool they cannot execute.
SummaryTwo PRs address #74470. #74471 directly restores deliverable approval boxes and schedules their send on the Discord gateway-owned loop, while #74493 adds generic loop-scheduling infrastructure without wiring the reported deliverable-approval call site and also contains unrelated changes. Related pull requests
Duplicates#74471 and #74493 target the same Discord aiohttp event-loop failure; #74493 is the broader partial duplicate because it does not connect its scheduling helper to the deliverable approval-box call site addressed by #74471. Suggested consolidationKeep #74471 open with a salvage path: retain its concrete owning-loop scheduling, approval persistence, three-button rendering, and focused tests, while requiring profile-aware fail-closed Discord adapter resolution and Discord-only tool exposure with regression coverage, as specified by the keep_open contributor review. Keep #74493 closed as a duplicate of #74471 because its relevant infrastructure is not wired into the affected call path and its branch includes unrelated changes. Complex graphflowchart LR
classDef open fill:#dbeafe,stroke:#1d4ed8,color:#1e3a8a
classDef merged fill:#dcfce7,stroke:#15803d,color:#14532d
classDef closed fill:#e5e7eb,stroke:#6b7280,color:#1f2937
classDef unverified fill:#f3f4f6,stroke:#9ca3af,color:#374151
classDef best stroke-width:3px,stroke:#b45309
classDef target stroke-width:3px,stroke:#4338ca
I74470(["issue #74470 (open)"])
subgraph Dup74471 ["PRs duplicating each other"]
P74471["PR #74471 (open)"]
P74493["PR #74493 (closed)"]
end
P74471 -->|best fix| I74470
class I74470 open
class P74471 open
class P74493 closed
class P74471 best
class P74471 target
click I74470 "https://github.com/NousResearch/hermes-agent/issues/74470"
click P74471 "https://github.com/NousResearch/hermes-agent/pull/74471"
click P74493 "https://github.com/NousResearch/hermes-agent/pull/74493"
Graph: solid arrow = fixes / best fix, dashed arrow = partial or unverified (see edge label); boxed group = PRs duplicating each other; amber border = best fix; indigo border = target; gray node = closed (state tag in the node label). Cross-PR triage: Reviewed 2 pull requests and 1 issue in this complex. Each diff was read against this issue; Assessment working set: 46 kB of PR diffs, 4 kB of issue/PR text, 2 kB of discussion (4 comments), 5 verify verdicts. verdicts reflect diff content, not PR titles. Part of an automated triage batch. |
Closes #74470.
What changed
_run_async's private worker loopRoot cause
discord.pyowns anaiohttpsession bound to the gateway event loop. The synchronous tool handler used_run_async, which ranchannel.send()on a different event loop and producedTimeout context manager should be used inside a task.Verification
venv/bin/python -m py_compile tools/discord_approval_box_tool.py plugins/platforms/discord/adapter.pyvenv/bin/python -m pytest tests/tools/test_discord_approval_box_tool.py -o addopts='' -q— 3 passedvenv/bin/python -m pytest tests/agent/test_async_utils.py -o addopts='' -q— 6 passedLive Discord verification will be recorded after the local gateway restart.