Thin LangChain adapter for PFC execution-boundary decisions
Project description
pfc-langchain
pfc-langchain is a thin execution-boundary wrapper for LangChain-style tools.
It asks PFC for a decision before the wrapped callable runs, then returns the tool
result together with PFC decision metadata.
What It Does
- Wraps a callable tool with a PFC pre-execution decision
- Preserves a simple callable interface
- Returns the tool result, decision id, and receipt hash in one response
Install
From this monorepo:
pip install -e ./packages/pfc_core
pip install -e ./packages/pfc_langchain
Quick Start
from pfc_langchain import GovernedTool
class EchoTool:
name = "echo"
description = "Return the provided value"
def __call__(self, value):
return {"echo": value}
tool = GovernedTool(
EchoTool(),
policy_id="policy-123",
pfc_api_key="pfc_test_key",
)
result = tool(value="hello")
print(result)
How It Works
GovernedToolbuilds a PFC execution payload from the wrapped tool call.- It sends that payload to PFC before the tool executes.
- If PFC allows the action, the tool runs and the wrapper returns
result,decision_id, andreceipt. - If PFC blocks the action, the wrapped tool is not executed.
Failure Behavior
- If the wrapped object is not callable,
GovernedToolraisesTypeError. - If PFC returns a blocking decision,
pfc_core.middleware.PFCBlockedErroris raised. - If the PFC API request fails, the underlying PFC client raises an exception.
Limitations
- This package is intentionally thin and does not manage prompts, chains, or policies.
- It treats the wrapped object as a generic callable rather than depending on specific LangChain internals.
- Positional arguments are represented in the PFC payload under an
argslist.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pfc_langchain-0.1.0.tar.gz
(2.2 kB
view details)
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 pfc_langchain-0.1.0.tar.gz.
File metadata
- Download URL: pfc_langchain-0.1.0.tar.gz
- Upload date:
- Size: 2.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.3 CPython/3.14.3 Darwin/25.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96f786c6f5913524337096e532f236ed057d9a8cfc7a550bd203e5912284b937
|
|
| MD5 |
66c7d6a66fe8f0521e0f98d93de0aa3b
|
|
| BLAKE2b-256 |
4cbe98974544df06a56a51fd78ac709e2dbb55b0e1ecd242fe8f68fa89b61cd8
|
File details
Details for the file pfc_langchain-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pfc_langchain-0.1.0-py3-none-any.whl
- Upload date:
- Size: 2.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.3 CPython/3.14.3 Darwin/25.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b823d56a4f5a31f9ce85a596b144cf7f02786fd01036f3fd62c51069e2fc33a1
|
|
| MD5 |
c2cbd0eb25382565775198f9a38aff4a
|
|
| BLAKE2b-256 |
c0d3a11c8f4a4a77747f317c358c8c509a9fd45dc348b62be9c4d85ccdd9a4a3
|