TealTiger governance callback handler for LlamaIndex — deterministic policy enforcement, cost tracking, and audit for RAG pipelines
Project description
llamaindex-tealtiger
Deterministic governance callback handler for LlamaIndex — policy enforcement, cost tracking, PII detection, and structured audit for RAG pipelines. No LLM in the governance path.
Install
pip install llamaindex-tealtiger
Zero-Config Quickstart (3 lines)
from llama_index.core import Settings
from llamaindex_tealtiger import TealTigerCallback
Settings.callback_manager.add_handler(TealTigerCallback())
That's it. Every LLM call, retriever fetch, and tool invocation is now logged with cost tracking and PII detection — nothing is blocked.
Enforce Mode — Block Policy Violations
from llama_index.core import Settings
from llamaindex_tealtiger import TealTigerCallback, GovernanceDenyError
handler = TealTigerCallback(
mode="ENFORCE",
policies=[
{"type": "tool_allowlist", "tools": ["search", "calculator"]},
],
budget=5.00, # USD session limit
agent_id="rag-pipeline-prod",
)
Settings.callback_manager.add_handler(handler)
# Any tool not in the allowlist raises GovernanceDenyError
# before the tool executes — no wasted compute.
try:
index.as_query_engine().query("Run dangerous_tool now")
except GovernanceDenyError as e:
print(f"Blocked: {e.decision['reason']}")
print(f"Codes: {e.decision['reason_codes']}")
Use with TealEngine (Advanced Policies)
from tealtiger.core.engine import TealEngine
from llamaindex_tealtiger import TealTigerCallback
engine = TealEngine(policies=[...])
handler = TealTigerCallback(
mode="ENFORCE",
engine=engine,
budget=10.00,
)
Features
| Feature | Description |
|---|---|
| Three Modes | OBSERVE (log only), MONITOR (log + warn), ENFORCE (log + block) |
| Cost Tracking | Per-request and session-level cost accumulation using TealTiger pricing |
| Budget Limits | Session-level USD budget with automatic DENY on breach |
| PII Detection | Email, phone, SSN, credit card, IP address patterns |
| Secret Detection | API keys, tokens, Bearer headers, AWS keys, GitHub PATs |
| Params Hashing | SHA-256 digest of JCS-canonicalized args for reproducibility |
| Policy Engine | Built-in allowlist/blocklist or plug in TealEngine for advanced rules |
| Fail Closed | Policy timeouts and errors always result in DENY |
| Audit Trail | Full decision history with correlation IDs and proposed_call_id |
| OpenTelemetry | Automatic trace_id capture when OTel is available |
| Adapter Source | Every event tagged with adapter_source: llamaindex-tealtiger |
Governance Modes
| Mode | Behavior |
|---|---|
OBSERVE |
Allow all, log decisions, track cost (default) |
MONITOR |
Allow all, log denials as warnings |
ENFORCE |
Block denied actions, raise GovernanceDenyError |
Session Report
report = handler.report()
# {
# "session_id": "...",
# "mode": "ENFORCE",
# "total_evaluations": 42,
# "allowed": 40,
# "denied": 2,
# "total_cost_usd": 0.0847,
# "budget_usd": 5.00,
# "pii_findings_total": 3,
# "secrets_detected_total": 1,
# }
Requirements
- Python ≥ 3.9
llama-index-core >= 0.11.0tealtiger >= 1.3.0
Links
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 llamaindex_tealtiger-0.1.0.tar.gz.
File metadata
- Download URL: llamaindex_tealtiger-0.1.0.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3de16881085e65499899aaa0c9efde699ba838f21a7d183a6c8c487eb849f6b
|
|
| MD5 |
b6177a2c79c6ad1a1a6c1462cbe40b3f
|
|
| BLAKE2b-256 |
ffaa1e23a05bc20bac60cd859889810d6b4ffffc3457f6e1991bd69721a43eba
|
File details
Details for the file llamaindex_tealtiger-0.1.0-py3-none-any.whl.
File metadata
- Download URL: llamaindex_tealtiger-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69aabf8ebefef877b42a8392e8790f8c5b3e09019039671b61b2d9ea3b2e67f9
|
|
| MD5 |
049ff8070f5d2f0461b52ad85cc69f07
|
|
| BLAKE2b-256 |
7267c90ce57676fe1895f0304f2a0e55e655b0b5e51c7bb82f6f18664940557d
|