Skip to content

abridge: configurable tunnel request window + explicit SDK retry policy#152

Merged
Meirtz merged 1 commit into
masterfrom
feat/abridge-tunnel-timeout
Jul 4, 2026
Merged

abridge: configurable tunnel request window + explicit SDK retry policy#152
Meirtz merged 1 commit into
masterfrom
feat/abridge-tunnel-timeout

Conversation

@Meirtz

@Meirtz Meirtz commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator

Why

abridge's credential-isolation tunnel forwards each agent request from an in-sandbox loopback FastAPI, over Socket.IO, to the host-side Proxy client that calls the real upstream. The per-request wait window was hard-coded 600s (_start_tunnel took a request_timeout param; Proxy.start never passed it). That window's timer starts when the request reaches the sandbox — strictly before the host's upstream call begins — so any upstream call approaching 600s lost the race: the agent got a 504 tunnel timed out while the host handler kept running, and the openai/anthropic SDK's silent default max_retries=2 let the handler occupy up to ~3× the window on a result nobody was waiting for. Long-generation models hit this in practice; the only workaround was capping the model's own time budget to fit the infra.

What

  • Proxy(*clients, request_timeout=600.0) threads the window into the in-sandbox tunnel. The sizing rule is documented as a lower bound: client timeout × (1 + max_retries), with SDK backoff and Retry-After waits on top — leave real margin. Non-positive values rejected.
  • AnthropicFromOpenAIClient, OpenAIClient, AnthropicClient gain max_retries, default 0 — retry policy is the operator's call, never a hidden multiplier behind the window. agentix-bridge-serve grows --upstream-max-retries so CLI operators can opt back in.
  • Forward's default deadline drops to 540s, strictly under the default window it races (an equal deadline always loses — the tunnel timer starts first).

Tests

Includes a real end-to-end tunnel: a never-answering host returns 504 at ~request_timeout, so a regression that re-hardcodes the window during route registration blows the time budget instead of staying green. Plus the threading, default, validation, and per-client retry-policy assertions.

Reviewed by a second co-author (Codex) + adversarial pass; confirmed findings folded in (AnthropicClient retry knob, serve.py opt-in, Forward default, lower-bound wording, real-tunnel test).

🤖 Generated with Claude Code

The tunnel answered every agent request within a hard-coded 600s window
(_start_tunnel already took request_timeout; Proxy.start never passed
it). The window's timer starts when the request reaches the sandbox —
strictly before the host's upstream call — so any upstream call
approaching 600s lost the race: the agent got a 504 while the host
handler kept running, and the SDK's silent default max_retries=2 let the
handler occupy up to ~3x the window on a result nobody was waiting for.
Long-generation models hit this in practice; the only workaround was
capping the model's time budget to fit the infra.

- Proxy(*clients, request_timeout=600.0) threads the window into the
  in-sandbox tunnel. Sizing rule documented as a LOWER bound: client
  timeout x (1 + max_retries), with SDK backoff and Retry-After waits on
  top — leave real margin. Non-positive values rejected.
- AnthropicFromOpenAIClient, OpenAIClient, and AnthropicClient take
  max_retries and default it to 0 — retry policy is the operator's call,
  never a hidden multiplier behind the tunnel window. agentix-bridge-serve
  grows --upstream-max-retries so CLI operators can opt back in.
- Forward's default deadline drops to 540s, strictly under the default
  window it races (an equal deadline always loses — the tunnel timer
  starts first).
- Tests include a real end-to-end tunnel: a never-answering host 504s at
  ~request_timeout, so a regression re-hardcoding the window during route
  registration blows the time budget instead of staying green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Meirtz Meirtz merged commit 028db38 into master Jul 4, 2026
5 checks passed
@Meirtz Meirtz deleted the feat/abridge-tunnel-timeout branch July 4, 2026 01:10
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