mastra-jev-moderation
One-file Mastra input processor that asks Jev whether a message must be blocked, failing open behind a deadline and circuit breaker.
Overview
mastra-jev-moderation is input moderation for Mastra agents built on Jev: one file, one request per turn, no text to parse. The README explains why it replaces Mastra's built-in ModerationProcessor: that processor asks a language model for a verdict and parses it from text, and on exactly the hostile inputs where a verdict matters, small models sometimes return nothing parsable and the processor fails open. Jev answers typed questions without writing text, so that failure mode does not exist.
Each turn sends the last message's text (up to 8,000 characters) with two questions in one request: a yes/no 'must this be blocked?', which gates at a probability of 0.7, and a category choice used only for logs. Failures (5-second timeout, HTTP error, unparsable answer or an open breaker) fail open with one log line, and a circuit breaker opens for 60 seconds after three consecutive failures. Messages are never logged. A listing reports that in production it blocked 9 of 9 hostile messages and 0 of 49 real ones at about 0.4 s median, roughly four times cheaper than an LLM moderator.
What the decision model decides
| Type | Question | Answers |
|---|---|---|
| Yes / no | Must this message be blocked? | — |
| Choice | What moderation category does this message fall into? (logged only) | — |
How it works
- User message enters the Mastra agent
- Processor sends the text with block and category questions to Jev
- If P(block) >= 0.7, the turn ends with a block tripwire
- On failure or open breaker, the message passes with a log line
- Verdict and token usage go to an optional callback
Strengths
- No parsing failures on hostile input
- Fast and cheap per turn
- Circuit breaker prevents latency during outages
- Messages never logged
Caveats
- Fails open, so outages let messages through
- Judges only the last message
- Small production sample
Getting started
Copy jev-moderation.ts into your Mastra project, install zod, set TYPESAFE_API_KEY and add createJevModerationProcessor to inputProcessors.At a glance
- Type
- Project
- Status
- production
- Language
- TypeScript
- Runtime
- Mastra agent processor
- Has code
- yes
Use cases and integrations
How curated lists describe it
AI assistants: Mastra input processor that asks Jev a `Boolean` "must this message be blocked?" plus a category `Choice` in one request, aborting the turn at 0.7 and failing open behind a deadline and circuit breaker; in production it blocked 9/9 hostile and 0/49 real messages at ~0.4 s median, about 4× cheaper than an LLM moderator.
yibie/awesome-jevInput moderation for Mastra agents on TypeSafe Jev — one file.
hellogumbo/awesome-jev
Frequently asked questions
Why not use Mastra's built-in moderation?
It parses an LLM's text verdict, which can fail on hostile input; Jev returns a typed probability.
What happens if Jev is down?
It fails open, and a circuit breaker avoids adding latency.
What threshold blocks a message?
A block probability of 0.7 or higher, configurable.
Related projects
Text review gateway between clients and AI services that classifies each user input with Jev and blocks or logs per configured scenarios.
LibrarybetaGoCline's official curated plugin collection, which includes jev-browser, jev-guard and jev-playground plugins.
PluginproductionTypeScriptPython/TypeScript/Go chatbot safety library checking user input and bot replies with Jev and returning one actionable verdict per message.
LibraryproductionPythonWordPress plugin connecting sites to Jev, with PHP helpers for choice, score and yes/no decisions plus a REST proxy and JS client.
ProjectbetaPHPOpen-source agent guardrails that use Jev or LAYA to check prompts, retrieved content, tool calls and outputs for injection and risk.
ProjectbetaPythonGateway admission control that asks Jev what each incoming request is trying to do, filtering prompt injection and abuse.
AppbetaLua