From model to agent: Equipping the Responses API with a computer environment
By Bo Xu, Danny Zhang, and Rohit Arunachalam
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(magbubukas sa bagong window) 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.
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.
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.
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.
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.
Sini-stream ng Responses API ang output shell command
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.
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.
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.
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.
The first part of container context is the file system for uploading, organizing, and managing resources. We built container and file(magbubukas sa bagong window) 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.
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.
Ang ikatlong bahagi ng konteksto ng container ay ang access sa network, isang mahalagang bahagi ng mga workload ng agent. Maaaring kailanganin ng workflow ng agent na kumuha ng live na data, tumawag sa mga panlabas na API, o mag-install ng mga package. Gayundin, maaaring maging mapanganib ang pagbibigay sa mga container ng walang limitasyong access sa internet: maaari nitong ilantad ang impormasyon sa mga panlabas na website, hindi sadyang makipag-ugnayan sa mga sensitibong panloob o third-party na sistema, o gawing mas mahirap bantayan laban sa pagsisiwalat ng kredensyal at pag-exfiltrate ng data.
Upang matugunan ang mga alalahaning ito nang hindi nililimitahan ang pagiging kapaki-pakinabang ng mga agent, bumuo kami ng mga naka-host na container para gumamit ng sidecar egress proxy. Ang lahat ng outbound na kahilingan sa network ay dumadaloy sa isang sentralisadong layer ng patakaran na nagpapatupad ng mga allowlist at mga kontrol sa pag-access habang pinananatiling nakikita ang trapiko. Para sa mga kredensyal, gumagamit kami ng domain-scoped secret injection sa egress. Mga placeholder lang ang nakikita ng mga modelo at container, habang ang mga raw na secret value ay nananatili sa labas ng kontekstong nakikita ng modelo at inilalapat lamang para sa mga naaprubahang destinasyon. Binabawasan nito ang panganib ng pagsisiwalat habang nagbibigay-daan pa rin sa awtentikadong mga panlabas na tawag.
Makapangyarihan ang mga shell command, pero maraming gawain ang nag-uulit ng parehong mga pattern na may maramihang hakbang. Kailangang muling tuklasin ng mga agent ang workflow sa bawat pagpapatakbo—muling pagpaplano, muling pag-isyu ng mga command, at muling pagkatuto ng mga kombensyon—na humahantong sa hindi pare-parehong mga resulta at nasasayang na pagpapatupad. Mga skill ng agent(magbubukas sa bagong window) ipina-package ang mga pattern na iyon sa mga muling magagamit at composable na building block. Tiyak, ang isang skill ay bundle ng folder na kinabibilangan ng ‘SKILL.md(magbubukas sa bagong window)’ (naglalaman ng metadata at mga tagubilin) kasama ang anumang mga sumusuportang mapagkukunan, gaya ng mga spec ng AI at mga UI asset.
Ang istrakturang ito ay natural na tumutugma sa arkitektura ng runtime na inilarawan namin kanina. Nagbibigay ang container ng mga persistent na file at konteksto ng pagpapatupad, at ang shell tool ay nagbibigay ng interface sa pagpapatupad. Kapag pareho nang naka-set up, pwedeng matuklasan ng modelo ang mga skill file gamit ang mga shell command (`ls`, `cat`, etc.) kapag kailangan nito, bigyang-kahulugan ang mga tagubilin, at patakbuhin ang mga skill script sa iisang agent loop.
Nagbibigay kami ng mga API(magbubukas sa bagong window) para pamahalaan ang mga skill sa platform ng OpenAI. Nag-a-upload at nag-iimbak ang mga developer ng mga folder ng skill bilang mga nakabersyong bundle, na maaaring kunin sa ibang pagkakataon gamit ang skill ID. Bago ipadala ang prompt sa modelo, nilo-load ng Responses API ang skill at isinasama ito sa konteksto ng modelo. Ang pagkakasunod-sunod na ito ay kailangang mangyari:
- Kunin ang metadata ng kasanayan, kabilang ang pangalan at paglalarawan.
- Kunin ang skill bundle, kopyahin ito sa container, at i-unpack ito.
- I-update ang konteksto ng modelo gamit ang metadata ng skill at ang container path.
Kapag nagpapasya kung may kaugnayan ang isang skill, unti-unting sinisiyasat ng modelo ang mga tagubilin nito, at isinasagawa ang mga script nito sa pamamagitan ng mga shell command sa container.
Para mabuo ang mga bahagi: ang Responses API ay nagbibigay ng plano, ang shell tool ay nagbibigay ng mga naipapatupad na aksyon, ang naka-host na container ay nagbibigay ng tuloy-tuloy na konteksto ng runtime, ang skills ay naglalagay ng muling magagamit na lohika ng daloy ng trabaho sa mga layer, at ang compaction ay nagbibigay-daan sa agent na tumakbo nang matagal gamit ang kontekstong kailangan nito.
Gamit ang mga primitive na ito, ang iisang prompt ay maaaring lumawak tungo sa end-to-end na daloy ng trabaho: tuklasin ang tamang skill, kumuha ng data, i-transform ito sa lokal na structured state, i-query ito nang mahusay, at bumuo ng mga matitibay na artifact.
Ipinapakita ng diagram sa ibaba kung paano gumagana ang system na ito para gumawa ng spreadsheet mula sa live na data.
Nagpaplano ang Responses API ng agentic na gawain
Para sa mas malalim na halimbawa ng pagsasama ng shell tool at computer environment para sa end-to-end na mga daloy ng trabaho, tingnan ang aming post sa developer blog(magbubukas sa bagong window) at cookbook(magbubukas sa bagong window) na gumagabay sa pag-package ng skill at pag-execute nito sa pamamagitan ng Responses API.
Nasasabik kaming makita kung ano ang bubuuin ng mga developer gamit ang hanay na ito ng mga primitive. Ang mga modelo ng wika ay inaasahang makakagawa ng higit pa kaysa sa pagbuo ng teksto, mga larawan, at audio–patuloy naming pauunlarin ang aming platform upang maging mas may kakayahan sa paghawak ng mga kumplikado, totoong gawain sa mundo sa malakihang saklaw.


