From mannequin to agent: Equipping the Responses API with a pc atmosphere

April 17, 2026


We’re at present in a shift from utilizing fashions, which excel at specific duties, to utilizing brokers able to dealing with advanced workflows. By prompting fashions, you’ll be able to solely entry educated intelligence. Nevertheless, giving the mannequin a pc atmosphere can obtain a a lot wider vary of use circumstances, like operating companies, requesting information from APIs, or producing extra helpful artifacts like spreadsheets or reviews.

A couple of sensible issues emerge while you attempt to construct brokers: the place to place intermediate information, keep away from pasting massive tables right into a immediate, give the workflow community entry with out making a safety headache, and deal with timeouts and retries with out constructing a workflow system your self.

As a substitute of placing it on builders to construct their very own execution environments, we constructed the required elements to equip the Responses API(opens in a brand new window) with a pc atmosphere to reliably execute real-world duties.

OpenAI’s Responses API, along with the shell software and a hosted container workspace, is designed to deal with these sensible issues. The mannequin proposes steps and instructions; the platform runs them in an remoted atmosphere with a filesystem for inputs and outputs, non-compulsory structured storage (like SQLite), and restricted community entry. 

On this put up, we’ll break down how we constructed a pc atmosphere for brokers and share some early classes on use it for quicker, extra repeatable, and safer manufacturing workflows.

agent workflow begins with a decent execution loop: the mannequin proposes an motion like studying information or fetching information with API, the platform runs it, and the consequence feeds into the subsequent step. We’ll begin with the shell software—the only solution to see this loop in motion—after which cowl the container workspace, networking, reusable abilities, and context compaction.

To know the shell software, it’s first helpful to grasp how a language mannequin makes use of instruments usually: to do issues like name a operate or work together with a pc. Throughout coaching, a mannequin is proven examples of how instruments are used and the ensuing results, step-by-step. This helps the mannequin study to determine when to make use of a software and use it. After we say “utilizing a software”, we imply the mannequin really solely proposes a software name. It will probably’t execute the decision by itself.

The shell tool is "just another tool" with diagram

The shell software makes the mannequin dramatically extra highly effective: it interacts with a pc by way of the command line to hold out a variety of duties, from looking for textual content to sending API requests in your laptop. Constructed on acquainted Unix tooling, our shell software can do something you’d count on, with utilities like grep, curl, and awk obtainable out of the field.

In comparison with our present code interpreter, which solely executes Python, the shell software permits a a lot wider vary of use circumstances, like operating Go or Java applications or beginning a NodeJS server. This flexibility lets the mannequin fulfill advanced agentic duties.

Orchestrating the agent loop

By itself, a mannequin can solely suggest shell instructions, however how are these instructions executed? We’d like an orchestrator to get mannequin output, invoke instruments, and cross the software response again to the mannequin in a loop, till the duty is full.

The Responses API is how builders work together with OpenAI fashions. When used with customized instruments, the Responses API yields management again to the shopper, and the shopper requires its personal harness for operating the instruments. Nevertheless, this API may orchestrate between the mannequin and hosted instruments out of the field. 

When the Responses API receives a immediate, it assembles mannequin context: consumer immediate, prior dialog state, and power directions. For shell execution to work, the immediate should point out utilizing the shell software and the chosen mannequin have to be educated to suggest shell instructions—fashions GPT‑5.2 and later are educated for this. With all of this context, the mannequin then decides the subsequent motion. If it chooses shell execution, it returns a number of shell instructions to Responses API service. The API service forwards these instructions to the container runtime, streams again shell output, and feeds it to the mannequin within the subsequent request’s context. The mannequin can then examine the outcomes, difficulty follow-up instructions, or produce a ultimate reply. The Responses API repeats this loop till the mannequin returns a completion with out further shell instructions.

Agent loop diagram: Responses API orchestrates model and shell execution 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 mannequin in close to actual time so the mannequin can determine whether or not to attend for extra output, run one other command, or transfer on to a ultimate response.

Streaming shell command execution output

The Responses API streams shell command output

The mannequin can suggest a number of shell instructions in a single step, and the Responses API can execute them concurrently utilizing separate container periods. Every session streams output independently, and the API multiplexes these streams again into structured software outputs as context. In different phrases, the agent loop can parallelize work, reminiscent of looking out information, fetching information, and validating intermediate outcomes.

Responses API multiplexes command execution sessions

When the command entails file operations or information processing, shell output can turn into very massive and eat context budgets with out including helpful alerts. To manage this, the mannequin specifies an output cap per command. The Responses API enforces that cap and returns a bounded consequence that preserves each the start and finish of the output, whereas marking omitted content material. For instance, you would possibly certain the output to 1,000 characters, with preserved starting and finish:

textual content at the start ... 1000 chars truncated ... textual content on the finish

Collectively, concurrent execution and bounded output make the agent loop each quick and context-efficient so the mannequin can preserve reasoning over related outcomes as an alternative of getting overwhelmed by uncooked terminal logs.

When the context window will get full: compaction

One potential difficulty with agent loops is that duties can run for a very long time. Lengthy-running duties fill the context window, which is necessary for offering context throughout turns and throughout brokers. Image an agent calling a ability, getting a response, including software calls and reasoning summaries—the restricted context window shortly fills up. To keep away from dropping the necessary context because the agent continues operating, we want a solution to preserve the important thing particulars and take away something extraneous. As a substitute of requiring builders to design and preserve customized summarization or state-carrying programs, we added native compaction within the Responses API, designed to align with how the mannequin behaves and the way it’s been educated.

