Strands is an agent framework by AWS. TheDocumentation Index
Fetch the complete documentation index at: https://docs.osmosis.ai/llms.txt
Use this file to discover all available pages before exploring further.
osmosis-ai package includes strands-agents[litellm] as a built-in dependency, so no additional installation is needed.
OsmosisStrandsAgent
OsmosisStrandsAgent is a drop-in replacement for the Strands Agent class that automatically:
- Swaps the model to connect to the training cluster’s LLM endpoint
- Registers itself with the
RolloutContextfor automatic sample collection
OsmosisRolloutModel does not take a model_id — the SDK hardcodes the placeholder model id openai/osmosis-rollout inside for_sample(), and the training cluster routes that to the current policy. Use the params dict to pass sampling parameters like temperature, max_tokens, etc. (see LiteLLM input params for the full list). Construct the agent inside AgentWorkflow.run() (or another code path where the execution backend has already installed an active RolloutContext).How It Works
OsmosisRolloutModel
OsmosisRolloutModel is a LiteLLMModel subclass that acts as a placeholder during construction. It does not make LLM calls directly — instead, it defers to the training cluster at runtime.
- At runtime,
for_sample(sample_id, rollout_ctx)creates a concreteLiteLLMModelinstance connected to the training cluster’s chat completions endpoint - Adds
x-sample-idandx-rollout-idheaders so the training cluster can route requests correctly - Cannot be called directly — raises
NotImplementedErrorif invoked before runtime resolution
OsmosisStrandsAgent
When constructed with anOsmosisRolloutModel, OsmosisStrandsAgent performs the following steps:
Read RolloutContext
Reads the active
RolloutContext from the current execution scope. Raises RuntimeError if no context is available.Resolve model
Calls
model.for_sample() to create a real LiteLLMModel connected to the training cluster.Register with context
Registers itself with the
RolloutContext via rollout_ctx.register_agent(sample_id, self) for automatic sample collection.Complete Example
Here is a full AgentWorkflow and Grader using Strands:ctx.prompt is already the ready-to-use input for the current sample, so you can pass it straight into OsmosisStrandsAgent(messages=...) with no extra reshaping. If your dataset row contains system_prompt and user_prompt, the SDK has already assembled that input for you. Inside an async run(), prefer await agent.invoke_async() — it matches the canonical SDK pattern and avoids bouncing through Strands’ synchronous wrapper. The synchronous agent(...) form may still run, but it is unnecessary here.Migrating from StrandsAgent
If you already have a Strands agent, migrating to Osmosis takes four changes:Update Model import
Replace Drop the
LiteLLMModel(model_id="openai/gpt-5.2", ...) with:model_id — the training cluster decides which policy to serve. Move any sampling kwargs (temperature, max_tokens, …) into the params dict.Swap Agent class
Replace
Agent(...) with OsmosisStrandsAgent(...). All other constructor parameters (tools, system prompt, etc.) stay the same.Next Steps
Building AgentWorkflows
Learn more about the AgentWorkflow class and implementation patterns.
Local Evaluation
Test your Strands-based workflow with eval mode.