FortifyOS runtime protection for LangChain and LangGraph agents — zero code changes required.
Project description
fortifyos-langchain
Runtime security for LangChain and LangGraph agents — with zero code changes.
fortifyos-langchain auto-attaches the FortifyOS policy engine to every LangChain agent running in your Python environment. It intercepts LLM calls and tool invocations, runs your security policies as plain shell scripts, and allows or blocks the action based on the result.
No imports. No callback wiring. No modifications to your agent code.
Installation
pip install fortifyos-langchain
How It Works
A .pth file shipped with the package is auto-loaded by Python on every interpreter startup, attaching a FortifyHandler globally to LangChain via register_configure_hook. The handler reads ~/.fortifyos/langchain.json to map lifecycle events to shell scripts under ~/.fortifyos/hooks/langchain/.
| Event | Fires when |
|---|---|
pre_llm |
Before an LLM / chat-model call |
post_llm |
After an LLM responds — includes generations, tool_calls, finish_reason, token_usage |
pre_tool |
Before a tool runs |
post_tool |
After a tool returns |
Script exit code 0 allows the action; non-zero blocks it.
What's New In 0.1.1
post_llmpayload now includes the actual model output:generations[].text,generations[].content,generations[].tool_calls(the tools the LLM wants to invoke),generations[].finish_reason,token_usage, andmodel. Useful for inspecting tool calls before they run, detecting content-filter triggers, and tracking token cost.
Disabling Protection
Set FORTIFYOS_DISABLE=1 to skip the auto-attach for a single run.
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fortifyos_langchain-1.1.0.tar.gz.
File metadata
- Download URL: fortifyos_langchain-1.1.0.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e8fe841fabf2ce8035195231effb792ccd415043d3ea0da50d92398dc0aedc5
|
|
| MD5 |
4b85e3579425bcef8d28a05942f3e664
|
|
| BLAKE2b-256 |
e71bab1c5b2571cd412d00235383bb95321207ad417dccde28420b869ae34a87
|
File details
Details for the file fortifyos_langchain-1.1.0-py3-none-any.whl.
File metadata
- Download URL: fortifyos_langchain-1.1.0-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10822a19be8e83044547e62c40ea4d0d583288310c460e9b22d6ff5bf2d35d7d
|
|
| MD5 |
0c21d309161f7c6649e1d2f944c59a43
|
|
| BLAKE2b-256 |
ffd284b7c1f53b10a305c359c71db6747b1394acf92ef7d879332e709341eed3
|