fix(sandboxes): retry transient background-job status timeouts - #904
Draft
samsja wants to merge 1 commit into
Draft
fix(sandboxes): retry transient background-job status timeouts#904samsja wants to merge 1 commit into
samsja wants to merge 1 commit into
Conversation
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.
Summary
Motivation
Production RL workloads intermittently received structured per-job errors while polling commands that were already running:
Surfacing that transient status-read failure immediately aborts the rollout even though relaunching the command would be unsafe and the original command may complete normally. This change retries the read instead, allowing four consecutive status attempts with 1s/2s/4s backoff. A successful poll resets that consecutive-failure budget, and all polling remains bounded by the caller's existing command deadline.
This does not retry sandbox creation, command launch, rate limits, egress failures, or persistent runtime errors.
Live A/B result
We ran two simultaneous, launch-order-reversed waves against the active service using the production
prime-sandboxes==0.2.39client. Each arm used four VMs and ran 800 commands total over the same service windows.The headline 99.50% to 100% success-rate difference might just be noise: the Wilson 95% intervals overlap (stock 98.72–99.81%, patched 99.52–100%) and a two-sided Fisher exact test gives
p=0.125. It is still interesting because the patched arm actually saw slightly more raw backend timeout items and recovered all five, while preserving exactly one launch per command. That instrumented recovery path is stronger evidence for the behavior than the aggregate score alone.The timeout items were correlated status-batch events: stock fanout was
2 + 2, while patched fanout was3 + 2. Median/p95 command latency was 1.357s/11.044s for stock and 1.309s/10.645s for patched. The sample is too small to attribute the latency difference to this patch.The live A/B used the exact production 0.2.39 implementation. This PR ports the same behavior onto current
main/prime-sandboxes0.2.41 and narrows the classifier to the exact structured timeout message.Validation
uv run pytest packages/prime-sandboxes/tests/test_batch_status.py -q— 43 passeduv run pre-commit run --all-files— passedPRIME_API_KEYTests cover sync and async recovery, bounded exhaustion, exactly-once command launch, and immediate failure for unrelated
RUNTIME_ERRORresponses.