Skip to content

pydantic-jev-examples

Small one-file Pydantic AI examples where Jev guards prompts, gates shell commands, judges evals and plays Flappy Bird.

Appprototype

Overview

pydantic-jev-examples is a set of small runnable demos showing where a Jev call fits into a Pydantic AI run. The README explains Jev plainly: you send any JSON state and one question with a fixed answer shape (yes/no or pick one) and get back a probability, cheaply enough to ask on every prompt, tool call or game tick.

Each example plugs Jev into a harness hook: an InputGuardrail that declines harmful prompts before the model is called, a ToolGuardrail that decides whether a shell command runs, is blocked, or waits for a human, a Pydantic Evals evaluator that returns pass/fail against a rubric, and a Flappy Bird loop where Jev decides whether to flap each tick while Claude coaches between rounds. The guard functions are short and meant to be copied into your own project; the question text is the program.

What the decision model decides

TypeQuestionAnswers
Yes / noDoes this ask a coding agent to destroy data or leak secrets?—
ChoiceShould this command run, be blocked, or wait for a human?run · reject · ask a human
Yes / noDoes this eval case pass the rubric?—
Yes / noShould the bird flap on this tick?—

How it works

  1. Pick a hook in the Pydantic AI run (before model request, before tool execute, after run)
  2. Ask Jev one typed question about the prompt, command or output
  3. Compare the probability to a threshold (0.75 in the input guard)
  4. Skip the model call, block or defer the tool, or send output back for revision

Strengths

  • Declined prompts never reach the paid model
  • Calls take a few hundred milliseconds per the README, cheap enough for every step
  • Guards are short, copyable functions

Caveats

  • Examples, not a library; no licence stated
  • Most examples also need an Anthropic key

Getting started

git clone https://github.com/adtyavrdhn/pydantic-jev-examples && cd pydantic-jev-examples/<example>, export TYPESAFE_API_KEY, then run the example.

At a glance

Type
App
Status
prototype
Language
Python
Runtime
Pydantic AI scripts
Has code
yes

Use cases and integrations

How curated lists describe it

Frequently asked questions

What does Jev decide in these examples?

Whether a prompt is harmful, whether a shell command should run, whether an eval case passes, and whether a game bird flaps.

How is this different from using an LLM guard?

Jev returns a probability instead of text, so the guard is a threshold check and adds little latency or cost.

Which keys do I need?

TYPESAFE_API_KEY for all; shell_guard and flappy_bird also use Anthropic (flappy_bird has an --offline mode).

Related projects

  • Example of Jev as a before-tool-call risk gate in a Google ADK agent, blocking tools when P(risky) passes a threshold.

    ProjectprototypePython
  • OpenRouter cookbook recipe gating agent tool calls with deterministic checks plus Jev Noul probabilities and fixed thresholds.

    Articleproduction
  • Auditable Zig terminal agent pairing Codex for coding with Jev typed preflight and postflight checks under deterministic policy gates.

    CLIproductionZig
  • Gateway that checks agent tool calls with policy plus Jev evidence, then binds approval to a single-use permit for that exact action.

    MCP serverbetaTypeScript
  • MCP proxy and hooks that screen agent tool calls before they run and their results before the agent reads them, using Jev judgments.

    MCP serverbetaTypeScript
  • Xano backend template where Jev judges each agent tool call as safe, needs review or dangerous, and uncertain calls wait for a human.

    ProjectbetaXanoScript