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

seo 1 .png


We are lately in a shift from the usage of fashions, which excel at explicit duties, to the usage of brokers in a position to dealing with complicated workflows. Through prompting fashions, you’ll be able to simplest get admission to educated intelligence. Alternatively, giving the mannequin a pc atmosphere can succeed in a wider vary of use circumstances, like working services and products, soliciting for knowledge from APIs, or producing extra helpful artifacts like spreadsheets or experiences.

A couple of sensible issues emerge while you attempt to construct brokers: the place to place intermediate information, the way to steer clear of pasting huge tables right into a urged, the way to give the workflow community get admission to with out developing a safety headache, and the way to maintain timeouts and retries with out development a workflow gadget your self.

As an alternative of striking it on builders to construct their very own execution environments, we constructed the essential parts 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 handle those 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 garage (like SQLite), and limited community get admission to. 

On this put up, we’ll damage down how we constructed a pc atmosphere for brokers and proportion some early courses on the way to use it for sooner, extra repeatable, and more secure manufacturing workflows.

A excellent agent workflow begins with a good execution loop: the mannequin proposes an motion like studying information or fetching knowledge with API, the platform runs it, and the end result feeds into your next step. We’ll get started with the shell software—the most simple method to see this loop in motion—after which duvet the container workspace, networking, reusable talents, and context compaction.

To grasp the shell software, it’s first helpful to know the way a language mannequin makes use of equipment usually: to do such things as name a serve as or engage with a pc. Throughout coaching, a mannequin is proven examples of ways equipment are used and the ensuing results, step-by-step. This is helping the mannequin learn how to make a decision when to make use of a device and the way to use it. After we say “the usage of a device”, we imply the mannequin if truth be told simplest proposes a device name. It can not execute the decision by itself.

The shell tool is "just another tool" with diagram

The shell software makes the mannequin dramatically extra tough: it interacts with a pc in the course 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 anything else you would be expecting, with utilities like grep, curl, and awk to be had out of the field.

In comparison to our current code interpreter, which simplest executes Python, the shell software permits a wider vary of use circumstances, like working Move or Java systems or beginning a NodeJS server. This adaptability shall we the mannequin satisfy complicated agentic duties.

Orchestrating the agent loop

By itself, a mannequin can simplest suggest shell instructions, however how are those instructions carried out? We’d like an orchestrator to get mannequin output, invoke equipment, and cross the software reaction again to the mannequin in a loop, till the duty is entire.

The Responses API is how builders engage with OpenAI fashions. When used with customized equipment, the Responses API yields keep watch over again to the buyer, and the buyer calls for its personal harness for working the equipment. Alternatively, this API too can orchestrate between the mannequin and hosted equipment out of the field. 

When the Responses API receives a urged, it assembles mannequin context: person urged, prior dialog state, and gear directions. For shell execution to paintings, the urged should point out the usage of the shell software and the chosen mannequin should be educated to suggest shell instructions—fashions GPT‑5.2 and later are educated for this. With all of this context, the mannequin then makes a decision the following motion. If it chooses shell execution, it returns a number of shell instructions to Responses API provider. The API provider forwards the ones 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 check out the consequences, factor follow-up instructions, or produce a last solution. The Responses API repeats this loop till the mannequin returns a crowning glory 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 provider. As output is produced, the API relays it to the mannequin in close to genuine time so the mannequin can make a decision whether or not to watch for extra output, run any other command, or transfer directly to a last reaction.

Streaming shell command execution output

The Responses API streams shell command output

The mannequin can suggest more than one shell instructions in a single step, and the Responses API can execute them similtaneously the usage of separate container classes. Every consultation streams output independently, and the API multiplexes the ones streams again into structured software outputs as context. In different phrases, the agent loop can parallelize paintings, similar to looking information, fetching knowledge, and validating intermediate effects.

Responses API multiplexes command execution sessions

When the command comes to document operations or knowledge processing, shell output can develop into very huge and eat context budgets with out including helpful indicators. To keep watch over this, the mannequin specifies an output cap consistent with command. The Responses API enforces that cap and returns a bounded end result that preserves each the start and finish of the output, whilst marking neglected content material. As an example, you may certain the output to one,000 characters, with preserved starting and finish:

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

In combination, concurrent execution and bounded output make the agent loop each speedy and context-efficient so the mannequin can stay reasoning over related effects as an alternative of having crushed by means of uncooked terminal logs.

When the context window will get complete: compaction

One attainable factor 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 reaction, including software calls and reasoning summaries—the restricted context window briefly fills up. To steer clear of shedding the necessary context because the agent continues working, we’d like a method to stay the important thing main points and take away anything else extraneous. As an alternative of requiring builders to design and deal with customized summarization or state-carrying techniques, we added local compaction within the Responses API, designed to align with how the mannequin behaves and the way it is been educated.

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

