Skip to content

refactor(http)!: adopt native synchronous HTTPX2 for SDK 0.12 - #415

Draft
WH-2099 wants to merge 4 commits into
mainfrom
refactor/sync-httpx2-transport
Draft

WH-2099 wants to merge 4 commits into
mainfrom
refactor/sync-httpx2-transport

Conversation

@WH-2099

@WH-2099 WH-2099 commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Move SDK model requests, file uploads/downloads, and serverless callbacks to native synchronous HTTPX2 interfaces for SDK 0.12.0.
Closes #414.

Release target: SDK 0.12.0, alongside gevent removal in #340.
SDK 0.11.0 publication is tracked in #413 and retains the existing HTTP clients and gevent runtime.
This PR remains a draft for the later release.

The SDK previously exposed Requests responses in model overrides and HTTPX objects in file/runtime calls.
These are now httpx2.Request, httpx2.Response, and HTTPX2 exceptions; the old compatibility adapters and codecs are removed.
This is a breaking change for plugins that override or catch those interfaces.
The README includes the API migration table, context-managed credential validation, and proxy/certificate/timeout configuration changes for the planned 0.12.0 release.

One transport connects HTTPX2 to httpcore2's connection pool and network backend.
It preserves signed request targets, multipart content/current file positions, redirect behavior and credential stripping, incremental SSE/audio delivery, and response/client ownership.
The shared backend supports SOCKS4/4a/5/5h authentication and explicit local/remote DNS semantics.
Targets and HTTPS proxies use the same configured certificate trust, including SSL_CERT_FILE together with SSL_CERT_DIR, with hostname verification enabled.
Trailing-dot hosts retain their HTTP/DNS name while TLS uses the normalized SNI name.

Request headers are validated before network I/O with safe errors; trailing SP/HTAB is normalized without accepting embedded control characters.
Regression tests verify that synthetic credentials do not appear in exception chains, logs, or the actual SDK error-writer output.
TLS upgrades acquire ownership of the SSL socket before the handshake, so cancellation closes the connection even when callers retain the exception traceback.
This applies to direct connections, proxy TLS, tunneled target TLS, and SOCKS.

Direct dependencies on Requests, urllib3, and old HTTPX are removed; old HTTPX/httpcore are absent from the resolved environment.
tiktoken still requires Requests/urllib3 for its own uncached tokenizer downloads.
HTTPX2/httpcore2 and socksio provide the SDK transport; gevent remains the concurrency model in this candidate; #340 tracks its removal for the same SDK 0.12.0 release.
HTTPX2 is the package name, and this change does not force the HTTP/2 wire protocol.

Intentional integration changes include native HTTPX2 exception categories, shared system/explicit CA trust, explicit NETRC configuration, socks5h:// for remote DNS, and HTTPX2's per-operation write timeout rather than the old cumulative upload behavior.
The two scoped internal imports are HTTPX2's environment proxy resolver and httpcore2's synchronous stream implementation; dependency upgrades need to retain the transport regression coverage.

Validation recorded for the transport implementation before the final SDK 0.12.0 integration:

  • Python 3.12 and 3.13: 1,852 tests passed on each.
  • just check, coverage gates, type checking of both transport modules, and just build passed.
  • HTTP coverage: 97.06% lines, 93.66% branches on both Python versions.
  • Local protocol tests cover SOCKS variants/auth/DNS/fragmentation/rejection, distinct proxy/target CA files, TLS hostname checks, request framing, streaming failures, and cancellation while retaining tracebacks.
  • The built wheel was installed in a fresh environment without old HTTPX/httpcore and exercised real local model/file calls while Requests network calls were disabled.

Live vendor endpoints and native Windows/macOS were not exercised.
The branch must be reconciled with the final SDK 0.11.0 baseline, and the combined HTTPX2/native-runtime candidate needs its own validation before SDK 0.12.0 publication.

Compatibility Check

  • Reviewed backward compatibility; native HTTP interfaces intentionally change as documented in README.md.
  • Reviewed forward compatibility; SDK/daemon business payloads retain their existing structure.
  • Identified release coordination: affected plugin overrides must migrate before upgrading to the new minor release.
  • Described the compatibility impact and scheduled this migration for SDK 0.12.0.
  • Update package release metadata to 0.12.0 during that release preparation; this branch still inherits the current 0.11.0 metadata.
  • Checked the version information in README.md.

Available Checks

  • just build has passed.
  • Relevant implementation and migration documentation is included.

@WH-2099 WH-2099 self-assigned this Nov 2, 2026
BREAKING CHANGE: SDK HTTP response hooks and transport exceptions now use HTTPX2. Plugins must migrate overrides and review the documented proxy, trust, authentication, and timeout settings.
@WH-2099 WH-2099 changed the title refactor(http): route SDK requests through synchronous HTTPX2 refactor(http)!: adopt native synchronous HTTPX2 Nov 2, 2026
@WH-2099 WH-2099 added this to the 0.12.0 milestone Nov 2, 2026
@WH-2099 WH-2099 changed the title refactor(http)!: adopt native synchronous HTTPX2 refactor(http)!: adopt native synchronous HTTPX2 for SDK 0.12 Nov 2, 2026

This branch has not been deployed

No deployments
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.

refactor(http)!: adopt native synchronous HTTPX2 in v0.12.0

1 participant