Skip to content

mitm: make upstream ResponseHeaderTimeout configurable (default 5m)#196

Draft
devniel wants to merge 1 commit into
Infisical:mainfrom
callRounded:configurable-response-header-timeout
Draft

mitm: make upstream ResponseHeaderTimeout configurable (default 5m)#196
devniel wants to merge 1 commit into
Infisical:mainfrom
callRounded:configurable-response-header-timeout

Conversation

@devniel

@devniel devniel commented May 20, 2026

Copy link
Copy Markdown

Problem

The proxy's upstream http.Transport hardcodes ResponseHeaderTimeout: 30 * time.Second in internal/mitm/proxy.go. For agents that proxy LLM APIs, reasoning / "thinking" models (Gemini 2.x Pro, Claude extended thinking, the o-series) routinely withhold HTTP response headers for tens of seconds — sometimes minutes — while they think. A 30s cap aborts those otherwise-healthy streaming completions with a 502 upstream_error, which surfaces as a ProxyError in the SDK and silently kills the agent's turn.

Change

Default raised to 5m (matches the kind of think-time these models actually take in practice) and made overridable via the AGENT_VAULT_RESPONSE_HEADER_TIMEOUT env var (Go duration; "0" disables the timeout entirely).

Test plan

  • Existing mitm tests still pass (go test ./internal/mitm/...)
  • Verified locally: long-thinking Claude/Gemini requests through the proxy no longer 502 with the bump in place

Opening as a draft for upstream feedback on the default value + env-var name before marking ready. Happy to land as e.g. AGENT_VAULT_UPSTREAM_RESPONSE_HEADER_TIMEOUT or any other naming the maintainers prefer.

The proxy's upstream http.Transport hardcoded ResponseHeaderTimeout to
30s. Agents proxy LLM APIs, and reasoning / "thinking" models (Gemini
Pro, Claude extended thinking, o-series) routinely withhold HTTP response
headers for tens of seconds — sometimes minutes — while they think. A 30s
cap aborts those otherwise-healthy streaming completions with a 502
upstream_error.

Default raised to 5m and made overridable via
AGENT_VAULT_RESPONSE_HEADER_TIMEOUT (Go duration; "0" disables it).
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.

1 participant