Skip to content

fix(sandboxes): bound background output retrieval - #862

Merged
DamianB-BitFlipper merged 4 commits into
mainfrom
fix/sdk-background-output-burst
Sep 1, 2026
Merged

fix(sandboxes): bound background output retrieval#862
DamianB-BitFlipper merged 4 commits into
mainfrom
fix/sdk-background-output-burst

Conversation

@DamianB-BitFlipper

@DamianB-BitFlipper DamianB-BitFlipper commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Caps background-job output reads at 20 concurrent requests, retrieves stdout/stderr
sequentially, preserves completed exit codes when output retrieval fails, adds jittered retries and
errno diagnostics, and includes a 100-job concurrency test.

Verification:

  • 82 focused tests passed
  • Ruff checks passed
  • Wheel build passed

Note

Medium Risk
Large change to background-job polling, concurrency, and client shutdown/delete ordering; behavior is well-tested but affects hot paths for VM batch job monitoring.

Overview
VM background jobs now separate completion checks from stdout/stderr downloads. New get_background_job_status / get_background_job_statuses return BackgroundJobStatusSnapshot without touching log files; get_background_job and get_background_jobs still hydrate tails but route output through a shared coordinator.

Output hydration is deduplicated per job, cached in a byte-bounded LRU, and limited client-wide (defaults: 20 active, 200 queued, 64 MiB cache) via background_job_output_concurrency, background_job_output_queue_size, and background_job_output_cache_bytes on sync/async clients. Fetches are fair across sandboxes, sequential per job (stdout then stderr), and respect a bounded retrieval deadline after the exit file is seen.

Reliability: BackgroundJobStatus gains stdout_error / stderr_error so a known exit code stays authoritative when a stream is missing; read retries use jittered backoff and richer errno diagnostics. Sandbox delete/drain cancels queued output work and coordinates with the expanded operation lease registry before API teardown.

Reviewed by Cursor Bugbot for commit 63425e7. Bugbot is set up for automated code reviews on this repo. Configure here.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8ca296c473

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/prime-sandboxes/src/prime_sandboxes/sandbox.py Outdated
Comment thread packages/prime-sandboxes/src/prime_sandboxes/sandbox.py
Comment thread packages/prime-sandboxes/src/prime_sandboxes/sandbox.py Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 822778c. Configure here.

Comment thread packages/prime-sandboxes/src/prime_sandboxes/sandbox.py
Comment thread packages/prime-sandboxes/src/prime_sandboxes/sandbox.py Outdated
@DamianB-BitFlipper
DamianB-BitFlipper merged commit 7d63394 into main Sep 1, 2026
18 checks passed
@DamianB-BitFlipper
DamianB-BitFlipper deleted the fix/sdk-background-output-burst branch September 1, 2026 16:06
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.

2 participants