fix(model_metadata): localhost->127.0.0.1 at both outbound probe sites (#61528 salvage) - #77615
Merged
kshitijk4poor merged 2 commits intoAug 3, 2026
Conversation
…probe sites fetch_endpoint_model_metadata's generic (non-LM-Studio) /models fetch and its llama.cpp /v1/props context-length follow-up built request URLs straight from the unrewritten candidate, unlike every other local-probe site. Both retained the multi-second dual-stack IPv6 connect penalty that _localhost_to_ipv4() exists to skip (measured on macOS: localhost 32.9ms vs 127.0.0.1 0.1ms on a dead port; ~2s on Windows). normalized stays the cache key so caching behavior is unchanged; only the outbound request target is rewritten. Re-derived from PR NousResearch#61528 onto current main (original no longer applied cleanly).
kshitijk4poor
enabled auto-merge (rebase)
August 3, 2026 11:40
4 tasks
|
Code Review: #77615 Verdict: Approve read_file hint: helpful UX improvement. LGTM - Reviewed diff. Changes are sound. |
CI slice 3/7 failures: run_conversation tests pass MagicMock base_urls through the metadata probe path; re.sub raised TypeError where the old code let non-strings flow through. Preserve that contract.
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.
Salvage of #61528 by @pierrenode — mechanism re-derived onto main's current fetch sites with authorship preserved (original conflicts; 5,436 commits behind).
Context — what this changes for users
On dual-stack machines, httpx/requests resolve 'localhost' IPv6-first; when the local server (LM Studio, llama.cpp, ollama) listens on IPv4 only, every metadata probe pays an IPv6 connection timeout first. Measured on this Mac (dead port): localhost 32.9ms vs 127.0.0.1 0.1ms per connect — and on Windows the stall is ~2s per probe.
Applied at BOTH of main's current outbound URL builders in fetch_endpoint_model_metadata (the generic /models loop AND the llama.cpp /v1/props follow-up — whole bug class), reusing the existing _localhost_to_ipv4 helper that main already has for detect_local_server_type. Cache keys keep the un-rewritten URL so localhost and 127.0.0.1 share entries.
Verification
10 tests green (2 new sibling-site guards); mutation: rewrite disabled -> exactly the 2 new tests fail; restore green; ruff clean.
Closes #61528.