fix(agent): short-circuit local server detection for known public provider hosts - #61428
Open
liuhao1024 wants to merge 1 commit into
Open
fix(agent): short-circuit local server detection for known public provider hosts#61428liuhao1024 wants to merge 1 commit into
liuhao1024 wants to merge 1 commit into
Conversation
…vider hosts - Add hostname blacklist to detect_local_server_type() to avoid probing local-only endpoints (/api/tags, /v1/props, /version) on public SaaS APIs - Prevents noisy 404s in egress logs and monitoring dashboards - Known hosts: api.openai.com, api.anthropic.com, generativelanguage.googleapis.com - Local/custom endpoints still probe as expected Fixes NousResearch#61421
This was referenced Jul 9, 2026
teknium1
reviewed
Jul 10, 2026
teknium1
left a comment
Contributor
There was a problem hiding this comment.
Thanks for addressing the unnecessary discovery traffic. The underlying path remains present on current main: agent/model_metadata.py:704-740 probes the configured URL, and agent/image_routing.py:321-331 can call that detector for an unknown capability.
Problems
agent/model_metadata.py:690parses the hostname directly instead of using the existingbase_url_hostname()helper. That misses the trailing-dot normalization contract already covered bytests/test_base_url_hostname.py:37-38:https://api.openai.com./v1will still be probed.
Suggested changes
- Use the already imported
base_url_hostname(normalized)atagent/model_metadata.py:690and add a matching no-request regression case.
Automated hermes-sweeper review.
| # This reduces noise in egress logs and monitoring dashboards. | ||
| try: | ||
| url = normalized if "://" in normalized else f"https://{normalized}" | ||
| host = urlparse(url).hostname or "" |
Contributor
There was a problem hiding this comment.
Please use the existing base_url_hostname(normalized) helper here. It canonicalizes trailing DNS dots (covered by tests/test_base_url_hostname.py), so https://api.openai.com./v1 is treated as the same OpenAI host and does not retain the probe behavior this change targets.
1 task
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?
When using the
openai-apiprovider with the default base URLhttps://api.openai.com/v1, Hermes sends HTTP GET requests to local-only discovery endpoints (/api/tags,/v1/props,/version) onapi.openai.com. These endpoints return 404 Not Found (as expected, since they're not part of the OpenAI API), creating noise in egress logs and monitoring dashboards.This PR adds a hostname blacklist to
detect_local_server_type()to short-circuit detection for known public provider hosts. Local/custom endpoints (localhost, 127.0.0.1, RFC1918 IPs, custom URLs) still probe as expected.Related Issue
Fixes #61421
Type of Change
Changes Made
agent/model_metadata.py: Add hostname check todetect_local_server_type()to short-circuit detection for known public provider hosts (api.openai.com, api.anthropic.com, generativelanguage.googleapis.com)tests/agent/test_model_metadata_local_ctx.py: AddTestDetectLocalServerTypePublicProviderShortCircuittest class with 5 regression testsHow to Test
/api/tags,/v1/props,/versiononapi.openai.com/v1/...API trafficpytest tests/agent/test_model_metadata_local_ctx.py::TestDetectLocalServerTypePublicProviderShortCircuit -v— all 5 tests passChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/agent/test_model_metadata_local_ctx.py -vand all 39 tests passTestDetectLocalServerTypePublicProviderShortCircuit)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/Aurlparse, works on all platforms