Zum Hauptinhalt springen
OpenAI

11. März 2026

Ingenieurwesen

From model to agent: Equipping the Responses API with a computer environment

By Bo Xu, Danny Zhang, and Rohit Arunachalam

Laden …

We're currently in a shift from using models, which excel at particular tasks, to using agents capable of handling complex workflows. By prompting models, you can only access trained intelligence. However, giving the model a computer environment can achieve a much wider range of use cases, like running services, requesting data from APIs, or generating more useful artifacts like spreadsheets or reports.

A few practical problems emerge when you try to build agents: where to put intermediate files, how to avoid pasting large tables into a prompt, how to give the workflow network access without creating a security headache, and how to handle timeouts and retries without building a workflow system yourself.

Instead of putting it on developers to build their own execution environments, we built the necessary components to equip the Responses API(wird in einem neuen Fenster geöffnet) with a computer environment to reliably execute real-world tasks.

OpenAI’s Responses API, together with the shell tool and a hosted container workspace, is designed to address these practical problems. The model proposes steps and commands; the platform runs them in an isolated environment with a filesystem for inputs and outputs, optional structured storage (like SQLite), and restricted network access. 

In this post, we’ll break down how we built a computer environment for agents and share some early lessons on how to use it for faster, more repeatable, and safer production workflows.

The shell tool

A good agent workflow starts with a tight execution loop: the model proposes an action like reading files or fetching data with API, the platform runs it, and the result feeds into the next step. We’ll start with the shell tool—the simplest way to see this loop in action—and then cover the container workspace, networking, reusable skills, and context compaction.

To understand the shell tool, it’s first useful to understand how a language model uses tools in general: to do things like call a function or interact with a computer. During training, a model is shown examples of how tools are used and the resulting effects, step by step. This helps the model learn to decide when to use a tool and how to use it. When we say “using a tool”, we mean the model actually only proposes a tool call. It can't execute the call on its own.

Das Shell-Tool ist „nur ein Tool wie jedes andere“ mit Diagramm

The shell tool makes the model dramatically more powerful: it interacts with a computer through the command line to carry out a wide range of tasks, from searching for text to sending API requests on your computer. Built on familiar Unix tooling, our shell tool can do anything you'd expect, with utilities like grep, curl, and awk available out of the box.

Compared to our existing code interpreter, which only executes Python, the shell tool enables a much wider range of use cases, like running Go or Java programs or starting a NodeJS server. This flexibility lets the model fulfill complex agentic tasks.

Orchestrating the agent loop

On its own, a model can only propose shell commands, but how are these commands executed? We need an orchestrator to get model output, invoke tools, and pass the tool response back to the model in a loop, until the task is complete.

The Responses API is how developers interact with OpenAI models. When used with custom tools, the Responses API yields control back to the client, and the client requires its own harness for running the tools. However, this API can also orchestrate between the model and hosted tools out of the box. 

When the Responses API receives a prompt, it assembles model context: user prompt, prior conversation state, and tool instructions. For shell execution to work, the prompt must mention using the shell tool and the selected model must be trained to propose shell commands—models GPT‑5.2 and later are trained for this. With all of this context, the model then decides the next action. If it chooses shell execution, it returns one or more shell commands to Responses API service. The API service forwards those commands to the container runtime, streams back shell output, and feeds it to the model in the next request’s context. The model can then inspect the results, issue follow-up commands, or produce a final answer. The Responses API repeats this loop until the model returns a completion without additional shell commands.

Diagramm einer Agenten-Schleife: Responses API orchestriert Modell- und Shell-Ausführung in Container

When the Responses API executes a shell command, it maintains a streaming connection to the container service. As output is produced, the API relays it to the model in near real time so the model can decide whether to wait for more output, run another command, or move on to a final response.

Ausgabe der Shell-Befehlsausführung wird gestreamt

Die Responses API streamt die Ausgabe des Shell-Befehls

The model can propose multiple shell commands in one step, and the Responses API can execute them concurrently using separate container sessions. Each session streams output independently, and the API multiplexes those streams back into structured tool outputs as context. In other words, the agent loop can parallelize work, such as searching files, fetching data, and validating intermediate results.

Responses API bündelt Befehlsausführungssitzungen

When the command involves file operations or data processing, shell output can become very large and consume context budgets without adding useful signals. To control this, the model specifies an output cap per command. The Responses API enforces that cap and returns a bounded result that preserves both the beginning and end of the output, while marking omitted content. For example, you might bound the output to 1,000 characters, with preserved beginning and end:

text at the beginning ... 1000 chars truncated ... text at the end

