Skip to content

API Reference parrot.eval.sandbox.base

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.eval.sandbox.base

View source

Sandbox ABCs and NoopSandbox for the Generic Agent Evaluation Harness.

FEAT-217 — Module 3. Defines the execution-environment contract used by every rollout and the runner.

Key types

SandboxSpec Pydantic configuration for a sandbox instance. Sandbox Async context manager + lifecycle ABC. SandboxProvider Factory ABC that acquires and releases Sandbox instances. AgentFactory Type alias: Callable[[Sandbox], Awaitable[AbstractBot]]. NoopSandbox / NoopSandboxProvider Trivial implementation for conversational / RAG agents that do not interact with a stateful environment. ExecResult Small model returned by Sandbox.exec().

Alias AbstractBot

Re-exported from parrot.bots.abstract.AbstractBot.

Attribute AgentFactory

Class ExecResult

Result of a command executed inside a sandbox.

Fields:

Field Type Default Description
exit_code int Process exit code (0 = success).
stdout str '' Standard output captured from the command.
stderr str '' Standard error captured from the command.

Class NoopSandbox

No-operation sandbox for agents that do not mutate external state.

Suitable for conversational and RAG agents. All lifecycle methods are trivial: reset and snapshot do nothing / return empty dicts; health_check always returns True; exec raises NotImplementedError.

Method NoopSandbox.reset

No-op reset (NoopSandbox has no state).

reset(seed_state: dict[str, Any] | None) -> None

Parameter Type Default Description
seed_state dict[str, Any] | None Ignored.

Method NoopSandbox.health_check

Always healthy.

health_check() -> bool

Returns: bool — True.

Method NoopSandbox.snapshot

Return an empty state dict.

snapshot() -> dict[str, Any]

Returns: dict[str, Any] — Empty dict.

Class NoopSandboxProvider

Provider that always returns a fresh NoopSandbox.

Suitable for conversational / RAG evaluation where no real sandbox isolation is required.

Method NoopSandboxProvider.acquire

Return a new NoopSandbox (ignoring spec).

acquire(spec: SandboxSpec) -> NoopSandbox

Parameter Type Default Description
spec SandboxSpec Ignored.

Returns: NoopSandbox — A fresh NoopSandbox.

Method NoopSandboxProvider.release

GC the sandbox (no pool).

release(sandbox: Sandbox) -> None

Parameter Type Default Description
sandbox Sandbox Ignored.

Class Sandbox

Abstract execution environment for agent evaluation.

Sandboxes are used as async context managers so the runner can bracket the lifecycle cleanly:

async with sandbox:
    await sandbox.reset(seed_state)
    bot = await agent_factory(sandbox)
    trajectory = await rollout.run(bot, task, sandbox)
    state = await sandbox.snapshot()

Subclasses provide concrete isolation strategies (in-memory, Docker, …).

Method Sandbox.reset

Reset the sandbox to a known state.

reset(seed_state: dict[str, Any] | None) -> None

Parameter Type Default Description
seed_state dict[str, Any] | None Initial state to load. None empties the store.

Method Sandbox.health_check

Check whether the sandbox is operational.

health_check() -> bool

Returns: bool — True if the sandbox is healthy.

Method Sandbox.snapshot

Capture a deterministic snapshot of the current world state.

snapshot() -> dict[str, Any]

Returns: dict[str, Any] — A deep copy of the current state, sorted for stable diffs.

Method Sandbox.exec

Execute a shell command inside the sandbox.

Concrete implementations (e.g. DockerSandbox) override this. State-based sandboxes raise NotImplementedError.

exec(cmd: list[str]) -> ExecResult

Parameter Type Default Description
cmd list[str] Command and arguments to execute.

Returns: ExecResult — ExecResult with exit code, stdout, stderr.

Raises:

  • NotImplementedError — If this sandbox type does not support command execution.

Class SandboxProvider

Factory that acquires and releases Sandbox instances.

Implementations may pool sandboxes (Docker) or provision fresh per attempt (InMemoryStateSandboxProvider).

Method SandboxProvider.acquire

Acquire a sandbox configured according to spec.

acquire(spec: SandboxSpec) -> Sandbox

Parameter Type Default Description
spec SandboxSpec Sandbox configuration.

Returns: Sandbox — A ready-to-use Sandbox instance.

Method SandboxProvider.release

Return a sandbox to the pool (or GC it for fresh-per-attempt).

release(sandbox: Sandbox) -> None

Parameter Type Default Description
sandbox Sandbox The sandbox to release.

Class SandboxSpec

Configuration for a sandbox instance.

Fields:

Field Type Default Description
kind Literal['docker', 'in_memory_state', 'mock_api', 'noop'] 'noop' Sandbox implementation selector.
image str | None None Docker image tag (only used by DockerSandbox).
setup list[str] Shell commands to run after the sandbox starts.
seed_state dict[str, Any] | None None Initial world state to load into state-based sandboxes.
git_truncate_after str | None None Git ref to truncate history to (SWE-bench use).

Attribute logger

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally