perf(mcp): skip preflight probe on reconnect#40548
Closed
mohamedorigami-jpg wants to merge 1 commit into
Closed
Conversation
alpindiay
reviewed
Jun 6, 2026
alpindiay
left a comment
There was a problem hiding this comment.
Review: PR #40548 -- perf(mcp): skip preflight probe on reconnect
Summary: Small, targeted change that skips the MCP preflight content-type probe when self._ready is already set (i.e., on reconnect).
What works well:
- The logic is correct: if the connection is already established (_ready.is_set()), there is no need to re-probe the content type.
- The change is minimal (one-line condition addition) and low-risk.
- The comment block above the code already documents the rationale for the probe, and this change is consistent with that intent -- probe on first connect only.
Considerations:
- No tests. While this is a small perf optimization that is difficult to test without mocking the ready event, a unit test verifying that _preflight_content_type is not called when _ready.is_set() would be ideal.
- The condition order is fine: short-circuit evaluation means self._ready.is_set() is not checked for SSE transports, which is correct.
Verdict: LGTM. Approve as-is; the lack of a test is acceptable given the nature of the change.
Contributor
changman
pushed a commit
to changman/hermes-agent
that referenced
this pull request
Jun 10, 2026
…ready (NousResearch#40604) Closes NousResearch#40366. Salvaged from NousResearch#40548; re-verified on main, tightened, tested. Co-authored-by: mohamedorigami-jpg <mohamedorigami-jpg@users.noreply.github.com>
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.
Skip the MCP preflight content-type probe when reconnecting to a server that already connected successfully.
The preflight sends an initial HEAD request (which returns 405) followed by a GET (which returns 406). This adds about 3 seconds of network round-trip time on every reconnect with no actionable information, since the URL was already validated during the first connection.
The fix changes the condition from:
if config.get("transport") != "sse":to:
if config.get("transport") != "sse" and not self._ready.is_set():This ensures the preflight probe only runs on first connection, not on reconnects.
Closes #40366