Compaction is to be had both integrated at the server or via a standalone `/compact` endpoint. Server-side compaction means that you can configure a threshold, and the gadget handles compaction timing mechanically, getting rid of the will for complicated client-side common sense. It permits a reasonably better efficient enter context window to tolerate small overages proper earlier than compaction, so requests close to the prohibit can nonetheless be processed and compacted slightly than rejected. As mannequin coaching evolves, the local compaction answer evolves with it for each and every OpenAI mannequin unlock.

Codex helped us construct the compaction gadget whilst serving as an early person of it. When one Codex example hit a compaction error, we would spin up a 2d example to analyze. The outcome used to be that Codex were given a local, efficient compaction gadget simply by operating at the downside. This talent for Codex to check out and refine itself has develop into an extremely attention-grabbing a part of operating at OpenAI. Maximum equipment simplest require the person to discover ways to use them; Codex learns along us.

Now let’s duvet state and assets. The container is not just a spot to run instructions but in addition the operating context for the mannequin. Throughout the container, the mannequin can learn information, question databases, and get admission to exterior techniques 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 document gadget for importing, organizing, and managing assets. We constructed container and document(opens in a brand new window) APIs to provide the mannequin a map of to be had knowledge and lend a hand it make a selection centered document operations as an alternative of acting large, noisy scans.

A commonplace anti-pattern is packing all enter at once into urged context. As inputs develop, overfilling the urged turns into pricey and tough for the mannequin to navigate. A greater sample is to level assets within the container document gadget and let the mannequin make a decision what to open, parse, or grow to be with shell instructions. Similar to people, fashions paintings higher with arranged knowledge.

The second one a part of container context is databases. In lots of circumstances, we recommend builders retailer structured knowledge in databases as SQLite and question them. As an alternative of copying a whole spreadsheet into the urged, as an example, you’ll be able to give the mannequin an outline of the tables—what columns exist and what they imply—and let it pull the rows it wishes.

As an example, for those who 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 sooner, inexpensive, extra scalable to bigger datasets.

The 1/3 a part of the container context is community get admission to, an very important a part of agent workloads. Agent workflow would possibly wish to fetch are living knowledge, name exterior APIs, or set up applications. On the similar time, giving bins unrestricted web get admission to can also be dangerous: it may well disclose knowledge to exterior web pages, by chance contact delicate inside or third-party techniques, or make credential leaks and knowledge exfiltration tougher to protect in opposition to.

To handle those considerations with out restricting brokers’ usefulness, we constructed hosted bins to make use of a sidecar egress proxy. All outbound community requests waft via a centralized coverage layer that enforces allowlists and get admission to controls whilst retaining site visitors observable. For credentials, we use domain-scoped secret injection at egress. The mannequin and container simplest see placeholders, whilst uncooked secret values keep out of doors model-visible context and simplest get carried out for licensed locations. This reduces the chance of leakage whilst nonetheless enabling authenticated exterior calls.

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

Shell instructions are tough, however many duties repeat the similar multi-step patterns. Brokers need to rediscover the workflow every run—replanning, reissuing instructions, and relearning conventions—resulting in inconsistent effects and wasted execution. Agent talents(opens in a brand new window) bundle the ones patterns into reusable, composable development blocks. Concretely, a ability is a folder package that incorporates ‘SKILL.md(opens in a brand new window)’ (containing metadata and directions) plus any supporting assets, similar to API specifications and UI belongings.

This construction maps naturally to the runtime structure we described previous. The container supplies continual information and execution context, and the shell software supplies the execution interface. With each in position, the mannequin can uncover ability information the usage of shell instructions (`ls`, `cat`, and so forth.) when it must, interpret directions, and run ability scripts all in the similar agent loop.

We offer APIs(opens in a brand new window) to control talents within the OpenAI platform. Builders add and retailer ability folders as versioned bundles, which is able to later be retrieved by means of ability ID. Prior to sending the urged to the mannequin, the Responses API rather a lot the ability and comprises it in mannequin context. This series is deterministic:

  1. Fetch ability metadata, together with title and outline.
  2. Fetch the ability package, replica it into the container, and unpack it.
  3. Replace mannequin context with ability metadata and the container trail.

When deciding whether or not a ability is related, the mannequin gradually explores its directions, and executes its scripts via shell instructions within the container.

Skill loading pipeline diagram: registry, bundle, runtime

To position all of the items in combination: the Responses API supplies orchestration, the shell software supplies executable movements, the hosted container supplies continual runtime context, talents layer reusable workflow common sense, and compaction permits an agent to run for a very long time with the context it wishes.

With those primitives, a unmarried urged can extend into an end-to-end workflow: uncover the correct ability, fetch knowledge, grow to be it into native structured state, question it successfully, and generate sturdy artifacts. 

The diagram under displays how the program works for making a spreadsheet from are living knowledge.

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

The Responses API orchestrates an agentic activity

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




Leave a Comment

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