Skip to main content
FitForJev

Blog · 12 min

Copy these three setups: router, guardrail, reranker

Three cookbook setups with Jev 1.13 code you can copy: tool router, parallel guardrails, RAG reranker.

cookbooksrouterguardrailsRAG

Three setups handle most production Jev work. The source is the systemonemodels.org cookbooks. You give Jev the judgment and keep the decision in code. You call an LLM when prose is the product. You start each setup from a different question type and threshold.

1. Tool router (Choice first). Model each tool as a closed-set Choice option. You register up to 182 tools; the question type caps at 255. Add a tool_needed Noul that routes to none_of_above. You filter by policy before selection and check confidence and approval gates after. You pause low-confidence or high-impact paths for confirmation. You keep free-form and numeric arguments outside Jev and validate them against JSON schema in code. You re-check authorization and side effects before execution.

2. Guardrails (parallel Nouls). Run jailbreak-attempt, sensitive-data, and policy-violation Nouls plus a harm Score over inbound prompts and proposed tool calls in one parallel pass. Convert results into deterministic allow, review, and block rules. Jev 1.13 trusts state by default, so you wrap user text in a typed key and scope instructions to that key. You strip injection triggers before evaluation, such as <system>, [INST], and "ignore previous".

3. RAG reranker (Score first). Retrieve a broad first-stage set of passages for retrieval-augmented generation. Score each passage for relevance and answer support. Score contradiction and injection risk in the same pass. Sort and filter by your thresholds before you hand evidence to the answer model. For example, keep relevance at 2 and above and take the top k. You route passage choice to Jev and answer-writing to the LLM.

The router main path has two checks. You pause low-confidence or high-impact calls at the approval gate. You block violations with post-execution guardrail Nouls and log each block. You reuse the same setup to rerank retrieval passages. Score them, apply the threshold, and take the top k.
// Generated by FitForJev. Agent tool / skill router. Structured criteria by default, Jev 1.13.
// Model: typesafe-ai/jev via Vercel AI Gateway. Auth uses the AI_GATEWAY_API_KEY env var, never a direct key.
import { experimental_evaluate as evaluate } from "ai";

const state = {
  user_request: "", // The raw user request you route to a tool
};

const questions = {
  "selected_tool": {
    "type": "choice",
    "instructions": {
      "question": "Which tool should handle this request? (router supports up to 182 registered tools)",
      "focus": "Inspect ONLY the workflow described in user_request.",
      "inspect": [
        "user_request"
      ],
      "compare": "Compare database_lookup / web_search / code_runner / none_of_above; pick exactly one."
    },
    "criteria": {
      "database_lookup": {
        "what": "You need rows or records from a database",
        "not_for": "Covered by: web_search, code_runner, none_of_above",
        "examples": []
      },
      "web_search": {
        "what": "You need fresh information from the web",
        "not_for": "Covered by: database_lookup, code_runner, none_of_above",
        "examples": []
      },
      "code_runner": {
        "what": "You need computation or data transformation",
        "not_for": "Covered by: database_lookup, web_search, none_of_above",
        "examples": []
      },
      "none_of_above": {
        "what": "No listed tool fits. Answer directly",
        "not_for": "Covered by: database_lookup, web_search, code_runner",
        "examples": []
      }
    }
  },
  "tool_needed": {
    "type": "boolean",
    "instructions": {
      "question": "Does this request need a tool?",
      "focus": "Inspect ONLY the workflow described in user_request.",
      "inspect": [
        "user_request"
      ],
      "compare": "Compare the true case against the false case and return P(true)."
    },
    "criteria": {
      "true": {
        "what": "Does this request need a tool?",
        "examples": []
      },
      "false": {
        "what": "The statement above does not hold for this input.",
        "examples": []
      }
    }
  }
};

export async function evaluateToolRouter(input: Record<string, string>) {
  return evaluate({
    model: "typesafe-ai/jev",
    state: { ...state, ...input },
    questions,
  });
}

You get structured criteria by default. Choice {what, not_for, examples}, Score{summary, signals}, Noul {true, false}. You call `typesafe-ai/jev` through the Vercel AI Gateway. You load the key from `AI_GATEWAY_API_KEY` and keep it out of source. The guard is if (!tool_needed) answerDirectly(); else callTool(selected_tool);

The snippets default to structured criteria in Jev 1.13. Choice options use {what, not_for, examples}, Score levels use {summary, signals}, and Noul uses {true, false} with contrastive compare instructions. Flat strings also work. You separate close options with contrastive definitions. Copy the TypeScript for the Gateway path or the Python for a direct POST with AI_GATEWAY_API_KEY. Open it pre-filled in the TypeSafe Playground and tune thresholds against real distributions.

Economics · live

100ms vs 2,500ms (25x) · $0.004 vs $0.50 per 100k

Jev
$0.040
Frontier LLM
$5.00
Saved / mo
$4.96

$0.042 per 1M input tokens, output free. About 100ms against about 2,500ms. At 100k requests per month the reference build saves about $5.95 per year. Vendors claim up to 100 times faster. Treat the headline 193 times and 444 times figures as company numbers and test them against your workload.

Try it on your own problem.

Paste the fuzzy version and get a verdict: Jev answers the typed questions, your code computes the fit.

Evaluate your problem