Skip to main content

voice-ai-governance

Compliance enforcement middleware for voice and SMS AI pipelines.

PyPI version Python 3.9+ License: MIT Coverage CI

Warm transfer state management, confidence-gated escalation, PII scrubbing, TCPA/A2P 10DLC SMS compliance, and HIPAA/FERPA/EU AI Act enforcement for voice and SMS AI systems built on Pipecat, LiveKit, Twilio ConversationRelay, Twilio Programmable Messaging, and any WebRTC-based voice AI platform.


What it does and when to use it

This Python library helps voice and messaging application developers carry conversation context into a human handoff, redact configured personal-data patterns, and apply consent and escalation checks. Use it when your application already handles calls or messages and needs reusable checks around those events. Find published releases on PyPI and changes in the changelog.

For example, a support caller may need a human after an uncertain answer. Your application records turns through the state manager, evaluates whether to escalate, builds a scrubbed handoff payload, and passes it to its contact-center integration. The receiving agent gets context without requiring the caller to repeat the entire conversation.

Start with the warm-transfer example below, then the voice-session example. The state manager, async state manager, and PII scrubber contain the implementation-level API details. The project guide explains how this package fits with the other libraries.

Integration and runtime limits

Your application owns authentication, telephony sessions, provider credentials, routing, and confirmation that a human accepted the transfer. An adapter builds or sends integration-specific data; a successful payload build is not proof of a completed call transfer. The included adapters are starting points to test against your installed SDK and provider configuration. The LiveKit publication boundary is qualified against installed SDKs as documented in the LiveKit guide; no live-room or telephony deployment validation is claimed.

Regex/key-based redaction can miss personal data outside its configured patterns. Consent checks use the records you supply; the library does not independently establish that consent is valid. Regulatory references describe intended control areas, not certification or a guarantee of legal compliance. Redis transactions protect state updates, but external telephony delivery is not part of that transaction. See reliability limits for concurrency, retries, and storage behavior.


Features

  • Confidence-gated escalation — multi-signal threshold policies (logprob + ASR confidence + tool risk + turn count)
  • Lossless warm transfer state — progressive profiling payload with intent history, entity values, sentiment trajectory
  • PII scrubbing — regex-based HIPAA PHI, FERPA education record, and SMS URL-parameter PHI detection + redaction
  • TCPA compliance — quiet hours enforcement, Prior Express Written Consent (PEWC) gating, opt-out interception
  • A2P 10DLC validation — TCR campaign config validation, AI-generated SMS disclosure enforcement, MIXED type warnings
  • Omnichannel consent bridging — voice consent records propagate to SMS channel without second opt-in
  • Post-call SMS summaries — PHI-stripped case summary sent to human agent after escalation
  • Compliance enforcement — HIPAA, FERPA, EU AI Act Articles 50(1)/14 runtime policy checking
  • Redis-gated state — atomic state management for concurrent telephony I/O (prevents race conditions)
  • Twilio ConversationRelay — native handoffData payload builder for Flex TaskRouter
  • Pipecat adapter — caller-wired frame helper; its legacy native installer is quarantined
  • No required dependencies — core library has zero required dependencies; Redis and Pipecat are optional

Quick Start

Installation

Installer examples keep the security-qualified package floor. If that release is not yet available on PyPI, use the reviewed checkout or wheel; do not drop the floor to make pip select an older distribution.

Use a maintained Python 3.11+ runtime for production. Python 3.9/3.10 core compatibility remains available as legacy support; development and optional SDK floors are separate.

The base runtime supports Python 3.9+. Development and tests ([dev]) require Python 3.10+ with patched pytest>=9.0.3. Python 3.9 CI runs an installed-wheel core API smoke and compile check without development dependencies.

pip install 'voice-ai-governance>=0.6.0'
# With Redis support:
pip install "voice-ai-governance[redis]>=0.6.0"
# With retained SDK installers:
pip install "voice-ai-governance[all]>=0.6.0"

Security-qualified installers

The 2026-11-02 qualification resolves/audits minimum and current graphs on Python 3.11 and current graphs on Python 3.14. Native tests are separate from resolution: 3.14 core tests do not qualify every telephony SDK there. Keep a reviewed dependency lock and rescan it for deployment.

