fix(mcp): increase MCP discovery timeout for kanban workers - #43348
Open
liuhao1024 wants to merge 1 commit into
Open
fix(mcp): increase MCP discovery timeout for kanban workers#43348liuhao1024 wants to merge 1 commit into
liuhao1024 wants to merge 1 commit into
Conversation
Kanban workers depend on MCP tools for task execution, but the default `wait_for_mcp_discovery` timeout (0.75s) is far too short for slow MCP servers that can take 30+ seconds to initialize. The worker's first API call fires before MCP tools are registered, causing the model to fall back to incompatible built-in tools. Detect the kanban worker context via HERMES_KANBAN_TASK and use a 60s timeout so MCP servers have time to register their tools before the first API call. Fixes NousResearch#43273
teknium1
reviewed
Jul 14, 2026
teknium1
left a comment
Contributor
There was a problem hiding this comment.
Thanks for addressing a real kanban/MCP startup race. The issue remains on current main: worker initialization calls wait_for_mcp_discovery() at hermes_cli/cli_agent_setup_mixin.py:237-239, and the default bounded wait is only 1.5 seconds (hermes_cli/config.py:1359-1372), so the reported 34-second server still misses the first tool snapshot.
Problems
- The diff targets the pre-refactor
wait_for_mcp_discovery(timeout=0.75)implementation. Current main resolves explicit/configured bounds through_resolve_discovery_timeout()inhermes_cli/mcp_startup.py:53-71; the addedmax(timeout, 60.0)needs to be integrated after that resolution rather than restoring the old timeout contract. - The added tests cover only the old direct argument path. They do not exercise the current config-backed resolution or the worker agent-build caller.
Suggested changes
- Preserve the current config resolver, then apply the worker-specific 60-second minimum.
- Add regression coverage for worker/non-worker resolution against the current implementation and, if practical, the first agent-build snapshot path.
Automated hermes-sweeper review.
| # Kanban workers can afford to wait longer — MCP tools are critical | ||
| # for task execution and the worker is a background subprocess. | ||
| if os.environ.get("HERMES_KANBAN_TASK"): | ||
| timeout = max(timeout, 60.0) |
Contributor
There was a problem hiding this comment.
Current main no longer has this fixed timeout=0.75 contract: wait_for_mcp_discovery() resolves mcp_discovery_timeout through _resolve_discovery_timeout(). Please integrate the kanban minimum after that resolver so configured bounds and the current API are retained.
1 task
This was referenced Aug 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Increases the MCP discovery wait timeout for kanban workers from 0.75s to 60s so that slow MCP servers (30s+ to initialize) have time to register their tools before the worker agent makes its first API call.
Related Issue
Fixes #43273
Type of Change
Changes Made
hermes_cli/mcp_startup.py: Inwait_for_mcp_discovery(), detect kanban worker context (viaHERMES_KANBAN_TASKenv var) and usemax(timeout, 60.0)instead of the default 0.75s timeout. Kanban workers are background subprocesses that depend on MCP tools for task execution — a longer blocking wait is acceptable.tests/hermes_cli/test_mcp_startup.py: Add 3 regression tests covering kanban worker timeout escalation, explicit timeout preservation (>60s passed through), and non-kanban sessions using the caller-provided timeout unchanged.How to Test
chrome-devtools-winvia stdio/npx)hermes kanban dispatchChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/hermes_cli/test_mcp_startup.py -vand all tests pass (7/7)Documentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/ACode Intelligence
wait_for_mcp_discovery(callers: 2 in cli.py, 1 in tui_gateway/server.py)HERMES_KANBAN_TASKenv var is the standard kanban worker context signal (used in cli.py at lines 15622, 15925, 15967, 16135)