Together, concurrent execution and bounded output make the agent loop both fast and context-efficient so the model can keep reasoning over relevant results instead of getting overwhelmed by raw terminal logs.

When the context window gets full: compaction

One potential issue with agent loops is that tasks can run for a long time. Long-running tasks fill the context window, which is important for providing context across turns and across agents. Picture an agent calling a skill, getting a response, adding tool calls and reasoning summaries—the limited context window quickly fills up. To avoid losing the important context as the agent continues running, we need a way to keep the key details and remove anything extraneous. Instead of requiring developers to design and maintain custom summarization or state-carrying systems, we added native compaction in the Responses API, designed to align with how the model behaves and how it's been trained.

Our latest models are trained to analyze prior conversation state and produce a compaction item that preserves key prior state in an encrypted token-efficient representation. After compaction, the next context window consists of this compaction item and high-value portions of the earlier window. This allows workflows to continue coherently across window boundaries, even in extended multi-step and tool-driven sessions. Codex relies on this mechanism to sustain long-running coding tasks and iterative tool execution without degrading quality.

Compaction is available either built-in on the server or through a standalone `/compact` endpoint. Server-side compaction lets you configure a threshold, and the system handles compaction timing automatically, eliminating the need for complex client-side logic. It allows a slightly larger effective input context window to tolerate small overages right before compaction, so requests near the limit can still be processed and compacted rather than rejected. As model training evolves, the native compaction solution evolves with it for every OpenAI model release.

Codex helped us build the compaction system while serving as an early user of it. When one Codex instance hit a compaction error, we'd spin up a second instance to investigate. The result was that Codex got a native, effective compaction system just by working on the problem. This ability for Codex to inspect and refine itself has become an especially interesting part of working at OpenAI. Most tools only require the user to learn how to use them; Codex learns alongside us.

Container context

Now let’s cover state and resources. The container is not only a place to run commands but also the working context for the model. Inside the container, the model can read files, query databases, and access external systems under network policy controls.

Ein Diagramm, das den Inhalt des Laufzeit-Containers zeigt: Dateien, Datenbanken, Fähigkeiten und ein durch Richtlinien gesteuertes Netzwerk

File systems

The first part of container context is the file system for uploading, organizing, and managing resources. We built container and file(wird in einem neuen Fenster geöffnet) APIs to give the model a map of available data and help it choose targeted file operations instead of performing broad, noisy scans.

A common anti-pattern is packing all input directly into prompt context. As inputs grow, overfilling the prompt becomes expensive and hard for the model to navigate. A better pattern is to stage resources in the container file system and let the model decide what to open, parse, or transform with shell commands. Much like humans, models work better with organized information.

Databases

The second part of container context is databases. In many cases, we suggest developers store structured data in databases as SQLite and query them. Instead of copying an entire spreadsheet into the prompt, for example, you can give the model a description of the tables—what columns exist and what they mean—and let it pull the rows it needs.

For example, if you ask, “Which products had declining sales this quarter?” the model can query just the relevant rows instead of scanning the whole spreadsheet. This is faster, cheaper, more scalable to larger datasets.

Netzwerkzugriff 

Der dritte Teil des Containerkontexts ist der Netzwerkzugriff, ein wesentlicher Bestandteil von Agenten-Workloads. Der Agenten-Workflow muss möglicherweise Live-Daten abrufen, externe APIs aufrufen oder Pakete installieren. Gleichzeitig kann es riskant sein, Containern uneingeschränkten Internetzugang zu gewähren: Dadurch können Informationen an externe Websites offengelegt werden, unbeabsichtigt sensible interne oder Drittanbietersysteme berührt werden, oder es wird schwieriger, sich gegen Zugangsdaten-Leaks und Datenexfiltration zu schützen.

Um diese Bedenken auszuräumen, ohne die Nützlichkeit der Agenten einzuschränken, haben wir gehostete Container entwickelt, die einen Sidecar-Egress-Proxy verwenden. Alle ausgehenden Netzwerkanfragen fließen durch eine zentralisierte Richtlinienebene, die Allowlists und Zugriffskontrollen durchsetzt und gleichzeitig den Datenverkehr beobachtbar hält. Für Zugangsdaten verwenden wir beim Datenausgang die Domain-bezogene Geheimniseinfügung. Das Modell und der Container sehen nur Platzhalter, während rohe Geheimniswerte außerhalb des für das Modell sichtbaren Kontexts bleiben und nur für genehmigte Ziele angewendet werden. Dadurch wird das Risiko von Datenlecks reduziert, während weiterhin authentifizierte externe Aufrufe möglich sind.

