Skip to content

Amazon SageMaker AI

SageMakerDecisionModel answers questions with a decision model you deploy to an Amazon SageMaker AI real-time endpoint in your own AWS account, such as Strands Decider. It returns the same result as every other decision model, plus a probability for each label and a confidence for each answer.

Choose it when the input must stay in your AWS account, or when you want to pick the model version and the instance it runs on. If you’d rather not run an endpoint, TypeSafe Jev answers the same questions as a hosted API.

You need a deployed endpoint first. The Strands Decider SageMaker guide deploys one from SageMaker JumpStart or with a CDK stack. The endpoint must accept the System One request that Strands Decider serves.

SageMakerDecisionModel ships with the SDK and uses boto3, which the SDK already depends on:

Terminal window
pip install strands-agents

SageMakerDecisionModel signs each request with the standard AWS credential chain: environment variables, shared config and credentials files, and IAM roles. The credentials need sagemaker:InvokeEndpoint on the endpoint. The container behind the endpoint has no authentication of its own, so this IAM permission is the only access control. See Setting up AWS credentials for shared setup.

To use a named profile or assumed-role credentials, pass a boto3 session. The decision model calls the endpoint in the session’s region:

import boto3
from strands.decisions import SageMakerDecisionModel
decisions = SageMakerDecisionModel(
"strands-decider-2b-qwen3-5-v1-2610",
boto_session=boto3.Session(profile_name="decisions", region_name="us-east-1"),
)

Without a session, pass region_name. If you set no region, the decision model uses the region from boto_client_config, then the session’s configured region, then AWS_REGION. With no region from any source, the constructor raises botocore’s NoRegionError.

OptionDescription
endpoint_nameendpointNameName of the SageMaker AI real-time endpoint. Required.
region_nameregionAWS region of the endpoint.
boto_client_configclientConfigConfiguration for the SageMaker Runtime client, such as timeouts and retries.
clientA SageMaker Runtime client you’ve built, used as is.
default_min_confidencedefaultMinConfidenceConfidence below which an answer comes back Uncertain, in [0.0, 1.0]. Defaults to 0.5. See Confidence and uncertainty.

A prebuilt client can’t be combined with the region, session, or client configuration, and a session can’t be combined with a region. The constructor raises an error for those combinations and for an empty endpoint name.

See the SageMakerDecisionModel API reference for all constructor options.

This example asks two questions about a support message and prints each answer with its confidence:

import asyncio
from strands.decisions import SageMakerDecisionModel
message = "I was charged twice for order 1182. Please refund one charge today."
async def main():
decisions = SageMakerDecisionModel(
"strands-decider-2b-qwen3-5-v1-2610", region_name="us-east-1"
)
result = await decisions.ask(
message,
{
"urgent": {
"question": "Does the customer need help today?",
"choices": "boolean",
},
"team": {
"question": "Which team should handle this message?",
"choices": ["billing", "shipping", "technical"],
},
},
)
confidence = result.metadata.confidence
print(result.answers["urgent"], f"{confidence['urgent']:.2f}")
print(result.answers["team"], f"{confidence['team']:.2f}")
asyncio.run(main())
# Typical output:
# True 0.90
# billing 1.00

The request doesn’t name a model. The endpoint runs one, and metadata.model_idmetadata.modelId reports the name the endpoint returns. The decision model doesn’t cap the number of questions per call.

The model reports a confidence for every answer. An answer below the minimum comes back as Uncertain, and metadata.confidence and metadata.probabilities still show what the model leaned toward. Confidence explains how it’s measured.

The default minimum of 0.5 suits most routing and triage questions. For a question where a wrong answer costs more than asking a person, raise the minimum on that question alone: set its uncertainty to {"min_confidence": 0.8}{ minConfidence: 0.8 }.

The call runs on botocore’s default timeouts and retries. Set your own with boto_client_config:

from botocore.config import Config
from strands.decisions import SageMakerDecisionModel
decisions = SageMakerDecisionModel(
"strands-decider-2b-qwen3-5-v1-2610",
region_name="us-east-1",
# Fail a slow read after five seconds and try the call at most twice
boto_client_config=Config(read_timeout=5, retries={"total_max_attempts": 2}),
)

boto3 is synchronous, so the call runs on a worker thread. Cancelling the task that awaits ask stops the wait, not the call already sent to the endpoint.

Beyond the validation errors, ask raises:

ErrorWhen
ModelThrottledExceptionModelThrottledErrorSageMaker is throttling or the endpoint isn’t ready (ThrottlingException, ModelNotReadyException, or ServiceUnavailable), or the container returned HTTP 429, 503, or 529. Retry with backoff.
ContextWindowOverflowExceptionContextWindowOverflowErrorThe container returned HTTP 413, or HTTP 422 with a message about the context window, as Strands Decider does when deployed with --strict-window. Shorten the input, such as by sending only the latest messages of a conversation.
botocore.exceptions.ClientErrorModelErrorAny other SageMaker error, such as AccessDeniedException for missing IAM permission or ValidationError for an endpoint that doesn’t exist.
botocore.exceptions.BotoCoreErrorModelErrorThe call didn’t complete, such as a read timeout, a network failure, or missing credentials.
StructuredOutputExceptionModelErrorThe endpoint returned a response the decision model can’t read, such as an answer outside the question’s choices.

The throttling errors keep the SageMaker error as their cause.

So do the context window errors. Read the error code from the cause's response.So does the generic ModelError. Check for the two specific errors first.