Skip to content

fix(desktop): call discover_plugins() in _make_agent so plugin hooks fire in the desktop GUI - #60010

Closed
donneyluck wants to merge 1 commit into
NousResearch:mainfrom
donneyluck:fix/desktop-gui-discover-plugins
Closed

fix(desktop): call discover_plugins() in _make_agent so plugin hooks fire in the desktop GUI#60010
donneyluck wants to merge 1 commit into
NousResearch:mainfrom
donneyluck:fix/desktop-gui-discover-plugins

Conversation

@donneyluck

Copy link
Copy Markdown

Summary

Plugin hooks (on_session_start, pre_llm_call, post_llm_call, etc.) never fire for users running the desktop GUI app.

Root Cause

The desktop app's conversation path goes through tui_gateway/server.py_make_agent(), which is called for every new WebSocket session from the Electron frontend. Unlike the TUI slash_worker path (which already has an explicit discover_plugins() call for the same reason — see the comment added in that file) and the oneshot/gateway paths, _make_agent() never called discover_plugins().

As a result, any installed plugin's hooks are silently never registered for desktop users.

Fix

Call discover_plugins() at the top of _make_agent(), immediately after from run_agent import AIAgent. discover_plugins() is idempotent — it no-ops after the first call per process — so this adds no overhead for subsequent agent creations in the same session.

# discover_plugins() is not triggered by lazy imports in the dashboard/
# desktop WebSocket path the way it is for the CLI and slash_worker paths.
try:
    from hermes_cli.plugins import discover_plugins
    discover_plugins()
except Exception:
    pass

Verification

After applying the fix, the plugin's plugin_registered and on_session_start log entries appear in the debug log (CLAWD_HERMES_DEBUG=1) when starting a desktop conversation — confirming hooks are now registered and firing.

Tested with the Clawd on Desk plugin on Windows.

…fire in the desktop GUI

The desktop app's conversation path goes through tui_gateway/server.py
_make_agent(), which is invoked on every new WebSocket session from the
Electron frontend.  Unlike the TUI slash_worker path (which already has
an explicit discover_plugins() call added for the same reason) and the
oneshot/gateway paths, _make_agent() never called discover_plugins(),
so any installed plugin's hooks (on_session_start, pre_llm_call, etc.)
were silently never registered for desktop users.

Fix: call discover_plugins() at the top of _make_agent(), immediately
after the AIAgent import.  discover_plugins() is idempotent — it is a
no-op after the first call in a process — so this adds no overhead for
subsequent agent creations in the same session.

Verified by confirming plugin_registered and on_session_start log
entries appear in the plugin's debug log after the fix, and that Clawd
on Desk responds to desktop Hermes sessions.
@alt-glitch alt-glitch added type/bug Something isn't working comp/tui Terminal UI (ui-tui/ + tui_gateway/) comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have duplicate This issue or pull request already exists labels Jul 7, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Duplicate of #50787 — both add the same idempotent discover_plugins() call at the top of tui_gateway/server._make_agent(); #50787 is earlier-open and also carries a regression test. The desktop GUI shares the _make_agent path with the TUI/Web UI, so the same fix covers both. Related: #24237 (superset that also registers shell hooks) and #59775 (lazy-discover-in-invoke_hook variant).

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for tracing the desktop/TUI plugin-registration path. This is an automated hermes-sweeper review; current main already provides the requested behavior.

  • tui_gateway/server.py:4529 imports run_agent.AIAgent in _make_agent() before constructing the agent.
  • run_agent.py:136-141 imports model_tools, and model_tools.py:203-208 imports and invokes discover_plugins() during module initialization.
  • hermes_cli/plugins.py:1286-1287 makes repeated discovery idempotent, so the proposed direct call does not add a missing guarantee.
  • The member discussion correctly notes the overlap with earlier PR fix(tui): call discover_plugins() in _make_agent to enable hook-based plugins (#50776) #50787; current-main behavior independently satisfies both PRs' requested desktop/TUI hook-registration outcome.

@teknium1 teknium1 closed this Jul 15, 2026
@teknium1 teknium1 added the sweeper:implemented-on-main Sweeper: behavior already present on current main label Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins comp/tui Terminal UI (ui-tui/ + tui_gateway/) duplicate This issue or pull request already exists P3 Low — cosmetic, nice to have sweeper:implemented-on-main Sweeper: behavior already present on current main type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants