Skip to main content

LangChain Integration

Add deterministic governance to your LangChain agents with a single middleware. Policy enforcement, PII detection, prompt injection blocking, cost limits, tool authorization, secret scanning, circuit breakers, and structured audit evidence — no LLM in the governance path.
Package: langchain-tealtiger on PyPI
License: Apache 2.0
Latency: Under 5ms per evaluation
Source: GitHub

Installation

This installs the full TealTiger governance engine as a dependency — all capabilities are available through the middleware.

Quick Start

Every tool call, model input, and model output now flows through deterministic governance evaluation.

Multi-Stage Defense

TealTiger doesn’t just govern tool calls — it protects at every stage of the agent lifecycle automatically:
All stages activate from a single middleware instance — no per-stage configuration needed.
Learn more about the multi-stage defense architecture in the concepts guide.

Governance Capabilities

PII Detection

Scans inputs, outputs, and tool arguments for 40+ PII patterns in under 2ms:
Detected patterns include: SSN, credit card numbers, IBAN, phone numbers, email addresses, IP addresses, AWS keys, passport numbers, driver’s license, dates of birth, and 30+ more. Each detection includes a confidence score (0.0–1.0).

Prompt Injection Detection

Deterministic pattern matching for common injection attacks — no LLM needed:
Catches: instruction override attempts, role manipulation, jailbreak patterns, system prompt extraction, and context manipulation.

Secret Scanning

Detects leaked secrets and credentials in model inputs/outputs:

Tool Authorization

Fine-grained control over what tools agents can use and how:

Cost Governance

Hard budget enforcement — not just alerts after the fact:
Cost is tracked per-model using real token pricing. When budget is exhausted, further calls are blocked.

Rate Limiting

Prevent runaway agents from exhausting resources:

Circuit Breaker

Automatic failure protection — stop calling broken tools/models:

Content Moderation

Classify and filter content by category:

Governance Modes

Governance Evidence & Audit Trail

Every governance decision produces a structured Decision Contract:

Evidence Export

Export for compliance teams:

OpenTelemetry Integration

Governance decisions propagate as OTel spans with the agent’s trace context:
Span attributes:
  • tealtiger.action: ALLOW / DENY / REDACT
  • tealtiger.risk_score: 0–100
  • tealtiger.reason_code: policy violation code
  • tealtiger.evaluation_ms: governance latency

Use with LangGraph

Works seamlessly in multi-agent LangGraph workflows:
Governance decisions are visible in LangSmith traces and respect LangGraph checkpointing.

Complete Example: Compliant Research Agent

OWASP AI Security Coverage

TealTiger addresses 7/10 OWASP Agentic Security Issues through the LangChain middleware:

Key Properties

Troubleshooting

Check your governance mode. In MONITOR mode, violations are logged but not blocked:
Ensure you’re using the middleware parameter when creating the agent:
Verify cost policies use "action": "BLOCK" (not "FLAG"):

Next Steps

Multi-Stage Defense

Understand how governance runs at every lifecycle stage

Governance Domains

Explore the 10 governance domains

Policy Reference

Full policy configuration reference

LangGraph Guide

Advanced multi-agent governance with LangGraph