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"}]})

app.stream and app.astream run the whole graph, check the final answer, then yield the chunks, with redactions applied or a single refusal in their place. They accept stream_mode "values" or "updates", alone or as a list, and subgraphs=True. Token streaming ("messages") and "custom" raise ValueError, because those chunks would reach the caller before the output check.

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 before it runs, without a Jev call. It applies whether or not tool_call is listed in stages.

When pii or secrets is enabled, a local scanner masks the emails, SSNs, card numbers, API keys, and private keys it recognizes on every pass, whatever Jev scores. Jev covers what a pattern cannot see. If Jev flags PII or a secret and the scanner finds no span to mask, 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.1

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.1
File Size Uploaded Provenance Actions
jevrail-0.1.1.tar.gz 19.4 kB Without provenance Details for jevrail-0.1.1.tar.gz

Built distribution (wheel)

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

Total release size: 37.2 kB

Release files / jevrail-0.1.1.tar.gz

Download URL jevrail-0.1.1.tar.gz
Size 19.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d40d27cc2e2e32bad5b7e502af6afce0a7cdaf641605c4970659594b2ffea47f
BLAKE2b-256 checksum
How to use checksums
63399dbddd2a21c47e07d367e989ac27c52e995fdd1320ffc9fd2febc07455ab
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.1-py3-none-any.whl

Download URL jevrail-0.1.1-py3-none-any.whl
Size 17.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0012627ae46b45a3fe45e6ed073895cd5610f250abe736dc0e6c1be0a46d2e78
BLAKE2b-256 checksum
How to use checksums
16cb735febba11bb24f026f3c0eb3f28581e092afbd4a414567911e021d8d9f3
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.1

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.1 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