AgentWorkflow is the SDK contract for rollout behavior. You subclass it, implement one async run() method, and create samples by calling the current policy through an Osmosis-supported agent integration.
The workflow should answer one question: given this dataset prompt, what should the agent do before the grader scores the result?
Base Class
run() is called once for each workflow execution. It should construct any per-execution agent/session objects inside the method, run the agent, and let the integration register the resulting conversation with the active RolloutContext.
AgentWorkflowContext
Thectx object gives the workflow its input and config:
| Field | Type | Description |
|---|---|---|
ctx.prompt | list[dict[str, Any]] | Input messages for the current dataset row |
ctx.config | TConfig | None | Custom workflow config object, if one was provided |
ctx.metadata | dict[str, Any] | None | Per-row metadata from the dataset’s optional metadata column. None when the row has no metadata. |
system_prompt, user_prompt, and ground_truth, the prompt fields are assembled into ctx.prompt. The reference answer is not passed to the workflow; it is exposed to your grader as ctx.label. The same metadata object is available on both AgentWorkflowContext and GraderContext, so workflows and graders can read the same per-row context.
Model Routing Requirement
Use one of the supported integrations:| Framework | Use | Integration objects |
|---|---|---|
| Strands Agents | Strands tools, Strands message history, migration from strands.Agent | OsmosisStrandsAgent, OsmosisRolloutModel |
| OpenAI Agents SDK | Runner.run, sessions, handoffs, OpenAI-style tools | OsmosisAgent, OsmosisRolloutModel, OsmosisMemorySession |
litellm, the OpenAI SDK, or another provider SDK directly with a hard-coded policy model from run(). Direct calls bypass the rollout context and are not compatible with training.
Strands Pattern
For Strands, passctx.prompt directly as messages and call invoke_async():
OsmosisStrandsAgent inside run() binds it to the active rollout context and registers the agent as a sample source.
See Strands Integration for tool examples, migration steps, and details about OsmosisRolloutModel.
OpenAI Agents Pattern
For OpenAI Agents, construct anOsmosisAgent, attach OpenAI Agents ModelSettings, create one OsmosisMemorySession, and pass that session to Runner.run():
run() so it registers with the current RolloutContext.
See OpenAI Agents Integration for session behavior, tracing notes, and migration steps.
Custom Configuration
Custom configs extendAgentWorkflowConfig. Define a module-level config instance in your rollout entrypoint and pass it to the backend:
osmosis train submit preflight auto-discovers at most one module-level AgentWorkflowConfig instance from the entrypoint module. Eval and training TOML files do not currently set workflow config fields directly.
BaseConfig allows extra fields, so simple rollout configs usually do not need additional Pydantic boilerplate.
| Field | Type | Default | Description |
|---|---|---|---|
name | str | required | Identifier for the workflow |
description | str | None | None | Optional description |
concurrency | ConcurrencyConfig | unlimited | Maximum concurrent workflow executions |
Tool-Using Workflows
Tool use belongs inside your agent framework, not in the backend. Define tools the way your framework expects, pass them into the Osmosis-wrapped agent, and let the integration record the resulting messages. For example, a Strands workflow can keep its tool list in config:Auto-Discovery
osmosis train submit and osmosis eval submit both scan the rollout entrypoint module for concrete AgentWorkflow subclasses. You do not need decorators or registration functions, but the entrypoint still needs to construct a backend and serve it with create_rollout_server() so the rollout server can run on the platform.
Use helpers, base classes, tools, and configs freely, but keep only the workflow class you want to run as a concrete AgentWorkflow in the entrypoint.
Next Steps
Strands Integration
Build a Strands-based rollout with tools and
OsmosisStrandsAgent.OpenAI Agents Integration
Build an OpenAI Agents SDK rollout with
OsmosisAgent and OsmosisMemorySession.Building Graders
Define reward logic for the samples your workflow produces.
Evaluation
Submit an evaluation run to test your workflow and grader before a training run.