Extra Qualified dependency floor Effective dependency Python floor
redis redis 4.5.4 project core 3.9; maintained 3.11+ recommended
livekit livekit-agents 1.8.7 <2, opentelemetry-api 1.45.1 3.10; SDK requires <3.15
amazon_connect boto3 1.34.63, urllib3 2.8.0 <3 3.10
all the three retained runtime installers above 3.10; LiveKit requires <3.15
dev patched pytest 9.0.3, pytest-asyncio 1.3.0 and listed tools 3.10

The old pipecat install extra is removed from metadata and all. Its legacy 0.x branch constrains Pillow below the patched 13.x floor, while older Pipecat releases also have a direct critical advisory. The helper API and source examples remain for caller-managed pipelines, but no Pipecat 1.x native installation/migration is claimed by this release. Do not treat pip's warning for an unknown legacy extra as a supported SDK install. Redis, LiveKit and boto3 floors also prevent the known affected minimum graphs; the core library still has no required dependencies. This dated qualification is not a promise for all historical or future dependency combinations.

Confidence-Gated Escalation

from voice_ai_governance import (
    ConfidenceGatedEscalationPolicy,
    EscalationThreshold,
    EscalationTrigger,
    EscalationAction,
)

policy = ConfidenceGatedEscalationPolicy(
    thresholds=[
        EscalationThreshold(
            trigger=EscalationTrigger.LOW_CONFIDENCE,
            threshold=0.65,
            action=EscalationAction.WARM_TRANSFER,
            priority=10,
        ),
        EscalationThreshold(
            trigger=EscalationTrigger.PII_DETECTED,
            threshold=1.0,  # Always escalate on PII detection
            action=EscalationAction.WARM_TRANSFER,
            priority=20,
        ),
        EscalationThreshold(
            trigger=EscalationTrigger.USER_REQUEST,
            threshold=1.0,
            action=EscalationAction.WARM_TRANSFER,
            priority=30,
        ),
    ],
)

result = policy.evaluate(
    confidence_score=0.45,
    context={"turn_count": 8, "intent": "billing_inquiry"},
)

if result.triggered:
    print(f"Escalating: {result.trigger} → {result.action}")
    # Initiate warm transfer

Warm Transfer State Management

from voice_ai_governance import WarmTransferStateManager
from voice_ai_governance.pii import PIIScrubber

# In-memory (testing) — swap for Redis in production
manager = WarmTransferStateManager(pii_scrubber=PIIScrubber())

# Create session at call start
session_id = manager.create_session(call_sid="CA1234567890")

# Update state each turn
manager.update_state(
    session_id,
    lambda s: s.add_turn(
        role="user",
        utterance="I need help with my invoice",
        intent="billing_inquiry",
        confidence=0.88,
        entities_detected={"invoice_number": "INV-2026-001"},
        sentiment_score=0.3,
    ),
)

# Build handoff payload — configured pattern redaction requested by default
payload = manager.build_handoff_payload(session_id, reason="low_confidence")
print(payload.caller_summary)
# "Caller interaction (3 turns). Intent: billing_inquiry. Sentiment: positive..."

Since 0.5.0, requested redaction raises ValueError if no scrubber is configured; this applies to both sync and async managers. Missing sessions still return None. An explicit scrub_pii=False bypasses redaction. Pattern matching cannot guarantee removal of all sensitive data; configure domain patterns and review outgoing payloads.

Twilio ConversationRelay Warm Transfer

import json
from voice_ai_governance import WarmTransferStateManager
from voice_ai_governance.pii import PIIScrubber
from voice_ai_governance.adapters.twilio import TwilioWarmTransferAdapter

manager = WarmTransferStateManager(redis_client=redis_client, pii_scrubber=PIIScrubber())
adapter = TwilioWarmTransferAdapter(
    state_manager=manager,
    queue_sid="WQ_YOUR_QUEUE_SID",
)

# In your WebSocket handler when escalation triggers:
message = adapter.build_end_session_message(session_id=session_id)
await websocket.send_text(json.dumps(message))
# Sends: {"type": "end", "handoffData": {...contextual data...}}

