Adam Innes · Blog

Strands Agents Grew a Typed Way to Say "I Don't Know"

· 6 min · ai agents, strands agents, python, aws

Back in September I wrote about Jev and TypeSafe’s System One model, and ended on a prediction I thought was safe because it was vague: deciding the shape of an answer before the model runs, and getting a probability over your own enum instead of a sentence to parse, is a different contract between software and a model, and the idea would probably outlast whichever vendor got there first. Six weeks later Amazon’s Strands Agents shipped that contract as a framework primitive. I went to look at it expecting a thin wrapper and found something more interesting, plus two details that would have bitten me.

Start with the thing you notice before any of the code, because it tripped up my bookmarks: the repo moved. strands-agents/sdk-python is now part of a monorepo at strands-agents/harness-sdk, described as “build an agent harness and control it end-to-end,” with the Python SDK under strands-py/ alongside a TypeScript SDK, a CLI, and an MCP server. The project’s center of gravity has shifted from “here is an agent loop” to “here is an assembled agent you configure,” and there’s now a separate strands-harness package whose entire public surface is create_harness(). The SDK you install as strands-agents is what you reach for when you want to own the loop yourself. That’s the layer the decision primitive lives in.

What a decision is, in this SDK

A DecisionModel answers closed questions about some state. You hand it a string, a content list or a message history, plus a map of question identifiers to questions, and you get back answers keyed by the same identifiers. Each question declares its own answer shape: "boolean", or a list of string literals.

import asyncio

from strands.decisions import LLMDecisionModel, Uncertain
from strands.models import BedrockModel

decisions = LLMDecisionModel(model=BedrockModel())

async def triage(ticket: str) -> str | None:
    result = await decisions.ask(
        ticket,
        {
            "team": {
                "question": "Which team should handle this ticket?",
                "choices": ["billing", "technical", "sales"],
            },
            "urgent": {
                "question": "Does the message convey time pressure?",
                "choices": "boolean",
                "uncertainty": False,
            },
        },
    )

    team = result.answers["team"]
    if isinstance(team, Uncertain):
        print("escalating:", team.reason)
        return None

    return team

asyncio.run(triage("Stripe has been failing for three days and payroll is Friday."))

Two things in there are worth pulling out. result.answers["team"] is typed as bool | str | Uncertain, so uncertainty is a value you receive rather than an exception you catch or a confidence float you compare. And "uncertainty": False on the second question is me opting out.

Uncertainty is opt-out, not opt-in

That default is the right call and it will still surprise people. Omit the uncertainty key, or set it to True, and the question permits an uncertain answer. Only an explicit False removes it. Which means every question you write without thinking about it can come back Uncertain, and any code that assumed it was getting one of its own choices has a branch it never wrote.

I’d rather have it this way around — the alternative is a model forced to pick billing for a ticket that is plainly neither billing nor technical nor sales, which is the silent-wrongness problem that makes these pipelines miserable to operate. But it does mean the isinstance check in that example isn’t defensive padding. It’s the common path, and if you skip it you’ve built the forced-choice system anyway, just with extra steps.

The sentinel is truthy

This one is a genuine trap, and the SDK’s own docstring flags it: an Uncertain instance is truthy. Always narrow with isinstance, never with truthiness. I checked rather than trusting the comment:

>>> from strands import Uncertain
>>> bool(Uncertain("no evidence either way"))
True

So if result.answers["urgent"]: is True when the model answered yes and when the model declined to answer at all. For a boolean question that’s the worst possible failure mode: the escape hatch that exists to stop the model guessing gets silently read as a yes. It’s the kind of thing that passes review, passes your happy-path test, and shows up weeks later as a handful of tickets that got paged out at 3am for no reason.

Nothing in the type system saves you here, because bool | str | Uncertain is a perfectly truthy union. If I were using this in anger I’d unwrap once at the boundary and never let an Uncertain reach business logic.

min_confidence does nothing on the LLM backend

Here’s the part I’d want to know before designing around any of this. A question’s uncertainty can be a mapping instead of a bool, carrying a min_confidence float in [0.0, 1.0]: below that confidence, report the answer as uncertain. That is exactly the threshold pattern — automate above the line, escalate below it — that made the System One idea worth writing about.

It is not implemented by the adapter most people will reach for first. The docstring says min_confidence is “read only by implementations that return per-answer confidence (e.g. System One models); ignored by LLMDecisionModel,” and the source agrees: the string min_confidence appears zero times in llm_decision_model.py. The same goes for the DecisionMetadata you get back, where probabilities and confidence are both documented as None for implementations that don’t report them.

It’s worth understanding why, because it isn’t an oversight. LLMDecisionModel is an adapter that turns any Model into a DecisionModel, and it does so with one forced structured-output call against a Pydantic schema built on the fly. Uncertainty is implemented by appending the literal string "uncertain" to each permitting question’s enum, with a sibling field for the reason. There is no distribution anywhere in that design. The model emits a token; the adapter maps that token to Uncertain(reason). There is nothing to threshold.

Which lands on the same point I made about asking an LLM to self-report confidence: a number that sounds like a probability and behaves like a vibe. The decision API has a slot for calibrated confidence, and pointing it at a text model fills that slot with a model’s willingness to type the word “uncertain” — which tracks prompt wording, enum ordering and temperature at least as much as it tracks the evidence. You get the shape of calibrated decision-making. Set a min_confidence of 0.85 on an LLMDecisionModel question and nothing happens. No error, no warning.

The backend that honors it

Version 1.64.0, published November 4, added TypeSafeDecisionModel — a DecisionModel backed by TypeSafe’s hosted Jev API, reading TYPESAFE_API_KEY from the environment, defaulting to model_id="jev-latest" and, notably, default_min_confidence=0.5.

from strands.decisions.typesafe_decision_model import TypeSafeDecisionModel

decisions = TypeSafeDecisionModel(default_min_confidence=0.8)

Construct it without a key and it raises immediately, which is the right instinct and makes the contrast sharper: a missing credential is a loud failure, while a min_confidence the backend can’t honor is a silent one.

Both classes subclass DecisionModel, so that’s the only line that changes. The ask call, the question map and the isinstance narrowing all stay exactly as they were. That is the part I think is actually well designed: a model that returns calibrated probabilities and a model that returns generated text have been put behind one interface where the difference between them shows up as whether a threshold is enforced, not as a rewrite.

The flip side is that the difference only shows up there, and silently. Two backends, one interface, one of them quietly ignoring a parameter you set for safety reasons — that asymmetry deserves a loud warning at construction time, and it doesn’t get one. If you adopt this, the thing to write down somewhere visible is which DecisionModel each call site is pointed at, because that’s what decides whether min_confidence is a control or a comment. A reasonable habit is to treat a min_confidence on an LLM-backed question as a type error in review.

A word on how new all of this is. strands.decisions first appeared in 1.63.0 on October 30; the version on PyPI as I write this is 1.64.0 from November 4. The narrative documentation isn’t there yet — the issue to document DecisionModel is still open, so what exists is the API reference and the source. Everything above came from reading the installed package, and a five-day-old primitive in a project that shipped eighty-nine releases this year is not where I’d put load-bearing weight yet.

But the direction is right, and it’s the direction I didn’t expect a framework to take first. Most agent SDKs treat “the model wasn’t sure” as a parsing problem or a retry, and the honest answer is that it’s a value your program has to handle. Strands made it a type. Whether that type carries real information still depends entirely on what you plug in behind it, and that’s a choice the interface is a little too comfortable letting you get wrong.

← all posts