Skip to main content

routes.sandbox

HTTP route for executing code in the running agent's code sandbox.

This endpoint lets out-of-process clients (e.g. the interactive TUX, which runs in a separate OS process from the agent-runtimes server) execute code in the existing sandbox owned by the server — most importantly the per-agent Jupyter sandbox created at agent startup — instead of spinning up a brand new sandbox in the caller's process.

Execution and result normalization are delegated to :class:code_sandboxes.CodeSandboxClient so the wire response is independent of the underlying sandbox variant.

SandboxExecuteRequest Objects

class SandboxExecuteRequest(BaseModel)

Request body for :func:execute_sandbox_code.

SandboxExecuteResponse Objects

class SandboxExecuteResponse(BaseModel)

Normalized execution result.

execute_sandbox_code

@router.post("/execute", response_model=SandboxExecuteResponse)
async def execute_sandbox_code(
request: SandboxExecuteRequest) -> SandboxExecuteResponse

Execute code in the server's existing sandbox and return the output.

Resolution order for the target sandbox:

  1. The per-agent sandbox for request.agent_id (the agent's real Jupyter sandbox when running in loop mode).
  2. The manager's currently active sandbox.
  3. The managed sandbox (respects the configured variant), created lazily.