See policy semantics and migration and the source register before configuring legal policies.

HIPAA + FERPA Compliance Enforcement

from voice_ai_governance import HIPAAVoicePolicy, FERPAVoicePolicy
from voice_ai_governance.adapters.pipecat import PipecatGovernanceAdapter

adapter = PipecatGovernanceAdapter(
    compliance_policies=[
        HIPAAVoicePolicy(
            require_consent_for_recording=True,
            scrub_phi_before_transfer=True,
        ),
        FERPAVoicePolicy(
            require_caller_identity_verification=True,
        ),
    ],
)

# Check compliance before responding
context = {
    "entities": {"student_id": "STU123", "gpa": "3.8"},
    "caller_identity_verified": False,
    "baa_verified": True,  # only after checking the applicable agreement
}
result = adapter.check_compliance(context)

if not result.passed:
    for violation in result.violations:
        print(f"[{violation.regulation}] {violation.rule_id}: {violation.description}")
    # Trigger escalation or restrict response

EU AI Act Articles 50(1)/14 Enforcement

from voice_ai_governance import EUAIActVoicePolicy

policy = EUAIActVoicePolicy(
    require_ai_disclosure=True,   # Article 50(1)
    is_high_risk_context=True,    # caller has assessed Article 6 / Annex III applicability
    require_human_override_capability=True,  # Article 14.3
)

result = policy.check({
    "ai_identity_disclosed": True,
    "human_override_available": True,
})
assert result.passed

TCPA-Compliant Outbound SMS

from voice_ai_governance import (
    OmnichannelConsentStore,
    ConsentType,
    A2PCampaignConfig,
    A2PCampaignType,
)
from voice_ai_governance.adapters.twilio_sms import TwilioSMSAdapter

# Record consent captured during voice call
consent_store = OmnichannelConsentStore()
consent_store.record_consent(
    phone="+15551234567",
    consent_type=ConsentType.PRIOR_EXPRESS_WRITTEN,
    channel="voice",
    campaign_id="C1234",
)

adapter = TwilioSMSAdapter(
    from_number="+18005550100",
    consent_store=consent_store,
    campaign_config=A2PCampaignConfig(
        campaign_id="C1234",
        brand_name="Acme Health",
        campaign_type=A2PCampaignType.HEALTHCARE,
        use_case_description="AI appointment reminders for patients",
        ai_generated=True,
        opt_out_message="Reply STOP to unsubscribe. Msg&data rates may apply.",
    ),
)

message = adapter.build_message(
    to="+15551234567",
    body="Your appointment is confirmed. Details: https://portal.example.com/appt?patient_id=9876",
    message_type="transactional",
    recipient_hour=10,  # Checked against TCPA quiet hours (8am–9pm)
)

if message.compliance_passed:
    # twilio_client.messages.create(**message.to_twilio_params())
    print(message.body)
    # "Your appointment is confirmed. Details: https://portal.example.com/appt?patient_id=[REDACTED]"

LiveKit Agents Warm Transfer

Run the no-credentials handoff contract demo to distinguish context publication from a confirmed connection.

Use the complete registration and dispatch example. It creates state before dispatch, records trusted consent/BAA evidence and explains how the worker finds the same session. Creating an adapter alone is insufficient.

Requires: pip install "voice-ai-governance[livekit]>=0.6.0" (installs LiveKit Agents 1.8.7+ <2 and patched OpenTelemetry API 1.45.1+).

Migration: transfer() and on_confidence_low() now require a keyword-only recipient_identity. Your application must authorize that participant and register an active or escalating session whose ID is in job metadata before calling them. Missing recipients, invalid sessions, and consent failures stop publication; SDK publication failures and cancellation propagate. These methods never disconnect the room or mark the session transferred. The historical transfer() name now means context publication only. Reliable packets do not prove receipt or a human connection. Use LiveKit's native warm-transfer workflow for consultation, connection, and failure return; confirm its outcome before updating transfer state. Recipient departure after validation, duplicate publications, and application acknowledgments remain the host application's responsibility.

Amazon Connect Warm Transfer

