fix(http): configure explicit timeouts and improve connection pooling#5737
Open
leseb wants to merge 2 commits intoogx-ai:mainfrom
Open
fix(http): configure explicit timeouts and improve connection pooling#5737leseb wants to merge 2 commits intoogx-ai:mainfrom
leseb wants to merge 2 commits intoogx-ai:mainfrom
Conversation
… HTTP clients Replace default httpx timeouts with explicit Timeout(total, connect=connect) across the codebase to fail fast on unreachable hosts while still allowing slow upstream responses. Introduce BaseToolRuntimeConfig with configurable timeout/connect_timeout fields so tool runtime providers (Bing, Brave, Tavily, Wolfram Alpha) expose these as user-tunable config. Reuse a persistent httpx.AsyncClient in CustomAuthProvider instead of creating one per request. Add SSRF protection via validate_url_not_private for URLs fetched in file_search and prompt_adapter image localization. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Sébastien Han <seb@redhat.com>
pytest is configured with async-mode=auto, so the explicit decorator is unnecessary and blocked by the pre-commit hook. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Sébastien Han <seb@redhat.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.
Summary
httpx.Timeout(total, connect=...)on everyhttpx.AsyncClientin the codebase, replacing bare defaults or per-requesttimeout=kwargs. Total timeout of 30s for tool runtimes / content fetch and 10s for auth endpoints; connect timeout set shorter (10s / 5s respectively) to fail fast on unreachable hosts.BaseToolRuntimeConfigwith user-tunabletimeoutandconnect_timeoutfields so operators can adjust HTTP timeouts per tool runtime provider (Bing Search, Brave Search, Tavily Search, Wolfram Alpha) via config YAML.httpx.AsyncClientinCustomAuthProviderinstead of creating a new client pervalidate_tokencall, reducing TCP/TLS setup overhead.validate_url_not_private()SSRF guard tofile_searchandprompt_adapterimage localization paths, blocking requests to loopback, link-local, and RFC 1918 addresses (including IPv4-mapped IPv6).Test plan
tests/unit/core/test_client_timeout.py— verifies the API client factory no longer putstimeoutinside per-request params (it is set on theAsyncClientconstructor instead).tests/unit/server/test_auth_http_client.py— verifiesCustomAuthProvidercreates its client eagerly with the correct connect/read/write/pool timeouts, reuses it, and closes it properly.tests/unit/server/test_auth_oauth2_introspection.py— updated assertions to match the newhttpx.Timeoutobject passed toAsyncClientand confirmstimeoutis no longer passed per-request.tests/unit/providers/utils/test_url_validation.py— comprehensive coverage forvalidate_url_not_private: loopback, RFC 1918, link-local, IPv6 loopback/ULA/link-local, IPv4-mapped IPv6, unresolvable hostnames, mixed DNS results, and public IP allowlisting.uv run pytest tests/unit/ -x --tb=shortuv run pre-commit run --all-files🤖 Generated with Claude Code