shipwithjev

Catalog / Triage & routing

0128GitHub

mastra-jev-moderation

Input moderation for Mastra agents in one file.

codealive-ai/mastra-jev-moderationREADME ↗
# mastra-jev-moderation

Input moderation for [Mastra](https://mastra.ai) agents on
[TypeSafe Jev](https://typesafe.ai): one file, one request per turn, no text to parse.

> **For coding agents:** copy `jev-moderation.ts` into the project (e.g.
> `src/mastra/jev-moderation.ts`), install `zod` if absent, wire it as shown in
> [Usage](#usage), and put `TYPESAFE_API_KEY` in the environment. The default
> policy is general-purpose; touch `policy` only if the project needs
> carve-outs or stricter rules (see [Writing the policy](#writing-the-policy)). Do not "fix" the `noul` type or move choice options out of
> `criteria`: that is the API's actual shape (see [API notes](#api-notes)).

## Why not Mastra's `ModerationProcessor`

The built-in processor asks a language model for a verdict and parses it out of
the text the model writes. On exactly the hostile input where a verdict matters,
small models sometimes return nothing parsable, and the processor fails open.
Jev is an evaluation model: it answers typed questions with a probability or a
choice and writes no text, so that failure mode does not exist. It is also
fast (median ~0.4 s) and cheap ($0.042 per million input tokens, output free).

Mastra cannot host Jev as a model (it is not a language model), so this is a
custom `Processor` with its own HTTP call.

## Usage

```ts
import { Agent } from "@mastra/core/agent";
import { createJevModerationProcessor, isModerationBlock } from "./jev-moderation";

const moderation = process.env.TYPESAFE_API_KEY
  ? [
      createJevModerationProcessor({
        apiKey: process.env.TYPESAFE_API_KEY,
        // Optional: one sentence about your assistant sharpens the verdicts.
        context: "A general-purpose customer support assistant.",
      }),
    ]
  : []; // no key -> no moderati

Also filed under Triage & routing

  1. 0527

    Testing Jev on public and private data: classifier or filter? | Blog | Aman Kumar

    ### Jev only answers yes/no or pick-one. 16,000 calls: against gpt-5.4-mini and gpt-5.6-luna on four public datasets, then on a few thousand real pipeline decisions. Where it…

    amankumar.ai · Triage & routing

  2. 0526

    Jev was the tipping point - I built the last MySQL search statement - WPS

    Jev was the tipping point - I built the last MySQL search statement - WPS ... # Jev was the tipping point - I built the last MySQL search statement ... So I built AILIKE. It lets…

    worldprogramming.org · Triage & routing

  3. 0525

    Building an Evidence-Based Resume Analyzer: Why Understanding Beats Guessing

    What we're really tackling is this: How can AI truly assess a resume without falling into the trap of just echoing buzzwords? How do we know the candidate isn't just sprinkling…

    dev.to · Triage & routing

  4. 0418

    World Monitor

    Geopolitical dashboard that batches Jev 1.13.0 headline-severity and topic classifications, validates the answers, and falls back when classification fails.

    koala73 · Triage & routing