Retry OpenCodeSessionFactory.create() with backoff#1009
Open
sergiopaniego wants to merge 1 commit into
Open
Conversation
Session creation spins up a sandbox, installs opencode, and starts the proxy + agent, the flakiest step in a rollout; a single transient failure used to drop the rollout as unscorable, shrinking the effective group size. create() now retries create_attempts times with exponential backoff. The per-attempt logic moved to _create_once, which already tears its own sandbox down on failure, so a retry never leaks a sandbox.
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds retry-with-backoff to
OpenCodeSessionFactory.create().Why
Session creation spins up a sandbox, installs opencode, and starts the proxy + agent. It is the flakiest step in a rollout (sandbox-API blips, cold install, proxy start). Today a single transient failure drops the whole rollout as unscorable, which shrinks the effective group size and silently weakens the training signal. This is one of the
TODO(@openenv)gaps flagged in TRL's loop-owning harness work (huggingface/trl#6420).Change
create()now retries up tocreate_attempts(default 3) with exponential backoff (create_backoff_s * 2**i, default base 2s), matching the existing_exec_with_retrystyle._create_once, which already tears its own sandbox down on any post-provision failure, so a retry never leaks a sandbox.Tests
The two existing teardown tests now pin
create_attempts=1(they test a single attempt's cleanup). Two new tests cover the wrapper: retries-then-succeeds, and raises-after-exhausting-attempts.pi_env'sPiSessionFactory.create()mirrors this and gets the same change on its own PR (#999).AI-assisted.
Note
Low Risk
Isolated harness resilience change with defaults preserving prior single-attempt behavior aside from up to two extra retries on failure; no auth or data-path changes.
Overview
OpenCodeSessionFactory.create()now retries flaky session startup instead of failing a rollout on the first transient error.The factory accepts
create_attempts(default 3) andcreate_backoff_s(default 2s, exponential2**i), in the same spirit as existing_exec_with_retry. Per-attempt provisioning lives in_create_once, which still kills the sandbox on failure so retries do not leak resources.Lifecycle tests pin
create_attempts=1so they exercise a single attempt’s teardown; new tests cover success after transient failures and re-raising after all attempts are exhausted.Reviewed by Cursor Bugbot for commit 7ad41ac. Bugbot is set up for automated code reviews on this repo. Configure here.