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.
Ask a question
Section titled “Ask a question”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'}import { LLMDecisionModel } from '@strands-agents/sdk'
const message = 'I was charged twice for order 1182. Please refund one charge today.'
const decisions = new LLMDecisionModel()const 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'], },})console.log(result.answers)
// 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.
Handle an uncertain answer
Section titled “Handle an uncertain answer”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.import { LLMDecisionModel, Uncertain } from '@strands-agents/sdk'
const message = 'I was charged twice for order 1182. Please refund one charge today.'
const decisions = new LLMDecisionModel()const result = await decisions.ask(message, { plan: { question: 'Which plan is the customer on?', choices: ['free', 'pro', 'enterprise'], },})const plan = result.answers.planif (plan instanceof Uncertain) { console.log(`Unknown plan: ${plan.reason}`)} else { console.log(`Plan: ${plan}`)}
// 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.
Next steps
Section titled “Next steps”- Questions and answers: the choices, uncertainty settings, inputs, and result fields.
- Decisions in an agent: ask from a tool and count the tokens toward the agent’s request.
- LLM decision model: choose the model and system prompt.