Patterns overview
TL;DR TypeSafe documents four patterns: Speculative Fan-Out (ask everything in one call, filter in code), Confidence-Gated Routing (per-action confidence thresholds), Composite Scoring (independent Score dimensions combined with weights you own), and Intent Routing (classify first, then invoke the cheapest adequate handler). All four rest on the same move: the model makes atomic judgments, your code composes them.
Problem
Jev sits inside a larger system rather than being the system. The docs state it plainly: "TypeSafe is designed to sit within a larger system, powering decisions with AI. Learning to think in terms of discrete, atomic decisions that compose into complex system behavior is a key skill for getting the most out of TypeSafe."
The recurring design question is therefore not "what prompt do I write" but "which judgments do I need, how many calls do I make, and what does my code do with the numbers that come back." The four patterns are TypeSafe's documented answers.
Prerequisites, per raw/docs/patterns.md: "This section assumes you know the TypeSafe primitives and understand how confidence works. If not, read those first." See Primitives: Choice, Score, Noul and Confidence vs probability.
Pattern
The catalog, reproduced from raw/docs/patterns.md:
| Pattern | What it does | Benefits |
|---|---|---|
| Speculative Fan-Out | Send many questions in a single call, including speculative ones, and let your code decide what's relevant | Cost, Speed |
| Confidence-Gated Routing | Utilize confidence as a second decision axis to build safer systems | Reliability, Safety |
| Composite Scoring | Combine several dimensions of analysis into a single score | Cost, Reliability, Speed |
| Intent Routing | Classify a user's intent and route to the appropriate handler | Cost, Speed |
Each page's own one-line thesis:
- Speculative fan-out — "Send many questions in a single call, including speculative ones, and let your code decide what's relevant."
- Confidence-gated routing — "Use confidence as a second axis. The answer tells you what; confidence tells you whether to act."
- Composite scoring — "Break a complex judgment into atomic scores, combine with weights you control in code."
- Intent routing — "Classify incoming requests and route each to the optimal handler: deterministic logic, a specialist LLM, or a human."
When to reach for each
The following selection table is a synthesis of the four source pages (inferred as a table; the individual claims are sourced):
| Your situation | Pattern | Why |
|---|---|---|
| A decision tree where later branches need extra facts | Speculative fan-out | "All questions are evaluated in parallel, so adding more questions to a call typically doesn't add any latency to the response." Ask the branch-specific questions upfront and discard the irrelevant answers. |
| Actions differ in blast radius (read vs. move money) | Confidence-gated routing | Each action type gets its own threshold "based on the consequences of acting on a wrong classification." |
| You need to rank or shortlist items on several dimensions | Composite scoring | Score each dimension separately, normalize, weight in code; weights are tunable without re-running inference. |
| Requests need different handlers (code / LLM / human) | Intent routing | "The expensive resources only get invoked for the requests that actually need them." |
These compose. The intent-routing example is itself fan-out plus a confidence gate: it asks intent and complexity in one call and checks intent.confidence < 0.5 before acting.
Implementation
Every pattern uses the same two-step skeleton — one POST /v1/systemone call carrying a questions map, then plain code over response.answers. The shared shape, from the pattern pages' Python snippets:
Step 1 is one call carrying many questions (see the individual pattern pages for the exact questions maps). Step 2 is plain code:
answer = response.answers["<question id>"]
answer.choice # Choice
answer.score # Score
answer.noul # Noul
answer.confidence # Choice and Score only
For the wire contract see HTTP API: POST /v1/systemone and GET /v1/models; for the SDK signatures see Python SDK: install, clients, system_one() and JavaScript/TypeScript SDK: install, client, choice/score/noul.
When it fails
- Treating the catalog as exhaustive. The docs invite additions: "We're always keen to learn how people are making use of our primitives. If you've found a killer use case you think should be mentioned here, feel free to drop us a note!" The agent skill (
raw/github/skills/skills/typesafe-ai/SKILL.md) says the same more sharply: "The patterns below are starting points: combine primitives around the user's goal, including ideas that do not fit an established recipe." - Skipping the prerequisites. Confidence thresholds copied from a pattern page without reading Confidence vs probability are the most common way these patterns misfire; see each page's "When it fails" section.
- Assuming zero cost for extra questions. Latency barely moves, but the skill warns: "Extra questions still use tokens; measure actual request budgets, cost, and end-to-end latency."
Variants
- Compose two or more patterns in one call. Intent routing is the documented example.
- Cookbooks are worked variants. The cookbook index shows these patterns applied end to end, often with a better decomposition than a generic classifier.
- Demos. Smart home assistant demo walkthrough is fan-out plus an LLM fallback in a running application.
Related
- Primitives: Choice, Score, Noul — Choice, Score, Noul; required reading first
- Confidence vs probability — what
confidencemeans and how to threshold it - How to build software with System One — the full design workflow
- Choosing between Choice, Score, Noul — picking the question type
- Cookbooks overview — worked, domain-specific applications
- The typesafe-ai agent skill and Claude Code plugin — the skill that teaches agents these patterns
Sources
- raw/docs/patterns.md (https://docs.typesafe.ai/patterns)
- raw/docs/patterns__fan-out.md (https://docs.typesafe.ai/patterns/fan-out)
- raw/docs/patterns__confidence-routing.md (https://docs.typesafe.ai/patterns/confidence-routing)
- raw/docs/patterns__composite-scoring.md (https://docs.typesafe.ai/patterns/composite-scoring)
- raw/docs/patterns__intent-routing.md (https://docs.typesafe.ai/patterns/intent-routing)