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:
- The per-agent sandbox for
request.agent_id(the agent's real Jupyter sandbox when running inloopmode). - The manager's currently active sandbox.
- The managed sandbox (respects the configured variant), created lazily.