---
title: "OpenAI Agents SDK in production (2026) — Cadenya"
url: "https://cadenya.com/other-content/openai-agents-sdk-in-production"
description: "Running the OpenAI Agents SDK in production: needs_approval and RunState resume, sessions, the Temporal and DBOS integrations, and versions."
---

Running the OpenAI Agents SDK in production means hosting its agent loop yourself: `Runner.run` calls the model, runs tool calls, and follows handoffs inside your Python or TypeScript process. For human in the loop, a tool with `needs_approval` (`needsApproval` in TypeScript) pauses the run, and you serialize its `RunState` to resume after a person decides, while durable execution comes from the Temporal, DBOS, Restate or Dapr integrations the SDK’s docs list.

So run the SDK on its own when a turn fits in one request and a session store holds the conversation. Add Temporal or DBOS when a run has to survive a crash or a deploy between steps, and you’re ready to operate that engine too. And if you’d rather not host the loop at all, Cadenya is a hosted agent loop with approvals, conversation state, resume and model swap built in: your app creates an objective, and Cadenya calls the model and your tool sets. A coding agent can set it up with no account, in a temporary workspace you claim later. [What it offers](#what-does-cadenya-offer-that-the-openai-agents-sdk-doesnt) is at the end.

Every price and limit below comes from each vendor’s own pages, checked on November 11, 2026.

## Where the SDK runs in production

The SDK is an MIT-licensed library, so hosting it means picking where its loop runs:

|  | Agents SDK on its own | Agents SDK with Temporal | Agents SDK with DBOS | Agents SDK with Restate | Cadenya |
| --- | --- | --- | --- | --- | --- |
| Where the agent loop runs | Your process, through Runner.run or run() | A Workflow on your Workers. Each model call runs as an Activity | A @DBOS.workflow() in your app, through DBOSRunner.run() | Your services, with Restate’s single-binary runtime | Hosted for you. Your app creates an objective and streams its events |
| Human in the loop | needs_approval on a tool, then approve or reject on a serialized RunState | on_approval_request waits on a Signal or an Update | Human-in-the-loop workflows, per the SDK’s docs | Human approval, per the SDK’s docs | Mark a tool as needing approval, then approve or deny it with a memo the agent reads |
| Conversation state | A session (SQLite, SQLAlchemy, Redis, MongoDB, Dapr) or OpenAI’s Conversations API | Workflow state, rebuilt from result.to_input_list() each turn | A SQLite or Postgres database | Session management in Restate | A durable event log per objective |
| What you run | Your app and a session store | A Temporal Service, your Workers and your app | Your app and SQLite or Postgres | The Restate runtime and your services | Your app, calling an HTTP API |
| Package | openai-agents 0.24.0, @openai/agents 0.21.0 | temporalio-openai-agents 1.1.0, @temporalio/openai-agents 1.24.0 | dbos-openai-agents 0.3.0 | Restate’s SDK | Python, TypeScript, Ruby and Go SDKs at 1.9.0, Apache-2.0 |

The SDK’s docs also list Dapr, through Diagrid, for agents “that automatically recover from failures.” For the engines on their own, see [Temporal for AI agents](/other-content/temporal-for-ai-agents) and [DBOS for AI agents](/other-content/dbos-for-ai-agents).

## Human in the loop: needs\_approval, interruptions and RunState

The docs sum up the flow: “Tools declare when they need approval, run results surface pending approvals as interruptions, and `RunState` lets you serialize paused runs and resume them after decisions are made.”

`needs_approval` takes `True` or an async function that decides per call. It works on function tools, `Agent.as_tool`, `ShellTool` and `ApplyPatchTool`, and local MCP servers take `require_approval` instead. Here’s the Python flow, adapted from the docs, split across two requests:

```
from agents import Agent, Runner, RunState
from agents.decorators import tool

@tool(needs_approval=True)
async def cancel_order(order_id: int) -> str:
    return f"Cancelled order {order_id}"

agent = Agent(
    name="Support agent",
    instructions="Handle tickets and ask for approval when needed.",
    tools=[cancel_order],
)

# Request 1: the run pauses on the tool call
result = await Runner.run(agent, "Cancel order 1042")
if result.interruptions:
    saved = result.to_state().to_string()  # store it in your database

# Request 2, maybe in another process: a reviewer decides
state = await RunState.from_string(agent, saved)
for item in state.get_interruptions():
    state.approve(item)  # or state.reject(item, rejection_message="...")
result = await Runner.run(agent, state)
```

The TypeScript SDK has the same shape, with `needsApproval`, `result.state.toString()` and `RunState.fromString`:

```
import { Agent, run, tool, RunState } from '@openai/agents';
import { z } from 'zod';

const cancelOrder = tool({
  name: 'cancelOrder',
  description: 'Cancel order',
  parameters: z.object({ orderId: z.number() }),
  needsApproval: true,
  execute: async ({ orderId }) => `Cancelled order ${orderId}`,
});

const agent = new Agent({ name: 'Support agent', tools: [cancelOrder] });

const first = await run(agent, 'Cancel order 1042');
const saved = first.state.toString(); // store it server side

const state = await RunState.fromString(agent, saved);
for (const interruption of state.getInterruptions()) {
  state.approve(interruption); // or state.reject(interruption, { message: '...' })
}
const result = await run(agent, state);
```

Three rules from the docs decide how you host this:

1.  **Keep the snapshot on your server.** `RunState.from_string()` doesn’t “authenticate the snapshot or the person submitting it,” so the browser gets only opaque IDs, and your backend takes the reviewer’s identity from its own session.
2.  **Approval isn’t exactly once.** “Approval permits a tool call to execute; it does not guarantee exactly-once execution,” so give each side effect a stable idempotency key. [Retries and idempotency for agent tool calls](/other-content/retries-and-idempotency-for-agent-tool-calls) covers the pattern.
3.  **Version what you store.** The docs suggest you “store a version marker for your agent definitions or SDK alongside the serialized state,” since the agent graph you resume with has to match.

## Sessions and conversation state

The SDK gives you four ways to carry a conversation into the next turn: `result.to_input_list()` in your app, a `session`, OpenAI’s `conversation_id`, or `previous_response_id`. The docs say to “pick one persistence strategy per conversation.”

For production, the docs point to `SQLAlchemySession` for “Production apps with existing databases” and `RedisSession` for “Shared memory across workers/services.” `OpenAIResponsesCompactionSession` wraps another session and compacts long histories. When you resume a paused run, pass the same session again.

Every backend and install line is on [OpenAI Agents SDK sessions](/other-content/openai-agents-sdk-sessions).

## Temporal OpenAI Agents SDK integration and other durable execution

**The Temporal OpenAI Agents SDK integration moved out of the Temporal Python SDK.** Temporal’s docs say “Version 1.0.0 moves the integration out of the Temporal Python SDK,” so you install `temporalio-openai-agents` (1.1.0 on PyPI, from October 1, 2026, Python 3.10 or later) and import `temporalio.openai_agents` instead of `temporalio.contrib.openai_agents`. The OpenAI docs still link the old contrib path.

Your Workflow stays ordinary Agents SDK code: “The plugin redirects `Runner.run` so that each model call becomes an Activity.” Two details catch people out. “`SQLiteSession` is not supported” inside Workflows, so you keep history in Workflow state. And approvals go through a `HostedMCPTool` callback that “can wait on a Signal or Update to get the answer from outside.”

In TypeScript, the package is `@temporalio/openai-agents` (1.24.0 on npm), and you call `new TemporalOpenAIRunner().run(agent, prompt)` in the Workflow. It “supports a single minor version of the OpenAI Agents SDK packages,” so upgrade both together.

DBOS takes the library route. `DBOSRunner.run()` is “a drop-in replacement for `Runner.run()` with the same arguments,” called from a DBOS workflow:

```
from agents import Agent, function_tool
from dbos import DBOS
from dbos_openai_agents import DBOSRunner

@function_tool
@DBOS.step()
async def get_weather(city: str) -> str:
    return f"Sunny in {city}"

agent = Agent(name="weather", tools=[get_weather])

@DBOS.workflow()
async def run_agent(user_input: str) -> str:
    result = await DBOSRunner.run(agent, user_input)
    return str(result.final_output)
```

Restate describes its integration as “fault-tolerant agent execution with automatic retries and durable state.”

## Other model providers: LiteLLM, Any-LLM and the AI SDK adapter

The Python SDK has three built-in ways to reach a non-OpenAI model. `set_default_openai_client` points every agent at an OpenAI-compatible endpoint, a `ModelProvider` applies to one run, and `Agent.model` sets a provider per agent. `RunConfig.model` overrides the model for a whole run.

For wider coverage, install `openai-agents[litellm]` and use `litellm/...` model names, or `openai-agents[any-llm]` with `any-llm/...` names. The TypeScript SDK uses Vercel’s AI SDK through `@openai/agents-extensions`:

```
import { Agent, run } from '@openai/agents';
import { openai } from '@ai-sdk/openai';
import { aisdk } from '@openai/agents-extensions/ai-sdk';

const model = aisdk(openai('gpt-5.4'));

const agent = new Agent({
  name: 'My Agent',
  instructions: 'You are a helpful assistant.',
  model,
});

run(agent, 'What is the capital of Germany?');
```

Check two things first. OpenAI’s docs say “many other providers don’t support” structured outputs, multimodal input, or hosted search tools. And without an OpenAI API key, turn tracing off or add another trace processor. For routing between providers, see [LiteLLM vs OpenRouter for AI agents](/other-content/litellm-vs-openrouter-for-ai-agents).

## Tracing, guardrails and handoffs

Tracing is on by default, and it records “LLM generations, tool calls, handoffs, guardrails, and even custom events.” Set `OPENAI_AGENTS_DISABLE_TRACING=1` to turn it off, or call `set_trace_processors()` to replace the default exporter. The docs list processors for Datadog, Langfuse, LangSmith and Logfire, among others.

Guardrails come in three kinds, and each one runs at a different point:

1.  **Input guardrails** “run only for the first agent in the chain.”
2.  **Output guardrails** “run only for the agent that produces the final output.”
3.  **Tool guardrails** “run on every guarded function-tool invocation,” which makes them the right check in a workflow with handoffs.

Handoffs “are represented as tools to the LLM,” so a handoff to `Refund Agent` becomes a `transfer_to_refund_agent` tool. Approvals raised after a handoff still surface on the outer run’s `RunState`.

## Release versions for Python and TypeScript

OpenAI publishes the SDK as `openai-agents` on PyPI (Python 3.10 or later) and `@openai/agents` on npm, both under MIT. The latest releases, from each registry:

| Package | Version | Released |
| --- | --- | --- |
| openai-agents (PyPI) | 0.24.0 | October 15, 2026 |
| openai-agents (PyPI) | 0.23.1 | October 2, 2026 |
| openai-agents (PyPI) | 0.22.3 | September 17, 2026 |
| @openai/agents (npm) | 0.21.0 | October 20, 2026 |
| @openai/agents (npm) | 0.20.0 | October 8, 2026 |
| @openai/agents (npm) | 0.19.0 | October 5, 2026 |

The minor number is the one to watch, since OpenAI raises it “for **breaking changes** to any public interfaces that are not marked as beta.” So pin the minor version and read the breaking change changelog first: Python 0.21.0 “requires `openai` v3,” and Python 0.22.0 rejects an explicit client combined with `organization` or `project`. The TypeScript sub-packages share one version number.

The PyPI extras show what plugs in: `litellm`, `any-llm`, `sqlalchemy`, `redis`, `mongodb`, `dapr` and `encrypt` for models and sessions, and `docker`, `e2b`, `daytona`, `modal`, `vercel`, `blaxel`, `cloudflare` and `runloop` for Sandbox Agents, which add a `Manifest` and a `SandboxRunConfig` to the normal `Runner` flow.

## What does Cadenya offer that the OpenAI Agents SDK doesn’t?

The OpenAI Agents SDK gives you a loop to host, and the production work is everything around it: a process, a session store, a `RunState` table, and maybe a durable engine. **Cadenya is the agent loop already hosted, with approvals, conversation state, resume and model swap built in.** Here’s what that covers:

1.  **The loop, already running.** Your app creates an objective, and Cadenya calls the model, runs your tool sets, and streams each event. There’s no `Runner` process or engine to operate.
2.  **Approvals with no snapshot to store.** Mark a tool as needing approval, and Cadenya “parks the Agent loop until it receives approval or a denial with optional steering.” Your backend handles `toolApprovalRequested` and approves or denies, and a denial carries a memo such as “Use the read-only lookup tool instead.” Several tools can wait at once.
3.  **Conversation state and resume.** Every objective carries a durable event log of its agent loop. Stream new events over server-sent events and resume with the last event ID, and send a Continue message when an objective is waiting for the user.
4.  **Compaction you configure once.** The variation holds a compaction config, and the Compact an objective endpoint compacts on demand: a waiting objective starts at once, and a busy one compacts before its next assistant turn.
5.  **Model swap with no deploy.** The model is a setting on an agent variation, not code. Connect your own AI provider keys, pay the provider directly, and let weighted variations favor whichever variation scores well.
6.  **No version marker to keep.** “The Objective keeps that variation’s configuration snapshot even if you edit the variation later,” so a prompt or tool change never breaks a run that’s already going. An External ID on an objective prevents duplicates for a record in your app.
7.  **Tools from what you already have.** A tool set comes from an OpenAPI 3.0 spec, an MCP server, HTTP endpoints you define, or Bare tools your app answers. Cadenya runs the agent loop and calls your sandbox as a tool set, as the [E2B guide](/other-content/running-agent-code-in-e2b) and [running agent-generated code safely](/other-content/running-agent-generated-code-safely) show.
8.  **Handoffs as sub-agents.** Assign a sub-agent or an agent pool to a variation, and an agent hands work to another agent as a sub-objective.
9.  **SDKs and a price in one line.** TypeScript, Python, Ruby and Go SDKs are at 1.9.0 under Apache-2.0. Free covers 1,000 loops a month, Growth is $49 a month for 50,000, and a loop is one LLM request.

[Approve or deny tools](/docs/guides/the-basics/objectives#approve-or-deny-tools) walks through the approval flow, and the free plan needs no card.

No account yet? A coding agent can create a temporary workspace with `cadenya workspaces create --temporary`, run its first objectives there, and hand you a link to claim it, as [auth.md](https://cadenya.com/auth.md) explains. To create an account, sign up at [app.cadenya.com/signup](https://app.cadenya.com/signup?utm_source=cadenya.com&utm_medium=article&utm_campaign=openai-agents-sdk-in-production), then copy your API key from the API keys page at `app.cadenya.com/account/apiKeys`.