openai-agents extra (osmosis-ai[openai-agents]>=0.3.0rc1,<0.4) when your rollout uses Agent, Runner.run, sessions, tools, handoffs, or other OpenAI Agents SDK primitives.
The integration has three main objects:
Quick Example
How It Works
1
Construct the agent inside run
OsmosisAgent checks whether the model argument is an OsmosisRolloutModel. If so, it replaces the placeholder with an OsmosisLitellmModel bound to the active RolloutContext.2
Create a memory session
OsmosisMemorySession registers itself as the single sample source on the current RolloutContext.3
Run the OpenAI agent
Runner.run() interacts with the session through get_items() and add_items(). The session stores the persisted OpenAI Agents SDK items in the canonical Responses API shape.4
Route policy calls
The resolved model sends requests directly to the rollout-scoped Osmosis chat-completions URL.
5
Collect the sample
After
run() completes, the backend asks the rollout context for its sample. The session returns one RolloutSample containing the runner’s persisted conversation.Complete Example
This example uses an OpenAI Agents SDK tool and a grader that reads the final assistant text from the session-backed sample.sample.messages preserves the OpenAI Agents SDK session’s native persisted items for graders. The integration separately performs a best-effort normalization for ATIF; conversion failure leaves the native sample intact. A server created with create_rollout_server() persists that ATIF view, and includes usage, model, or timestamp fields only when the source provides them.OsmosisRolloutModel
OsmosisRolloutModel is a placeholder. Do not call it directly and do not pass a fixed policy model name into rollout code. In the workspace templates, sampling options live in OpenAI Agents ModelSettings.
OsmosisAgent replaces the placeholder with a model that points at the active Osmosis rollout endpoint.
One Session per Rollout
Use exactly oneOsmosisMemorySession in each workflow execution that uses OsmosisRolloutModel.
run(). A session created outside the active rollout context cannot be reused inside a rollout run because it was not registered with that context. Constructing a second session in the same execution raises ValueError; use handoffs within the same run, or configure multiple independent workflow executions when you need multiple candidate samples.
Migrating from OpenAI Agents SDK
If you already have an OpenAI Agents SDK workflow, migrate it in four steps:1
Replace Agent with OsmosisAgent
Change the import and class:Then construct
OsmosisAgent(...) instead of Agent(...).2
Replace the policy model
Replace a fixed model string with an
OsmosisRolloutModel placeholder:3
Add an OsmosisMemorySession
Create the session inside
AgentWorkflow.run() and pass it to Runner.run():4
Wrap the runner in AgentWorkflow
Put the runner call inside an
AgentWorkflow.run() method. Keep your tools, instructions, handoffs, and agent behavior the same unless they depend on out-of-band state.Evaluation
Use the normal eval command:openai/osmosis-rollout to the model named in [experiment].model_path of the evaluation TOML. During a training run, Osmosis routes the same placeholder to the current training policy.
Next Steps
AgentWorkflow
Review the shared
AgentWorkflow.run(ctx) contract.Grader
Write reward logic for the OpenAI Agents session sample.
Evaluation
Submit an evaluation run for your OpenAI Agents rollout before a training run.