Skip to content

Decision models quickstart

In this quickstart, you triage a customer support message with a decision model. You ask whether the message is urgent and which team should handle it, then read the answers in your code.

The examples use LLMDecisionModel, which runs the questions on a model provider. With no model configured, it uses Amazon Bedrock, so you need the SDK installed and AWS credentials with Amazon Bedrock access. The Python and TypeScript quickstarts cover both.

Each question has an id you choose, the question in plain language, and its choices: "boolean" for a yes/no answer, or a list of labels. Pass the input and the questions to ask:

import asyncio
from strands import LLMDecisionModel
message = "I was charged twice for order 1182. Please refund one charge today."
async def main():
decisions = LLMDecisionModel()
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"],
},
},
)
print(result.answers)
asyncio.run(main())
# Typical output:
# {'urgent': True, 'team': 'billing'}

The answers are keyed by your question ids. A yes/no question returns a boolean, and a multiple-choice question returns one of its labels.

Sometimes the input doesn’t support any of the choices. Instead of guessing, the decision model can return Uncertain, often with a reason. This message says nothing about the customer’s plan:

import asyncio
from strands import LLMDecisionModel, Uncertain
message = "I was charged twice for order 1182. Please refund one charge today."
async def main():
decisions = LLMDecisionModel()
result = await decisions.ask(
message,
{
"plan": {
"question": "Which plan is the customer on?",
"choices": ["free", "pro", "enterprise"],
},
},
)
plan = result.answers["plan"]
if isinstance(plan, Uncertain):
print(f"Unknown plan: {plan.reason}")
else:
print(f"Plan: {plan}")
asyncio.run(main())
# Typical output:
# Unknown plan: The message does not mention which plan the customer is on.

Every question allows Uncertain unless you turn it off, which Questions and answers covers.