from voice_ai_governance.adapters.amazon_connect import AmazonConnectAdapter
from voice_ai_governance.state import WarmTransferStateManager
from voice_ai_governance.pii import PIIScrubber

adapter = AmazonConnectAdapter(
    instance_id="arn:aws:connect:us-east-1:123456789012:instance/abc",
    region_name="us-east-1",
    state_manager=WarmTransferStateManager(pii_scrubber=PIIScrubber()),
)

# Build Amazon Connect contact attributes payload (TCPA-gated, HIPAA-scrubbed)
payload = adapter.build_transfer_payload(
    session_id=session_id,
    contact_id=contact_id,
    reason="confidence_escalation",
)
# payload["attributes"] maps directly onto Amazon Connect SetAttributes block

# Extract Contact Lens real-time transcript turns
turns = adapter.extract_transcript(contact_id)

Requires: pip install "voice-ai-governance[amazon_connect]>=0.6.0" (installs boto3).

CCPA Consumer Rights Enforcement

from voice_ai_governance.ccpa import CCPAVoicePolicy, CCPARequestTracker

policy  = CCPAVoicePolicy()
tracker = CCPARequestTracker()

context = {
    "consumer_id": "c-001",
    "california_resident": True,
    "transcript": "Please delete all my information.",  # phrase-matched
}

result = policy.check(context)
if not result.passed:
    for v in result.violations:
        print(f"[{v.rule_id}] {v.citation}: {v.description}")
        # [CCPA-105] Cal. Civil Code §1798.105: Consumer invoked Right to Delete...
    tracker.record_request(context["consumer_id"], "right_to_delete")
    # Route caller to human agent; 45-day SLA clock starts now

Post-Call SMS Case Summary

from voice_ai_governance.adapters.twilio_sms import PostCallSMSBuilder

builder = PostCallSMSBuilder(
    portal_base_url="https://portal.example.com/cases",
    scrub_phi=True,
)

message = builder.build(
    to_agent="+15559999999",
    from_number="+18005550100",
    caller_number="+15554445678",
    session_id="sess_abc123",
    intent="billing_inquiry",
    turn_count=5,
    escalation_reason="low_confidence",
)
# Body: "[CASE ALERT] New inbound case\nCaller: ...5678\nIntent: Billing Inquiry | Turns: 5\n..."
# All PHI stripped; portal link appended for secure detail access

Inbound Opt-Out Interception

from voice_ai_governance.adapters.twilio_sms import TwilioSMSAdapter
from voice_ai_governance import OmnichannelConsentStore

store = OmnichannelConsentStore()
adapter = TwilioSMSAdapter(from_number="+18005550100", consent_store=store)

# In your Twilio webhook handler:
result = adapter.process_inbound(from_number="+15551234567", body="STOP")
if result.is_opt_out:
    # opt-out recorded in store — future messages suppressed automatically
    pass  # send CTIA-required confirmation reply

Regulations Covered

Regulation Coverage
HIPAA §164.514 PHI detection and scrubbing before transfer; URL parameter PHI redaction in SMS
Configurable recording safeguard Consent tracking; not a recording-consent mandate under HIPAA §164.522
FERPA §99.31 Education record access restriction
FERPA §99.37 Directory information opt-out enforcement
CCPA §1798.100 Right to Know — detect and route consumer enquiries about collected data
CCPA §1798.105 Right to Delete — 45-day SLA tracking, inline deletion blocked, route to fulfilment
CCPA §1798.120 Right to Opt-Out — sale/sharing opt-out within 15 business days
11 CCR §7221 Detect ADMT opt-out requests and route for applicability/human review; scope and exceptions apply
CCPA §1798.125 Right to Non-Discrimination — service-level change on rights exercise prohibited
TCPA 47 U.S.C. §227 Quiet hours (8am–9pm), PEWC for AI marketing SMS, opt-out suppression
Configurable consent policy Per-campaign granularity; not the vacated FCC one-to-one consent rule
CTIA Best Practices STOP/HELP/UNSUBSCRIBE/CANCEL/END/QUIT keyword interception
A2P 10DLC (TCR) Campaign config validation, AI-generated disclosure, MIXED type throughput warnings
EU AI Act Article 50(1) AI identity disclosure
EU AI Act Article 14 Caller-attested override availability for configured high-risk use; not full human-oversight compliance
EU AI Act Article 12 Logging and monitoring
OWASP ASI-02 Tool misuse prevention via compliance-gated execution
OWASP ASI-09 Human-agent trust exploitation prevention