Diagramm des kontrollierten Netzwerkzugriffs über einen Egress-Proxy: Container-Setup

Agentenfähigkeiten

Shell-Befehle sind leistungsstark, aber viele Aufgaben wiederholen dieselben mehrstufigen Muster. Agenten müssen bei jedem Durchlauf den Workflow neu erlernen – neu planen, Befehle erneut ausgeben und Konventionen neu verinnerlichen – was zu inkonsistenten Ergebnissen und unnötigem Ausführungsaufwand führt. Agentenfähigkeiten(wird in einem neuen Fenster geöffnet) bündeln diese Muster zu wiederverwendbaren, kombinierbaren Bausteinen. Konkret ist eine Fähigkeit ein Ordnerpaket, das ‘SKILL.md(wird in einem neuen Fenster geöffnet)’ (mit Metadaten und Anweisungen) sowie alle unterstützenden Ressourcen, wie z. B. API-Spezifikationen und UI-Assets, enthält.

Diese Struktur lässt sich nahtlos auf die zuvor beschriebene Laufzeitarchitektur übertragen. Der Container stellt persistente Dateien und Ausführungskontext bereit, und das Shell-Tool bietet die Ausführungsschnittstelle. Wenn beides vorhanden ist, kann das Modell bei Bedarf Skill-Dateien mithilfe von Shell-Befehlen (`ls`, `cat` usw.) finden, Anweisungen interpretieren und Fähigkeiten-Skripte ausführen – alles in derselben Agenten-Schleife.

Wir stellen APIs(wird in einem neuen Fenster geöffnet) bereit, um Fähigkeiten auf der OpenAI-Plattform zu verwalten. Entwickler:innen können Fähigkeiten-Ordner als versionierte Pakete (Bundles) hochladen und speichern, die später über die Fähigkeits-ID abgerufen werden können. Bevor der Prompt an das Modell gesendet wird, lädt die Responses API die Fähigkeit und schließt sie in den Modellkontext ein. Diese Sequenz ist deterministisch:

  1. Metadaten der Fähigkeit abrufen, einschließlich Name und Beschreibung.
  2. Das Fähigkeits-Paket abrufen, es in den Container kopieren und es entpacken.
  3. Den Modellkontext mit den Fähigkeits-Metadaten und dem Containerpfad aktualisieren.

Bei der Entscheidung, ob eine Fähigkeit relevant ist, durchläuft das Modell schrittweise deren Anweisungen und führt deren Skripte über Shell-Befehle im Container aus.

Diagramm der Pipeline zum Laden von Fähigkeiten: Registry, Bundle (Paket), Runtime

Wie Agenten erstellt werden

Um alle Teile zusammenzufügen: Die Responses API bietet Orchestrierung, das Shell-Tool bietet ausführbare Aktionen, der gehostete Container bietet einen persistenten Laufzeitkontext, Fähigkeiten liefern Ebenen wiederverwendbarer Workflow-Logik, und Compaction ermöglicht es einem Agenten, über einen längeren Zeitraum mit dem benötigten Kontext zu laufen.

Mit diesen Primitiven kann sich ein einzelner Prompt zu einem End-to-End-Workflow erweitern: die richtige Fähigkeit finden, Daten abrufen, sie in einen lokalen strukturierten Zustand transformieren, sie effizient abfragen und dauerhafte Artefakte erzeugen. 

Das Diagramm unten zeigt, wie dieses System funktioniert, um aus Live-Daten eine Tabelle zu erstellen.

Diagramm des Anfragelebenszyklus: von einem Prompt zu dauerhaften Artefakten, Finden von Fähigkeiten

Die Responses API orchestriert eine agentische Aufgabe

Erstelle deinen eigenen Agenten

Ein ausführliches Beispiel dafür, wie du das Shell-Tool und die Computerumgebung für End-to-End-Workflows kombinierst, findest du in unserem Entwickler-Blogbeitrag(wird in einem neuen Fenster geöffnet) und Cookbook(wird in einem neuen Fenster geöffnet), die Schritt für Schritt zeigen, wie du eine Fähigkeit paketierst und über die Responses API ausführst.

Wir sind gespannt, was Entwickler:innen mit diesem Satz an Grundbausteinen entwickeln werden. Sprachmodelle sollen mehr leisten als nur Text, Bilder und Audio zu generieren. Wir werden unsere Plattform stetig weiterentwickeln, um komplexe Aufgaben aus der realen Welt in großem Maßstab besser bewältigen zu können.

Autor

Bo Xu, Danny Zhang und Rohit Arunachalam