sagemaker.train.rft.adapters.strands#
Strands framework adapter for automatic header and inference param injection.
Provides wrap_model() which wraps a Strands model to automatically inject RFT headers and inference parameters into requests using the rollout context.
The wrapper intercepts stream() and injects headers via
client_args["default_headers"] because Strands OpenAIModel creates
a new OpenAI client per request from client_args.
Functions
|
Wrap a Strands model to auto-inject headers and inference params from context. |
- sagemaker.train.rft.adapters.strands.wrap_model(model: Any) Any[source]#
Wrap a Strands model to auto-inject headers and inference params from context.
Creates a transparent proxy that: 1. Injects the
X-RFT-Metadataheader (containing job_id, experiment_id,rollout_id) via client_args[“default_headers”] on every stream() call
Injects inference parameters (temperature, max_tokens, top_p)
- Parameters:
model – A Strands model instance (e.g.,
OpenAIModel).- Returns:
A wrapped model that transparently injects RFT headers.
Example:
from strands.models.openai import OpenAIModel from strands import Agent from sagemaker.train.rft.adapters.strands import wrap_model model = OpenAIModel( client_args={"api_key": "...", "base_url": "..."}, model_id="my-model", ) wrapped = wrap_model(model) agent = Agent(model=wrapped, tools=[...]) result = agent("Solve this task")