Files
hermes-agent/tests/hermes_cli
teknium1 a702791371 test(cli): stop leaking a real MCP discovery thread from the TUI launcher test
tests/hermes_cli/test_tui_launcher_skips_plugin_discovery.py crashed CI with
SIGABRT ("FATAL: exception not rethrown") after both tests passed
(PR #120924, run 35967641887 attempt 1).

Mechanism: the plain-chat case replaces sys.modules["hermes_cli.plugins"]
with a SimpleNamespace spy that lacks has_enabled_agent_plugin_mcp.
_prepare_agent_startup then calls mcp_startup.start_background_mcp_discovery,
whose _has_configured_mcp_servers() probe imports that symbol from the stub,
raises, and falls back to "assume configured" -- so a REAL cli-mcp-discovery
daemon thread starts and is still importing tools.mcp_tool when pytest
exits. At interpreter finalization the daemon thread re-takes the GIL,
CPython ends it via pthread_exit, and glibc's forced unwind hits a
non-rethrowing catch frame inside the C-extension import: abort.

Repro (base, 40 runs under 20 busy CPUs): 2 SIGABRT (rc=134), thread alive
at atexit in 38/40. Fixed: 0/40 aborts, 0/40 leaked threads.

Fix: the spy also no-ops start_background_mcp_discovery -- plugin discovery
is the only subject of this file. Assertions unchanged.
2026-09-24 02:56:08 -07:00
..