Skip to main content

jevrail

Input and output guardrails for LangGraph agents. Jev scores each check and returns a probability. jevrail applies your thresholds and decides whether to allow, block, redact, or flag.

Jev does not write the refusal. One call per stage asks every enabled check.

Install

pip install jevrail
pip install "jevrail[langgraph,typesafe]"

Set TYPESAFE_API_KEY before a live agent runs. Tests and the decision engine accept a stand-in classifier, so the package does not call TypeSafe unless you use the default one.

Place the guard where you need it

Checks you leave out do not run. The default policy guards user input and the model answer. Tool calls and tool results stay off until you list them.

from jevrail import GuardPolicy, JevRail, guard

policy = GuardPolicy(
    stages={
        "input": ["prompt_injection", "jailbreak", "content_safety"],
        "output": ["content_safety", "pii", "secrets", "system_prompt_leak"],
        # "tool_call": ["excessive_agency"],
        # "tool_result": ["indirect_injection"],
    },
    thresholds={"prompt_injection": 0.7, "pii": 0.8},
    actions={"pii": "redact", "prompt_injection": "block"},
    on_block="refuse",   # refuse | raise
    fail_mode="closed",  # closed | open
)

create_agent middleware:

from langchain.agents import create_agent

agent = create_agent(model, tools=tools, middleware=[JevRail(policy)])

A compiled graph, checked on the way in and on the way out:

app = guard(compiled, policy)
app.invoke({"messages": [{"role": "user", "content": "Hello"}]})

A custom graph, on the edges you choose:

from jevrail import input_guard, output_guard

graph.add_node("input_guard", input_guard(policy))
graph.add_node("output_guard", output_guard(policy))

import jevrail.auto is optional. It patches create_agent and messages-based StateGraph.compile using JEVRAIL_POLICY when that variable points at a YAML file. Import it before you build the agent.

What each stage can check

Check Typical stage Action
prompt_injection input, tool result block
jailbreak input block
content_safety input, output block
system_prompt_extraction input block
system_prompt_leak output block
pii output redact
secrets output redact
data_exfiltration output block
excessive_agency tool call block
indirect_injection tool result block
topic_scope input or output, with allowed_topics block

denied_tools blocks a tool by name on the tool-call stage without a Jev call.

Emails, SSNs, card numbers, API keys, and private keys are masked by a local scanner. Jev says a secret is present. The scanner finds the span. If Jev flags PII or a secret and the scanner finds no span, the action becomes a block.

If the TypeSafe API fails, fail_mode="closed" blocks the turn. fail_mode="open" lets it through.

Publish

Do not create an empty project on PyPI. The name is claimed by the first upload.

  1. Register at pypi.org and test.pypi.org and turn on 2FA.
  2. uv build or python -m build.
  3. twine upload --repository testpypi dist/* and install it in a clean virtualenv.
  4. twine upload dist/* to create the jevrail project.

Development

pip install -e ".[dev,typesafe]"
pytest

Metadata

Release files for jevrail 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jevrail 0.1.0
File Size Uploaded Provenance Actions
jevrail-0.1.0.tar.gz 16.3 kB Without provenance Details for jevrail-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for jevrail 0.1.0
File Interpreter ABI Platform Actions
jevrail-0.1.0-py3-none-any.whl Python 3 none any Details for jevrail-0.1.0-py3-none-any.whl

Total release size: 32.9 kB

Release files / jevrail-0.1.0.tar.gz

Download URL jevrail-0.1.0.tar.gz
Size 16.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d0a044fd2a71c37804b5868e3950360c47e6a0be269d12b35c809eb56ff0cf54
BLAKE2b-256 checksum
How to use checksums
1474c881611f4da80e197f1aa8541dc412697866a9fb288560879ed0d32c46d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / jevrail-0.1.0-py3-none-any.whl

Download URL jevrail-0.1.0-py3-none-any.whl
Size 16.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
91aabf722b3da92f89685d65c8922a56b4ca633e4dd087d9eff44716aa9ef67d
BLAKE2b-256 checksum
How to use checksums
04f49f9529ace83048b73413411b97cb724d2cae72930df8b68a20a560006f7a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Security for jevrail 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page