Skip to content

fix(v1/harnesses): retry bash harness model calls through tunnel reconnects - #3345

Open
nxphi47 wants to merge 1 commit into
mainfrom
fix/bash-harness-tunnel-retry
Open

nxphi47 wants to merge 1 commit into
mainfrom
fix/bash-harness-tunnel-retry

Conversation

@nxphi47

@nxphi47 nxphi47 commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

While a sandbox's tunnel client reconnects, the tunnel edge answers 404 (no client registered for the route) or 502–504. The bash harness's chat() retried only transport errors raised while reading the stream, so any rollout with a model call in flight during a reconnect exited with status 1.

This PR:

  • moves the chat.completions.create request inside the retry, so request setup is retried too;
  • also retries 404 and 502–504, alongside connection and transport errors;
  • keeps retrying for at least two minutes (stop_after_attempt(max_retries + 1) & stop_after_delay(120)), long enough to ride out a reconnect.

The interception server's digest replay guard keeps a retried call to a single turn.

Note

Retry bash harness model calls through tunnel reconnects via _is_tunnel_gap

The bash harness in core.py retried only connection/transport errors, so tunnel reconnects surfaced as API status errors (404, 502, 503, 504) and failed the run.

  • Adds _is_tunnel_gap, a Tenacity retry predicate that treats those API status codes plus connection and transport errors as retryable.
  • Moves the completion request creation inside the retry attempt, so both the request and stream reading are covered.
  • Retry now stops only when the attempt limit and a 120-second delay threshold are both exceeded; either one alone does not stop it.

Macroscope summarized 0b74310.

…nnects

While a sandbox's tunnel client reconnects, its edge answers 404 (no client registered) or 502-504, and the chat
program retried only transport errors outside the request itself, so every rollout with a model call in flight exited
1. Retry those statuses and transport errors, request included, for at least two minutes; the interception server's
digest replay guard keeps a retried call to one turn.

Claude-Session: https://claude.ai/code/session_01PEUKiKSBdkzvBp88ioqLRK
@nxphi47
nxphi47 marked this pull request as ready for review December 4, 2026 22:31
@macroscopeapp

macroscopeapp Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 0b74310

Macroscope's review found this PR approvable — Model calls now retry through tunnel reconnects, covering both request setup and interrupted streams. Existing replay protection is retained; the main behavioral tradeoff is longer waiting before persistent failures surface.

You can add or adjust custom eligibility rules. Learn more.

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.

1 participant