Skip to content

[BREAKING] MAINT: Rename SandboxClient to ExecutionClient (part 2) - #4732

Merged
Richard Lundeen (richlundeen) merged 6 commits into
microsoft:mainfrom
richlundeen:richlundeen-exec-stack-1-rename
Nov 30, 2026
Merged

Richard Lundeen (richlundeen) merged 6 commits into
microsoft:mainfrom
richlundeen:richlundeen-exec-stack-1-rename

Conversation

@richlundeen

@richlundeen Richard Lundeen (richlundeen) commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Description

Part 2 of the code-execution stack, which lets PyRIT test models that act by running code. This part renames the client contract to say what it does. A client asks a backend to run code; isolation is a property of the backend's environment, which the client cannot guarantee, so calling it a sandbox client promised more than it can deliver.

The stack, merged in order:

  1. FEAT: Bound OpenAIResponseTarget's tool loop, and end the turn when a tool's infrastructure fails (part 1) #4101 Bounded tool loop for OpenAIResponseTarget (merged)
  2. [BREAKING] MAINT: Rename SandboxClient to ExecutionClient (part 2) #4732 Rename SandboxClient to ExecutionClient (this PR)
  3. FEAT: Declared capabilities for ExecutionClient, with per-call timeouts and pre-run validation (part 3) #4102 Declared capabilities for ExecutionClient, with per-call timeouts and pre-run validation
  4. FEAT: ExecutionToolProvider, so a model's tool calls run on an execution backend, with provenance on each result (part 4) #4104 ExecutionToolProvider, with provenance on each result

Independent of the stack: #4733, staged scoring with TrueFalseCompositeScorer(sequential=True).

Before After
SandboxClient ExecutionClient
SandboxExecutionError ExecutionInfrastructureError
DockerSandboxClient DockerExecutionClient
ProgramExecutionSource(sandbox=...) ProgramExecutionSource(client=...)
  • No deprecation cycle. pyrit._code_execution is private and documented to change without one, so the 1.2 names no longer resolve. To migrate, rename the imports as in the table and pass client= to ProgramExecutionSource; sandbox= is no longer accepted.
  • ProgramExecutionSource's identifier names its child client instead of sandbox. Scorer identities recorded before this change don't match the new ones: the Docker client's class name changes, and for a custom client the new child key alone changes the identity.
  • The sandbox_warnings observation metadata key is unchanged, so stored observations read the same.
  • Custom clients written against 1.2 return the private _ExecutionRun, renamed from _SandboxRun.
  • Docs: the Code Execution section of doc/code/framework.md and the program execution scorer notebook.

🤖 Generated with Claude Code

A client asks a backend to run code; whether that backend isolates it is a property of the environment,
which the client cannot guarantee. The new names say what the client does:

- SandboxClient -> ExecutionClient
- SandboxExecutionError -> ExecutionInfrastructureError
- DockerSandboxClient -> DockerExecutionClient
- ProgramExecutionSource(sandbox=...) -> ProgramExecutionSource(client=...)

The old names shipped in 1.2, so they still resolve, with a deprecation warning, until 1.5.0. The
sandbox_warnings observation metadata key is unchanged, so stored observations read the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Deprecated names now resolve to object through __getattr__, breaking existing typed callers before the promised 1.5.0 removal.

1 open issue
What changed in this PR

Renames the code-execution client contract to distinguish execution from backend-provided isolation, preparing the stack for capability declarations and execution tools.

Changes:

  • Renames the client, Docker implementation, infrastructure exception, and private execution-result type.
  • Adds deprecated runtime aliases and a client keyword for ProgramExecutionSource, updating identifiers while preserving sandbox_warnings metadata.
  • Updates documentation and tests, including compatibility coverage.
