Skip to content

fix(studio/llama_cpp): disable trust_env on the loopback health probe (#6750) - #6752

Merged
wasimysaid merged 8 commits into
unslothai:mainfrom
Anai-Guo:fix-llama-health-trust-env
Jun 30, 2026
Merged

wasimysaid merged 8 commits into
unslothai:mainfrom
Anai-Guo:fix-llama-health-trust-env

Conversation

@Anai-Guo

Copy link
Copy Markdown
Contributor

What

LlamaCppBackend._wait_for_health() polls http://127.0.0.1:<port>/health with httpx.get(url, timeout=2.0). httpx defaults to trust_env=True, so an ambient HTTP_PROXY / HTTPS_PROXY in the environment is applied even to the loopback request.

When such a proxy returns 503 for 127.0.0.1 (a common corporate-proxy setup), every probe fails, the loop runs until the full timeout, and Studio load hangs. As reported in #6750:

httpx.get("http://127.0.0.1:<llama-port>/health", trust_env=True) returns 503, while trust_env=False returns 200; Studio load hangs because health check uses default trust_env.

Fix

Pass trust_env=False to the loopback readiness probe so it never routes through a proxy. This mirrors the existing trust_env=False handling already used by the sibling HTTP clients in core/inference/llama_http.py and core/inference/external_provider.py.

Scope is intentionally limited to the health probe (the reported hang). The separate Darwin/Metal SIGTERM hard-kill suggestion in the issue is a distinct process-lifecycle concern and is left for a follow-up.

Fixes #6750

🤖 Generated with Claude Code

_wait_for_health() polls http://127.0.0.1:<port>/health with the default
httpx trust_env=True, so an ambient HTTP(S)_PROXY in the environment is
applied to the loopback request. A proxy that returns 503 for 127.0.0.1
makes every probe fail, so the loop runs until timeout and Studio load
hangs (trust_env=False returns 200 immediately).

Pass trust_env=False so the local readiness probe never goes through a
proxy. This mirrors the existing trust_env=False handling in the sibling
llama_http / external_provider HTTP clients.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the loopback health probe in llama_cpp.py to disable environment proxy settings (trust_env=False), preventing loopback requests from being routed through ambient proxies. The reviewer suggests using urllib.request to handle proxy environment variables and TLS/certificate failures, although this suggestion is aimed at external endpoints rather than loopback probes.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

_wait_for_health now calls httpx.get(..., trust_env=False); update the retry test's fake_get to accept the kwarg so it doesn't raise TypeError.
@Anai-Guo
Anai-Guo requested a review from danielhanchen as a code owner June 30, 2026 07:10
@wasimysaid wasimysaid self-assigned this Jun 30, 2026
@wasimysaid

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2493f98307

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@wasimysaid

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 85e6b8fd32

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@wasimysaid

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 21e5b160ee

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@wasimysaid
wasimysaid merged commit 7337729 into unslothai:main Jun 30, 2026
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mac os health check uses default trust_env

2 participants