Infrastructure

tiershift

@iamvatsalpatel2TypeScriptMITupdated 2026-09-18runnable

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.

iamvatsalpatel/tiershift

Where it calls Jev

import { TypeSafeClient } from "@typesafe-ai/sdk";

src/router.ts:2

The link points at the commit we read, so the line number still holds.

What it asks Jev

These question sets are lifted from this project's source exactly as written.

from python/tiershift/signals.py:17

  1. difficultyscore

    How hard is it to answer `request.user_message` well? Consider `request.system_prompt` and `request.step` for context.

    • 0trivial: a lookup, a formatting change, an acknowledgement, or a one-line reply
    • 1moderate: needs domain knowledge or a few reasoning steps; a competent generalist can do it
    • 2hard: needs deep expertise, long multi-step reasoning, careful trade-off analysis, or novel design
  2. needs_reasoningtrue/false

    Does `request.user_message` require multi-step logical reasoning, proof, debugging, or planning rather than recall, rewriting, or formatting?

  3. stakesscore

    How costly is a wrong or low-quality answer to `request.user_message` for the user?

    • 0low: easy to spot and redo; no external consequence
    • 1medium: wastes real time or money if wrong; affects work product
    • 2high: legal, financial, medical, safety, security, or production-system impact
  4. domainchoice

    Which domain does `request.user_message` belong to?

    • codewriting, debugging, reviewing, or explaining software
    • math_logicmathematics, proofs, formal logic, puzzles
    • writingprose, tone, editing, summarizing, translation
    • architecturesystem design, infrastructure, migrations, planning
    • legal_financecontracts, compliance, money, tax
    • datadata analysis, SQL, spreadsheets, statistics
    • generalgeneral knowledge, conversation, simple questions
  5. has_codetrue/false

    Does `request.user_message` contain code or ask for code to be written, fixed, or reviewed?

  6. ambiguoustrue/false

    Is `request.user_message` missing information that an expert would need before answering well?

  7. output_lengthscore

    How long should a good answer to `request.user_message` be?

    • 0one line or a single value
    • 1one to three paragraphs or a short code snippet
    • 2a long document, a detailed plan, or multi-file code
  8. creativetrue/false

    Does `request.user_message` ask for creative or stylistic writing rather than factual or technical output?

Run it on your own text

The code
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

  1. addressestrue/false

    question

Run it on your own text

The code
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

  1. addressestrue/false

    Does `answer` fully and correctly address `request`?

Run it on your own text

The code
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`?' },
  },
});

Other projects in this category