Patterns

September 19, 2026 · View on GitHub

Code owns control flow. Jev supplies snap judgments. Keep arithmetic, lookups, and policy weights in code.

Speculative fan-out

Ask every question the tree might need in one call, including ones you will ignore. Example: classify a ticket and score bug severity; drop severity when the choice is not bug_report.

Second request only when the first answer is required to fetch evidence, construct new state, or pick the next options. Three cookbooks that actually need a second call: skill suggestion (rank, then re-judge top 3 with full text), structure recovery (stitch lines, then classify blocks that did not exist yet), hierarchical classification (each choice picks the next option set).

Confidence-gated routing

Answer = what. Confidence = whether to act. Floor for "don't guess"; higher bar for destructive actions. Example from docs: any intent below 0.6 → human; check_balance at 0.6 is fine; approve_transfer wants >0.85 or confirm. Tune on your data.

Composite scoring

One score per dimension, normalize, weight in code. Changing a weight does not require a re-ask if the questions are unchanged. Do not hide an "any serious violation" rule inside a weighted sum — that is separate nouls.

Intent routing

Cheap choice (+ optional complexity score) in front of handlers: deterministic code, specialist LLM, or human. Invoke expensive resources only on the branches that need them.

Cookbook map

Live index: docs.typesafe.ai cookbooks. Use the closest cookbook before inventing a classifier.

NeedCookbook
Batch many questions over one documentparallel_questions
Rerank retrieved passagesrerank_typesafe
Search line IDs in a long docsemantic_find
Recover lost markdown structureautoformat
Map NL to typed function + argsfunction_calling
Pick at most one skill for a turnskill_suggestion
Same-entity vs related vs distinctentity_alignment
Filter RAG passages (incl. injection)classifying_rag_passages
Citation support vs sourcecitation_check
In/out LLM guardrailsllm_guardrails
Extract then verify then reasonsde_cascade
Dates: extract parts, compare in codedate_extraction_cookbook
Regex candidates, Jev selects spanpre_parsed_value_extraction_cookbook
Deep taxonomy / beam searchhierarchical_classification
Propose features, fit classical MLautoresearch_feature_discovery
Broaden label when confidence is lowclassification_using_confidence
Uncertain noul → human, keep raw valueconsistency_noul_cookbook
Uncertain choice → abstainconsistency_choice_cookbook

Select, don't generate: find candidates in code, ask Jev to pick, copy the verbatim value. Keep questions and thresholds in one file so a human can review them.

Official: patterns · how to build