cpuos

Integration · Agent framework

OpenAI Agents SDK with cpuos sandboxes

Give an OpenAI Agents SDK agent a sandboxed code tool: a function tool that runs code in a cpuos microVM, with any OpenAI-compatible model.

SDK
@cpuos/sdk · pip install cpuos
Model endpoint
https://gpuos.si/v1 or any OpenAI-compatible
Status
Early access

A function tool backed by a sandbox

The Agents SDK turns a typed Python function into a tool with @function_tool. Make that function write the code into a cpuos sandbox and run it there, and the agent can execute whatever it writes without touching your machine.

Install
pip install openai-agents cpuos
agent.py
import osfrom agents import (Agent, OpenAIChatCompletionsModel, Runner,                    function_tool, set_tracing_disabled)from cpuos import Sandboxfrom openai import AsyncOpenAIgpuos = AsyncOpenAI(base_url="https://gpuos.si/v1", api_key=os.environ["GPUOS_API_KEY"])set_tracing_disabled(True)  # traces go to OpenAI by defaultsbx = Sandbox.create(template="python", timeout="30m")@function_tooldef run_python(code: str) -> str:    """Run a Python 3 script in an isolated sandbox. Files live in /work.    Returns the exit code, stdout and stderr."""    sbx.files.write("/work/main.py", code)    run = sbx.exec("cd /work && python main.py", timeout="2m")    return f"exit_code={run.exit_code}\n{run.stdout[-4000:]}\n{run.stderr[-2000:]}"agent = Agent(    name="Analyst",    instructions="Compute every number with run_python. Files are in /work.",    model=OpenAIChatCompletionsModel(model="qwen3-32b", openai_client=gpuos),    tools=[run_python],)result = Runner.run_sync(agent, "What is the 90th Fibonacci number?")print(result.final_output)sbx.pause()

The examples point the model at gpuOS, which serves open models on your own GPUs at https://gpuos.si/v1 with an OpenAI-compatible API. Any other OpenAI-compatible provider works the same way: change the base URL, the key and the model name.

cpuos is in early access: @cpuos/sdk (npm) and cpuos (PyPI) ship to early-access teams first, and read the API key from CPUOS_API_KEY. The calls on this page show the current API shape.

One sandbox per conversation

Create the sandbox when a conversation starts and pass it to the tool through the run context instead of a global, so two users never share a machine. Pause it when the run ends and store the id with the conversation; Sandbox.resume(id) brings back the files and installed packages on the next turn.

Official documentation: openai.github.io/openai-agents-python

Questions

Why disable tracing?
The Agents SDK uploads traces to OpenAI by default, which needs an OpenAI key and sends your run data there. Disable it, or configure your own trace processor, when you use another model provider.
Does the Agents SDK have its own code interpreter?
Its hosted code interpreter tool runs on OpenAI's infrastructure and only works with OpenAI models. A function tool backed by cpuos works with any model and keeps execution in the EU.
Which model should I use?
One trained for tool calling, such as Qwen3 32B, GLM-4 32B or gpt-oss 20B on gpuOS.

Related

Run OpenAI Agents SDK tool calls in a sandbox

cpuos is in early access: a Firecracker microVM per task, hosted in the EU or on your servers, billed per second and free while paused.

gpuOS · where models think

Need the model too? Run it on gpuOS

gpuOS serves open models on your own GPUs behind one OpenAI-compatible API. The model reasons on gpuOS, the agent acts in a cpuOS sandbox.