Platform Compatibility

Platform Adapter Status
Pipecat (pipecat-ai) PipecatGovernanceAdapter Caller-managed helper only; native install extra quarantined
Twilio ConversationRelay TwilioWarmTransferAdapter ✅ Supported
Twilio Programmable Messaging TwilioSMSAdapter, PostCallSMSBuilder ✅ Supported
LiveKit Agents 1.8.7+ <2 LiveKitWarmTransferAdapter Targeted context publication; native human transfer remains application-owned
Amazon Connect + Contact Lens AmazonConnectAdapter ✅ Supported
Cisco Webex CC Coming in v0.4 🔜 Planned
NICE CXone Coming in v0.4 🔜 Planned


License

MIT License. See LICENSE.

Reliability updates (0.3.0)

Complete handoff-field redaction, including nested sequences and name entities; WATCH/MULTI updates with bounded retries and completed-session protection. Introduced in 0.3.0.

Run pip install -e ".[dev,redis]" and python -m pytest. Real Redis tests use a temporary Unix socket and require redis-server; absent binaries skip those tests. Redis WATCH/MULTI retries at most 100 times. Updaters must have no external side effects: conflicts replay callbacks. Connection failures propagate. Completed sessions cannot be retransferred. Async in-memory locks remain for the manager lifetime; use Redis/TTL for long-lived services. Synchronous in-memory use is single-threaded.

Entities are scrubbed before generating summaries; the complete payload is then scrubbed, including nested lists. Configured regex/key-based redaction cannot guarantee detection of every form of personal data. Source state stays intact.

September 2026 boundary review (0.3.1)

Return isolated in-memory conversation snapshots and redact nested dictionary keys; reject redaction collisions instead of silently losing entries.

State returned by get_state and update_state is a snapshot; persist changes through update_state. This matches Redis behavior and prevents callers from mutating terminal state outside the update path. Dictionary keys are checked with the configured PII patterns, including inside sequences. Two keys that redact to the same text raise ValueError; non-string keys raise TypeError. Original data remains untouched. Regex/key detection is still bounded by its configured patterns.

LiveKit session userdata is shared across agents: keep authoritative state behind the manager rather than exposing its internals. Official session guidance. Installed-SDK packet publication is qualified as described in the LiveKit guide; live telephony and native transfer orchestration remain unvalidated and application-owned.

Metadata

Release files for voice-ai-governance 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for voice-ai-governance 0.6.0
File Size Uploaded Provenance Actions
voice_ai_governance-0.6.0.tar.gz 111.8 kB With provenance Details for voice_ai_governance-0.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for voice-ai-governance 0.6.0
File Interpreter ABI Platform Actions
voice_ai_governance-0.6.0-py3-none-any.whl Python 3 none any Details for voice_ai_governance-0.6.0-py3-none-any.whl

Total release size: 165.5 kB

Release files / voice_ai_governance-0.6.0.tar.gz

Download URL voice_ai_governance-0.6.0.tar.gz
Size 111.8 kB
Tags Source
SHA-256 checksum
How to use checksums
26e15194548be0e6f790b777766fdd0ef32e0bcc7751c85958f690fb4f4eda67
BLAKE2b-256 checksum
How to use checksums
f93709f42b7f560fecf9ccd7f6cdc280de6bdff38ffbd8a93662fa9ac93f6b1f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Release files / voice_ai_governance-0.6.0-py3-none-any.whl

Download URL voice_ai_governance-0.6.0-py3-none-any.whl
Size 53.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3d9bbdfe29338715f465c9c6ac1464d6be5366fb1b49ae9048a7db4b98ca7f2d
BLAKE2b-256 checksum
How to use checksums
cfd03f4bfc5d42bebe91352553f6dd3945966612800f17fe0d080f7625053dfc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Security for voice-ai-governance 0.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for voice_ai_governance-0.6.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page