Expand description
The shared HTTP transport layer (hoisted from anthropic/ at Task 18):
retry policy + backoff, the HttpFailure carrier, Retry-After parsing,
client construction, and schema normalization. Per-wire error classification
stays wire-local (body shapes and terminal heuristics genuinely differ).
Structs§
- Http
Failure - A classified HTTP failure plus the retry-control signals that ride beside
the error taxonomy (
x-should-retryoverride — Anthropic-only, other wires always passfalse— andRetry-After). - Retry
Policy - Transport-retry knobs (Task-12 plan §3.6; sources: Claude Code 500ms·2ⁿ cap
32s, grok’s 429-cap-2 and 120s
Retry-Aftercap, codex’s ±10% jitter).
Functions§
- backoff
- Compute the pre-retry sleep for
attempt(1-based).Retry-Aftertakes precedence and bypasses the exponential cap (itself capped); otherwise exponential with ±10% jitter. - build_
http_ client - Build the reqwest client with the wires’ shared timeouts (30s connect, 10min total — non-streaming reasoning turns can run minutes).
- normalize_
input_ schema - Normalize a schemars-derived schema into the
input_schema/parametersthe APIs accept: our flatArgsstructs emit no$defs/$ref(generation inlines subschemas at the source), so normalization reduces to stripping the top-level$schemameta-annotation. Shared by every wire. - parse_
retry_ after - Parse a
Retry-Afterheader value: integer delta-seconds only. HTTP-date forms →None(fall back to exp backoff) — grok’s simplification. - run_
with_ retry - Drive
opuntil success, a terminal classification, or attempt exhaustion. Generic over the success type — the loop only inspectsHttpFailure.