fix(v1): allow concurrent borrowed runtime environments - #2418
Merged
Conversation
parkerpettit
marked this pull request as ready for review
August 25, 2026 23:27
Contributor
ApprovabilityVerdict: Not approved Macroscope's review found this PR not approvable — The PR changes the production borrowed-runtime lifecycle from serialized use to concurrent use by introducing shallow views that share provider state while isolating environments. This cross-runtime concurrency and cleanup change has broader operational impact than a routine isolated bug fix and merits human review. Not approved because:
Review your spending limits in Billing settings. You can add or adjust custom eligibility rules. Learn more. |
parkerpettit
force-pushed
the
fix/concurrent-borrowed-runtime-env
branch
from
August 25, 2026 23:54
f6e3322 to
e4897c3
Compare
parkerpettit
marked this pull request as draft
August 26, 2026 00:03
parkerpettit
marked this pull request as ready for review
August 26, 2026 00:10
parkerpettit
force-pushed
the
fix/concurrent-borrowed-runtime-env
branch
from
August 26, 2026 00:56
e0e2e7c to
d90b924
Compare
mikasenghaas
approved these changes
Aug 26, 2026
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
Why
#2362 added a rollout-wide lock because borrowed rollouts were applying their process environment directly to the shared runtime. Without serialization, concurrent agents could overwrite each other’s environment variables.
The lock prevented that race, but it also serialized the entire lifetime of every borrowed rollout. This can deadlock nested-agent workflows:
This PR removes the need for that lock by using
Runtime.with_env(). Each rollout gets its own process-environment view while continuing to share the same underlying sandbox handles. Concurrent rollouts therefore cannot overwrite each other’s environment, which preserves the isolation the lock was added to provide without serializing agents.Network policy remains sandbox-scoped. The existing borrowed-placement validation rejects any agent or task whose required policy is incompatible with the sandbox. All valid borrowers therefore share the same network policy and can run concurrently.
Owner lifecycle checks continue to operate on the physical runtime, so the sandbox cannot be closed or replaced while borrowed agents are using it.