File Description
tests/​unit/​score/​test_program_execution_scorer.py Updates client usage and tests keyword compatibility and identifiers.
tests/​unit/​models/​test_code_execution.py Updates execution-result round-trip coverage.
tests/​unit/​common/​test_lazy_package_imports.py Updates lazy-import and layer-boundary checks.
tests/​unit/​_code_execution/​test_docker_client.py Migrates Docker tests to renamed types.
tests/​unit/​_code_execution/​test_client.py Tests deprecated runtime exports and warnings.
tests/​integration/​score/​test_program_execution_scorer_integration.py Migrates real Docker execution tests.
pyrit/​score/​observation/​program_execution_source.py Adds client, deprecates sandbox, and updates identifiers.
pyrit/​models/​code_execution.py Renames _SandboxRun to _ExecutionRun.
pyrit/​_code_execution/​docker_client.py Renames the Docker client and infrastructure exception references.
pyrit/​_code_execution/​client.py Renames the contract and clarifies isolation responsibilities.
pyrit/​_code_execution/​__init__.py Exports renamed classes with deprecated runtime aliases.
doc/​code/​scoring/​7_program_execution_scorer.py Updates the executable scoring example.
doc/​code/​scoring/​7_program_execution_scorer.ipynb Updates the matching notebook example.
doc/​code/​framework.md Clarifies execution-client and environment responsibilities.

Review effort: Balanced

Comment thread pyrit/_code_execution/__init__.py Resolved
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move the framework's isolation sentence after the Docker exception so it applies to every client, drop 'isolated' and 'sandbox' from the observation payload and scorer docstrings, and label a partial-run infrastructure failure 'execution backend error' like a whole-run one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Automated review completed. No blocking concerns remain. This review records source coverage; merging is handled separately.

Richard Lundeen (richlundeen) added a commit to richlundeen/PyRIT that referenced this pull request Nov 29, 2026
Keep this layer's three capability bullets in the Code Execution section of
doc/code/framework.md and take microsoft#4732's sentence order for the bullet that
leaves environments to the caller.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@richlundeen
Richard Lundeen (richlundeen) marked this pull request as ready for review November 30, 2026 17:35

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good, thanks for changing the name

pyrit._code_execution is private and documented to change without a deprecation cycle, so the 1.2 names
SandboxClient, SandboxExecutionError and DockerSandboxClient no longer resolve. ProgramExecutionSource's
keyword is client= only; its client is always an object from that private package, and the shim made the
argument optional in the signature and the registry's build contract.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Richard Lundeen (richlundeen) added a commit to richlundeen/PyRIT that referenced this pull request Nov 30, 2026
…pabilities layer

# Conflicts:
#	pyrit/score/observation/program_execution_source.py
@richlundeen Richard Lundeen (richlundeen) changed the title MAINT: Rename SandboxClient to ExecutionClient (part 2) [BREAKING] MAINT: Rename SandboxClient to ExecutionClient (part 2) Nov 30, 2026
The required diff-coverage check counts every line the rename touched. Five of them, all failure paths in
DockerExecutionClient, had no unit test: an unverifiable cleanup after a failed start, a capture that outlives
the stopped client, unreadable client output, and a malformed exit code or memory-kill state from inspect.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@richlundeen
Richard Lundeen (richlundeen) added this pull request to the merge queue Nov 30, 2026
Merged via the queue into microsoft:main with commit 1b06126 Nov 30, 2026
76 of 78 checks passed
@richlundeen
Richard Lundeen (richlundeen) deleted the richlundeen-exec-stack-1-rename branch November 30, 2026 19:42
Richard Lundeen (richlundeen) added a commit to richlundeen/PyRIT that referenced this pull request Dec 1, 2026
…rged

This layer was built on microsoft#4732's pre-squash head 9bc983d, and microsoft#4732 has
since squash-merged into main as 1b06126. A plain merge re-diffs the old
pre-squash microsoft#4732 content against main's squashed version, so this merge uses
9bc983d as the merge base (git merge-tree --merge-base) to apply only the
layer's own changes on top of main.

One content conflict, in tests/unit/_code_execution/test_docker_client.py:
microsoft#4732's final head and this layer both appended tests after
test_profiles_are_explicit_trusted_configuration. Both sets are kept in full,
main's coverage tests first and the layer's tests after them. Everything else
in that file is main's version plus the layer's own hunks. No other changes
were needed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

4 participants