Skip to main content
The OpenAI Agents SDK (@openai/agents) ships shellTool and applyPatchTool primitives that take pluggable Shell and Editor backends. Mirage provides MirageShellExecutor and MirageEditor implementations that route every command and patch through your Workspace instead of the host shell. mirageReadFileTool adds agent-initiated file reads with structured model input for text, images, and PDFs.

Install

@struktoai/mirage-openai-agents is runtime-agnostic. Pair it with @struktoai/mirage-node for Node or @struktoai/mirage-browser for the browser.

Usage

For an OpenAI-compatible provider without the Responses API, give the agent mirageTools(ws), Mirage’s seven function tools, instead of the hosted shell and editor tools.

Sandbox Agent

SandboxAgent runs the SDK’s own exec_command, apply_patch and view_image tools against a sandbox session. MirageSandboxClient makes that session a Mirage workspace, and MirageCapability adds the workspace’s mounts (backend, mode, commands) to the agent’s instructions. The client also needs @openai/agents-core, at the same version as @openai/agents.
How the session behaves:
  • Every command starts at the manifest root, / unless you configure a Manifest, or at the model’s workdir, and a cd or export ends with its command, as in the SDK’s other sandboxes. Commands see the manifest’s environment. Each sandbox session has its own Mirage session. Its commands run in it side by side, so one left running in the background does not hold up the next.
  • A command still running after exec_command’s yield time keeps running. The model polls it with write_stdin and stops it with Ctrl-C (\u0003).
  • Relative paths resolve against the manifest root. Manifest file and dir entries are written into the workspace; other entry types raise SandboxUnsupportedFeatureError.
  • A run paused for tool approval resumes on the same workspace and keeps the files the agent wrote.

Exports

Unsupported binary formats return a metadata description instead of being decoded as corrupt text. The tool reads raw workspace bytes, so files mounted from RAM, S3, and other Mirage mounts use the same model-input path.

Examples