Skip to content

Support restricted shared agent runtimes - #2125

Open
xeophon wants to merge 10 commits into
PrimeIntellect-ai:mainfrom
xeophon:agent/fix-agentic-judge-restricted-runtime
Open

Support restricted shared agent runtimes#2125
xeophon wants to merge 10 commits into
PrimeIntellect-ai:mainfrom
xeophon:agent/fix-agentic-judge-restricted-runtime

Conversation

@xeophon

@xeophon xeophon commented Jul 24, 2026

Copy link
Copy Markdown
Member

Overview

Enable sequential agents to share a network-restricted runtime while preserving the trusted-setup and restricted-execution boundary.

Details

The base runtime now owns the common policy lifecycle: it grants trusted setup once, records policy activation, and accumulates framework routes used by later rollouts. Docker and Prime reuse that lifecycle while keeping only their backend-specific enforcement code. Docker updates its proxy policy without repeating the one-way network cut, while Prime reapplies its provider policy when a new framework route is introduced.

An exported shared_runtime context manager provisions one box and prepares peer harnesses before restrictions activate. Later sequential agents skip harness installation, retain their own task and trace lifecycle, and refresh the active policy with their current interception and tool routes.

Agentic judge uses this abstraction for Docker and Prime solver runtimes and carries the solver task network policy into the generated judge task.

Note

Support restricted shared agent runtimes across rollouts

  • Adds a Runtime.rollout async context manager that enables restricted runtimes to be reused across rollouts by killing non-baseline processes, clearing setup caches, and toggling between unrestricted trusted-setup networking and filtered execution-time networking between runs.
  • Introduces Runtime._apply_network_policy(routes) as an abstract method; passing None restores unrestricted networking, passing routes applies the configured allow/block policy. Implemented in both DockerRuntime and PrimeRuntime.
  • AgenticJudgeEnv.run raises RuntimeError if the shared runtime is network-restricted but execution_prepared is not set, indicating the solver exited before the network policy was activated.
  • Judge tasks now inherit the solver task's network_allow and network_block settings via JudgeTask.from_trace.
  • Risk: restricted runtimes now raise SandboxError if a second rollout is attempted while one is already in progress (exclusive claim required).

Macroscope summarized bd752cf.


Note

High Risk
Changes sandbox isolation (process killing, network policy toggling) and concurrent-use rules for restricted runtimes; mis-implementation could leak egress or break multi-agent shared-box flows.

Overview
Network-restricted runtimes can be reused across sequential rollouts instead of being single-use. prepare_setup() is replaced by a Runtime.rollout() async context manager that exclusively claims the box, and on reuse kills processes not in the prior snapshot, clears uv/setup caches, and temporarily restores unrestricted egress before the next agent’s trusted setup.

Rollouts enter that scope via a dedicated _runtime_stack in RolloutRun (including on abort/close). prepare_execution now drives policy through _apply_network_policy(routes) and sets execution_prepared when the cut is applied.

Docker and Prime implement _apply_network_policy: routes=None opens trusted setup; non-None applies allow/block plus framework routes. Docker skips repeating the one-way iptables cut when _cut is already set.

Agentic judge copies the solver’s network_allow / network_block onto the judge task and raises if the shared box is restricted but the solver never reached execution_prepared. The agentic-judge e2e uses a Docker block list to exercise the restricted shared box path.

Reviewed by Cursor Bugbot for commit bd752cf. 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: 4ea5724d82

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/utils/shared_runtime.py Outdated
Comment thread verifiers/v1/rollout.py Outdated

@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: 0334d5e42f

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/rollout.py Outdated

@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: 01a16162f2

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/utils/shared_runtime.py Outdated
Comment thread verifiers/v1/utils/shared_runtime.py Outdated

@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: 335bbe4238

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/runtimes/base.py Outdated
Comment thread verifiers/v1/utils/shared_runtime.py Outdated

@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: 172d2c76af

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/utils/shared_runtime.py Outdated
Comment thread verifiers/v1/rollout.py Outdated
Comment thread verifiers/v1/runtimes/base.py

@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: 774f7cc779

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/runtimes/base.py
Comment thread verifiers/v1/runtimes/base.py

@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: 018d0c31fe

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread verifiers/v1/runtimes/base.py

@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 1 potential issue.

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 797eb7b. Configure here.

Comment thread verifiers/v1/runtimes/base.py

@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: c16de90919

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +239 to +243
if routes is None:
self._proxy.policy = NetworkPolicy(
["*"], [], [HOST_ALIAS], allow_non_global=True
)
return

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Restore Docker setup networking on reuse

When a restricted Docker box is reused after the first rollout, this branch only makes the HTTP proxy permissive; the container routes are still cut because _cut remains true and DockerRuntime.run() can only help commands that honor the injected proxy env. A later task or harness setup that uses raw TCP/SSH or a tool that ignores HTTP_PROXY will fail even though runtime.rollout() has supposedly reopened trusted setup; before this change those restricted Docker runtimes were rejected for reuse. Either restore the routes or keep Docker shared reuse limited to cases where setup is proxy-compatible.

Useful? React with 👍 / 👎.

@xeophon
xeophon force-pushed the agent/fix-agentic-judge-restricted-runtime branch from c16de90 to bd752cf Compare July 27, 2026 13:27

@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: bd752cf75b

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +344 to +346
result = await self.run(
["sh", "-c", _KILL_AFTER_SNAPSHOT],
{"VF_PROCESS_BASELINE": self._process_baseline},

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Perform reuse cleanup outside the mutable sandbox

When the first agent runs as root, as it does in the default Docker Python image, it can replace sh or place a malicious one earlier on PATH; the next rollout then executes this attacker-controlled binary to perform the process cleanup. It can report success without killing anything, and the subsequent shell-based snapshot can preserve its background process as part of the new baseline before unrestricted setup networking is restored, allowing solver code to forge the judge result or use trusted egress. Fresh evidence in this revision is that the newly added isolation defense itself relies on executables from the filesystem it is meant to distrust; process cleanup and snapshotting need to occur through a host/provider mechanism or an immutable trusted executable.

Useful? React with 👍 / 👎.

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.

1 participant