Our newest fashions are educated to research prior dialog state and produce a compaction merchandise that preserves key prior state in an encrypted token-efficient illustration. After compaction, the subsequent context window consists of this compaction merchandise and high-value parts of the sooner window. This permits workflows to proceed coherently throughout window boundaries, even in prolonged multi-step and tool-driven periods. Codex depends on this mechanism to maintain long-running coding duties and iterative software execution with out degrading high quality.

Compaction is out there both built-in on the server or by way of a standalone `/compact` endpoint. Server-side compaction permits you to configure a threshold, and the system handles compaction timing mechanically, eliminating the necessity for advanced client-side logic. It permits a barely bigger efficient enter context window to tolerate small overages proper earlier than compaction, so requests close to the restrict can nonetheless be processed and compacted quite than rejected. As mannequin coaching evolves, the native compaction resolution evolves with it for each OpenAI mannequin launch.

Codex helped us construct the compaction system whereas serving as an early consumer of it. When one Codex occasion hit a compaction error, we would spin up a second occasion to research. The consequence was that Codex obtained a local, efficient compaction system simply by engaged on the issue. This skill for Codex to examine and refine itself has turn into an particularly attention-grabbing a part of working at OpenAI. Most instruments solely require the consumer to discover ways to use them; Codex learns alongside us.

Now let’s cowl state and assets. The container will not be solely a spot to run instructions but additionally the working context for the mannequin. Contained in the container, the mannequin can learn information, question databases, and entry exterior programs underneath community coverage controls.

A diagram that shows inside the runtime container: Files, databases, skills, and a policy-controlled network

The primary a part of container context is the file system for importing, organizing, and managing assets. We constructed container and file(opens in a brand new window) APIs to present the mannequin a map of obtainable information and assist it select focused file operations as an alternative of performing broad, noisy scans.

A typical anti-pattern is packing all enter straight into immediate context. As inputs develop, overfilling the immediate turns into costly and onerous for the mannequin to navigate. A greater sample is to stage assets within the container file system and let the mannequin determine what to open, parse, or rework with shell instructions. Very like people, fashions work higher with organized data.

The second a part of container context is databases. In lots of circumstances, we propose builders retailer structured information in databases as SQLite and question them. As a substitute of copying a complete spreadsheet into the immediate, for instance, you may give the mannequin an outline of the tables—what columns exist and what they imply—and let it pull the rows it wants.

For instance, if you happen to ask, “Which merchandise had declining gross sales this quarter?” the mannequin can question simply the related rows as an alternative of scanning the entire spreadsheet. That is quicker, cheaper, extra scalable to bigger datasets.

The third a part of the container context is community entry, a necessary a part of agent workloads. Agent workflow might must fetch reside information, name exterior APIs, or set up packages. On the identical time, giving containers unrestricted web entry could be dangerous: it may possibly expose data to exterior web sites, unintentionally contact delicate inside or third-party programs, or make credential leaks and information exfiltration more durable to protect towards.

To deal with these issues with out limiting brokers’ usefulness, we constructed hosted containers to make use of a sidecar egress proxy. All outbound community requests move by way of a centralized coverage layer that enforces allowlists and entry controls whereas holding visitors observable. For credentials, we use domain-scoped secret injection at egress. The mannequin and container solely see placeholders, whereas uncooked secret values keep outdoors model-visible context and solely get utilized for authorised locations. This reduces the chance of leakage whereas nonetheless enabling authenticated exterior calls.

Diagram of controlled network access via access egress proxy: container setup

Shell instructions are highly effective, however many duties repeat the identical multi-step patterns. Brokers should rediscover the workflow every run—replanning, reissuing instructions, and relearning conventions—resulting in inconsistent outcomes and wasted execution. Agent abilities(opens in a brand new window) package deal these patterns into reusable, composable constructing blocks. Concretely, a ability is a folder bundle that features ‘SKILL.md(opens in a brand new window)’ (containing metadata and directions) plus any supporting assets, reminiscent of API specs and UI belongings.

This construction maps naturally to the runtime structure we described earlier. The container supplies persistent information and execution context, and the shell software supplies the execution interface. With each in place, the mannequin can uncover ability information utilizing shell instructions (`ls`, `cat`, and so on.) when it must, interpret directions, and run ability scripts all in the identical agent loop.

We offer APIs(opens in a brand new window) to handle abilities within the OpenAI platform. Builders add and retailer ability folders as versioned bundles, which may later be retrieved by ability ID. Earlier than sending the immediate to the mannequin, the Responses API masses the ability and consists of it in mannequin context. This sequence is deterministic:

  1. Fetch ability metadata, together with identify and outline.
  2. Fetch the ability bundle, copy it into the container, and unpack it.
  3. Replace mannequin context with ability metadata and the container path.

When deciding whether or not a ability is related, the mannequin progressively explores its directions, and executes its scripts by way of shell instructions within the container.

Skill loading pipeline diagram: registry, bundle, runtime

To place all of the items collectively: the Responses API supplies orchestration, the shell software supplies executable actions, the hosted container supplies persistent runtime context, abilities layer reusable workflow logic, and compaction permits an agent to run for a very long time with the context it wants.

With these primitives, a single immediate can broaden into an end-to-end workflow: uncover the best ability, fetch information, rework it into native structured state, question it effectively, and generate sturdy artifacts. 

The diagram under exhibits how this technique works for making a spreadsheet from reside information.

Diagram of request lifecycle: from one prompt to durable artifacts, skill discovery

The Responses API orchestrates an agentic process

We’re excited to see what builders construct with this set of primitives. Language fashions are supposed to do greater than producing textual content, photos, and audio–we’ll proceed to evolve our platform to turn into extra succesful in dealing with advanced, real-world duties at scale.





Source link

Article Tags:
· · · · · ·
Article Categories:
Water Purifiers & Accessories

Leave a Reply

Your email address will not be published. Required fields are marked *