Infrastructure
Shift every LLM call to the cheapest model that can handle it. Routing decided by TypeSafe Jev in ~180 ms. No training data. Policy in plain YAML. TypeScript and Python.
import { TypeSafeClient } from "@typesafe-ai/sdk";The link points at the commit we read, so the line number still holds.
These question sets are lifted from this project's source exactly as written.
from python/tiershift/signals.py:17
difficultyscoreHow hard is it to answer `request.user_message` well? Consider `request.system_prompt` and `request.step` for context.
0 — trivial: a lookup, a formatting change, an acknowledgement, or a one-line reply1 — moderate: needs domain knowledge or a few reasoning steps; a competent generalist can do it2 — hard: needs deep expertise, long multi-step reasoning, careful trade-off analysis, or novel designneeds_reasoningtrue/falseDoes `request.user_message` require multi-step logical reasoning, proof, debugging, or planning rather than recall, rewriting, or formatting?
stakesscoreHow costly is a wrong or low-quality answer to `request.user_message` for the user?
0 — low: easy to spot and redo; no external consequence1 — medium: wastes real time or money if wrong; affects work product2 — high: legal, financial, medical, safety, security, or production-system impactdomainchoiceWhich domain does `request.user_message` belong to?
code — writing, debugging, reviewing, or explaining softwaremath_logic — mathematics, proofs, formal logic, puzzleswriting — prose, tone, editing, summarizing, translationarchitecture — system design, infrastructure, migrations, planninglegal_finance — contracts, compliance, money, taxdata — data analysis, SQL, spreadsheets, statisticsgeneral — general knowledge, conversation, simple questionshas_codetrue/falseDoes `request.user_message` contain code or ask for code to be written, fixed, or reviewed?
ambiguoustrue/falseIs `request.user_message` missing information that an expert would need before answering well?
output_lengthscoreHow long should a good answer to `request.user_message` be?
0 — one line or a single value1 — one to three paragraphs or a short code snippet2 — a long document, a detailed plan, or multi-file codecreativetrue/falseDoes `request.user_message` ask for creative or stylistic writing rather than factual or technical output?
import { experimental_evaluate as evaluate } from 'ai';
const { answers } = await evaluate({
model: 'typesafe-ai/jev',
state,
questions: {
difficulty: { type: 'score', instructions: 'How hard is it to answer `request.user_message` well? Consider `request.system_prompt` and `request.step` for context.',
criteria: ['trivial: a lookup, a formatting change, an acknowledgement, or a one-line reply', 'moderate: needs domain knowledge or a few reasoning steps; a competent generalist can do it', 'hard: needs deep expertise, long multi-step reasoning, careful trade-off analysis, or novel design'] },
needs_reasoning: { type: 'boolean', instructions: 'Does `request.user_message` require multi-step logical reasoning, proof, debugging, or planning rather than recall, rewriting, or formatting?' },
stakes: { type: 'score', instructions: 'How costly is a wrong or low-quality answer to `request.user_message` for the user?',
criteria: ['low: easy to spot and redo; no external consequence', 'medium: wastes real time or money if wrong; affects work product', 'high: legal, financial, medical, safety, security, or production-system impact'] },
domain: { type: 'choice', instructions: 'Which domain does `request.user_message` belong to?',
criteria: { code: 'writing, debugging, reviewing, or explaining software', math_logic: 'mathematics, proofs, formal logic, puzzles', writing: 'prose, tone, editing, summarizing, translation', architecture: 'system design, infrastructure, migrations, planning', legal_finance: 'contracts, compliance, money, tax', data: 'data analysis, SQL, spreadsheets, statistics', general: 'general knowledge, conversation, simple questions' } },
has_code: { type: 'boolean', instructions: 'Does `request.user_message` contain code or ask for code to be written, fixed, or reviewed?' },
ambiguous: { type: 'boolean', instructions: 'Is `request.user_message` missing information that an expert would need before answering well?' },
output_length: { type: 'score', instructions: 'How long should a good answer to `request.user_message` be?',
criteria: ['one line or a single value', 'one to three paragraphs or a short code snippet', 'a long document, a detailed plan, or multi-file code'] },
creative: { type: 'boolean', instructions: 'Does `request.user_message` ask for creative or stylistic writing rather than factual or technical output?' },
},
});from python/tiershift/signals.py:154
addressestrue/falsequestion
import { experimental_evaluate as evaluate } from 'ai';
const { answers } = await evaluate({
model: 'typesafe-ai/jev',
state,
questions: {
addresses: { type: 'boolean', instructions: 'question' },
},
});from src/signals.ts:132
addressestrue/falseDoes `answer` fully and correctly address `request`?
import { experimental_evaluate as evaluate } from 'ai';
const { answers } = await evaluate({
model: 'typesafe-ai/jev',
state,
questions: {
addresses: { type: 'boolean', instructions: 'Does `answer` fully and correctly address `request`?' },
},
});