strands.decisions.decision_model
Base interface for making structured “decisions” from inside the SDK.
DecisionModel
Section titled “DecisionModel”class DecisionModel(abc.ABC)Defined in: src/strands/decisions/decision_model.py:16
Abstract base for anything that can answer closed questions.
The public ask opens a decision span, validates the question map, delegates to the
subclass _ask, records usage, the question ids, and the answer set as span attributes, and
closes the span. Content goes on span attributes rather than span events because OpenTelemetry
has deprecated the span-event recording API. Every implementation is traced identically. Given
an invocation_context, ask also adds the reported usage to that request once _ask
returns.
async def ask(state: DecisionInput, questions: dict[str, Question], *, invocation_context: InvocationContext | None = None, **kwargs: Any) -> DecisionResultDefined in: src/strands/decisions/decision_model.py:27
Ask one or more closed questions over the given state.
Arguments:
state- A plain string, a one-shot content list, or a message history.questions- Map of identifier to question. The returnedanswersdict is keyed off this same map.invocation_context- Request to add this decision’s token usage to. The request’s limits do not apply to the decision.**kwargs- Additional keyword arguments forwarded to the implementation for future extensibility.
Returns:
A DecisionResult whose answers are keyed by the question identifiers.
Raises:
ValueError- Ifquestionsis empty or a question violates its semantic constraints.TypeError- Ifinvocation_contextwas not created by the SDK.StructuredOutputException- If the model declines to produce a valid answer set, omits an answer, or returns a value outside a question’s allowed choices.