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.
| Need | Cookbook |
|---|---|
| Batch many questions over one document | parallel_questions |
| Rerank retrieved passages | rerank_typesafe |
| Search line IDs in a long doc | semantic_find |
| Recover lost markdown structure | autoformat |
| Map NL to typed function + args | function_calling |
| Pick at most one skill for a turn | skill_suggestion |
| Same-entity vs related vs distinct | entity_alignment |
| Filter RAG passages (incl. injection) | classifying_rag_passages |
| Citation support vs source | citation_check |
| In/out LLM guardrails | llm_guardrails |
| Extract then verify then reason | sde_cascade |
| Dates: extract parts, compare in code | date_extraction_cookbook |
| Regex candidates, Jev selects span | pre_parsed_value_extraction_cookbook |
| Deep taxonomy / beam search | hierarchical_classification |
| Propose features, fit classical ML | autoresearch_feature_discovery |
| Broaden label when confidence is low | classification_using_confidence |
| Uncertain noul → human, keep raw value | consistency_noul_cookbook |
| Uncertain choice → abstain | consistency_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