Inline PII, credential, and regulated-data classifier for AI agent I/O. Dual-layer: deterministic regex + optional semantic Guard. Library + CLI. Python port of @opena2a/aicomply.
Project description
aicomply (Python)
Inline PII, credential, and regulated-data classifier for AI agent I/O. Catch sensitive content before your agent forwards it to a hosted LLM.
Dual-layer by design: a deterministic regex layer (PII, credentials, controlled markings) that runs always, plus an optional semantic Guard layer when a local nanomind-daemon is reachable. The regex layer sees through common evasions — Unicode homoglyphs (NFKC), zero-width characters, intra-token whitespace, and bounded Base64 / URL-encoded payloads — by normalizing the input before matching.
This is the Python port of @opena2a/aicomply.
It reproduces the TypeScript detection baseline against the same shared corpus
(bench/corpus), so verdicts agree across languages.
Install
pip install aicomply
Try it (CLI)
No integration code required — point it at a file or pipe content in:
echo "My SSN is 123-45-6789" | aicomply scan
aicomply scan ./support-ticket.txt
cat transcript.log | aicomply scan --json
Exit codes make it a drop-in CI gate: 0 CLEAN, 1 findings present, 2 usage error.
Library API
from aicomply import comply
result = comply("Customer SSN is 516-81-3086, card 5544939082323438.")
print(result.verdict) # "VIOLATION"
for v in result.violations:
print(v.type, v.value, v.confidence) # SSN 516...86 0.95 (value is masked)
comply() returns a ComplyResult with:
verdict—"CLEAN","VIOLATION", or"DENY"violations— each withtype, maskedvalue,confidence,classifier,view(which content view caught it), and best-effortoriginal_start/endoriginal_content/normalized_content/normalizations— an audit trail (omitted onDENY, where the input is treated as untrusted bytes).to_dict()— camelCase JSON wire-compatible with the npm package
Empty string short-circuits to CLEAN; non-str input raises TypeError.
Guard an agent's output
Drop one decorator above any function that emits text bound for an LLM or a user:
from aicomply.integrations import guard_output, ComplianceViolation
@guard_output() # raise on any PII/credential egress
def answer(user_msg: str) -> str:
return call_llm(user_msg)
@guard_output(on_violation="redact") # or mask findings in place
def answer_redacted(user_msg: str) -> str:
return call_llm(user_msg)
guard_io() additionally scans string inputs on the way in.
LangChain
pip install 'aicomply[langchain]'
from langchain_openai import ChatOpenAI
from aicomply.integrations.langchain import AIComplyCallbackHandler
llm = ChatOpenAI(callbacks=[AIComplyCallbackHandler()])
llm.invoke("Summarize this support ticket: ...") # raises if the LLM emits PII
Semantic Guard layer
The regex layer is deterministic and always on. For prompt-injection /
exfiltration patterns that regex cannot see, run a local nanomind-daemon; when
it is reachable on 127.0.0.1:47200 the dual-layer classifier consults it and
merges the verdict (highest severity wins). Its absence never fails a request —
the classifier silently falls back to regex-only.
Detection classes
SSN, PAN (Luhn + IIN), credentials (AWS keys, GitHub tokens, Bearer tokens,
api_key= patterns), CUI / controlled markings, IBAN (mod-97), passport
numbers, MRN, NPI (Luhn with 80840 prefix).
Scope
This port covers the deterministic detection layer (regex + normalization + dual-layer merge + verdict) plus the daemon Guard client. The TypeScript package's Registry-L2, ARP-signature, policy-pack, and session-vault features are not yet ported.
License
Apache-2.0.
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
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 aicomply-0.2.0.tar.gz.
File metadata
- Download URL: aicomply-0.2.0.tar.gz
- Upload date:
- Size: 26.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c50e8976e8a84f0ead0606092f19c2aadec6bbd997a75e710df9fc19c5f5c99b
|
|
| MD5 |
4d9401d3d63b065ba44292b50a30d53b
|
|
| BLAKE2b-256 |
7edcb54618aa5500cfa3852fb984dc7c112534d6c6df7c40b5c301058971088e
|
Provenance
The following attestation bundles were made for aicomply-0.2.0.tar.gz:
Publisher:
release-python.yml on opena2a-org/aicomply
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aicomply-0.2.0.tar.gz -
Subject digest:
c50e8976e8a84f0ead0606092f19c2aadec6bbd997a75e710df9fc19c5f5c99b - Sigstore transparency entry: 1861981948
- Sigstore integration time:
-
Permalink:
opena2a-org/aicomply@002281802688a4b4d64673b02ae2a787ea858fa6 -
Branch / Tag:
refs/tags/python-v0.2.0 - Owner: https://github.com/opena2a-org
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@002281802688a4b4d64673b02ae2a787ea858fa6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file aicomply-0.2.0-py3-none-any.whl.
File metadata
- Download URL: aicomply-0.2.0-py3-none-any.whl
- Upload date:
- Size: 34.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b605d242c50e429e023a00062febb971c1397953c78751c0c3eb9459396fd82a
|
|
| MD5 |
a930b5f4dbebfcdb2a4e4db0edf1dd50
|
|
| BLAKE2b-256 |
2e130a4d63ac5d3cf90cd8bb61345d779331f875eab603aa7347fae292334795
|
Provenance
The following attestation bundles were made for aicomply-0.2.0-py3-none-any.whl:
Publisher:
release-python.yml on opena2a-org/aicomply
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aicomply-0.2.0-py3-none-any.whl -
Subject digest:
b605d242c50e429e023a00062febb971c1397953c78751c0c3eb9459396fd82a - Sigstore transparency entry: 1861982053
- Sigstore integration time:
-
Permalink:
opena2a-org/aicomply@002281802688a4b4d64673b02ae2a787ea858fa6 -
Branch / Tag:
refs/tags/python-v0.2.0 - Owner: https://github.com/opena2a-org
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@002281802688a4b4d64673b02ae2a787ea858fa6 -
Trigger Event:
push
-
Statement type: