Skip to content

fix: batch Prime background job polling - #2462

Merged
mikasenghaas merged 1 commit into
mainfrom
fix/batch-prime-background-jobs
Aug 29, 2026
Merged

fix: batch Prime background job polling#2462
mikasenghaas merged 1 commit into
mainfrom
fix/batch-prime-background-jobs

Conversation

@DamianB-BitFlipper

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

Copy link
Copy Markdown
Collaborator

Summary

Prime runtime command execution now delegates to the Prime SDK run_background_job helper instead of manually polling each job with get_background_job. Because runtimes already share one SDK client per event loop, concurrent VM job checks can now coalesce into batches of up to 100 rather than producing one gateway /read-file request per job.

The call preserves the previous one-second polling cadence and uses the existing effectively-unbounded 30-day safety deadline. Rollout cancellation remains the practical execution timeout, and result/error mapping is unchanged.

Verification

  • uv run --isolated pytest tests/: 915 passed, 76 credential-gated tests skipped
  • focused delegation test: passed
  • Ruff, formatting, and pre-push ty checks: passed
  • all-files Markdown lint remains blocked by pre-existing inline HTML findings in the untouched ScaleSWE README

Note

Medium Risk
Changes how every Prime run() waits on VM jobs; behavior is intended to match prior polling but relies on SDK batching and timeout semantics.

Overview
Prime sandbox command execution now uses the shared SDK run_background_job helper instead of starting a job and polling get_background_job in a loop. That lets concurrent polls on the per–event-loop client batch (up to ~100 jobs), cutting per-job gateway traffic while keeping 1s poll_interval and the same long safety deadline.

The idle-timeout sandbox lifetime fallback constant is renamed to EFFECTIVELY_UNBOUNDED_SECONDS with a clearer docstring; container timeout_minutes still uses that 30-day bound. Rollout cancellation remains the real timeout; ProgramResult mapping is unchanged.

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

Note

Replace manual polling with SDK run_background_job in PrimeRuntime.run

  • Replaces the manual start_background_job + get_background_job while-loop with 1s sleeps in PrimeRuntime.run with a single SDK run_background_job call using timeout=EFFECTIVELY_UNBOUNDED_SECONDS and poll_interval=1.
  • Renames IDLE_FALLBACK_LIFETIME to EFFECTIVELY_UNBOUNDED_SECONDS in prime.py and updates all references including the sandbox timeout calculation.
  • Risk: polling behavior and timeout enforcement now depend on the SDK's run_background_job implementation rather than the previous manual loop.

Macroscope summarized b2e7304.

@macroscopeapp

macroscopeapp Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at b2e7304

Macroscope's review found this PR approvable — This localized Prime runtime fix replaces manual one-second job polling with the existing SDK helper, preserving command execution and result handling while enabling shared-client batching. The only added bound is a 30-day safety deadline, leaving normal rollout timeouts and existing behavior effectively unchanged.

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

@mikasenghaas
mikasenghaas merged commit 573bfa1 into main Aug 29, 2026
13 checks passed
@mikasenghaas
mikasenghaas deleted the fix/batch-prime-background-jobs branch August 29, 2026 04:17
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