Skip to main content

parlant-activefence

Deprecated. parlant-activefence is no longer maintained. It does not run on Parlant 3.2 or later, and it will stop working entirely when the Alice v1 evaluate API it calls is removed. Use parlant-alice 0.2.0 or later instead (source). ActiveFence is now Alice, and your existing API key works with parlant-alice.

Migrating to parlant-alice

  1. Replace the package and upgrade Parlant in the same change. parlant-alice requires Parlant 3.2.0 or later, which parlant-activefence does not run on.

    pip uninstall parlant-activefence
    pip install "parlant-alice>=0.2.0" "parlant>=3.2.0"
    
  2. Change the import and the class:

    # Before
    from parlant.contrib.activefence import ActiveFence
    moderation = ActiveFence(api_key="API_KEY", app_name="APP_NAME", blocked_message="This message was blocked")
    
    # After
    from parlant.contrib.alice import Alice
    moderation = Alice(api_key="API_KEY", app_id="APP_ID", blocked_message="This message was blocked")
    

    If you call check_message directly, its third argument is now the customer ID, not the agent ID. The parlant-alice changelog lists the other behaviour changes.

  3. Rename the environment variables:

    parlant-activefence parlant-alice
    ACTIVEFENCE_API_KEY ALICE_API_KEY
    ACTIVEFENCE_APP_NAME ALICE_APP_ID (required): the ID (a UUID) of the application in Alice's Application Inventory
    ACTIVEFENCE_BLOCKED_MESSAGE ALICE_BLOCKED_MESSAGE
    ACTIVEFENCE_URL_OVERRIDE ALICE_URL_OVERRIDE
    ACTIVEFENCE_API_TIMEOUT ALICE_API_TIMEOUT
    ACTIVEFENCE_RETRY_MAX ALICE_RETRY_MAX
    ACTIVEFENCE_RETRY_BASE_DELAY ALICE_RETRY_BASE_DELAY

    An application name is no longer enough: messages are evaluated against the policies assigned to the application whose ID you pass, and that application must be in the same project as your API key. ACTIVEFENCE_MODEL_PROVIDER, ACTIVEFENCE_MODEL_NAME, ACTIVEFENCE_MODEL_VERSION and ACTIVEFENCE_PLATFORM have no replacement. The default endpoint changes from https://apis.activefence.com to https://api.alice.io, so update any egress allowlist.

Until you migrate, you can silence the warning this package prints on import by running warnings.filterwarnings("ignore", message="parlant-activefence is deprecated", category=FutureWarning) before importing it.

The rest of this page documents the deprecated package.


ActiveFence integration for Parlant - A Python package that provides content moderation and compliance checking for Parlant applications using ActiveFence's threat analysis & detection services.

Introduction

ActiveFence’s Trust and Safety (T&S) is the world’s leading tool stack for Trust & Safety teams. With ActiveFence’s end-to-end solution, Trust & Safety teams of all sizes can protect users from malicious activity and online harm – regardless of content format, language or abuse area. Integrating with the T&S platform enables you to detect, collect and analyze harmful content that may put your users and brand at risk. By combining AI and a team of subject-matter experts, the ActiveFence T&S platform enables you to be agile and proactive for maximum efficiency, scalability and impact.

Installation

You can install parlant-activefence using pip:

pip install parlant-activefence

Usage

Basic Usage

The parlant-activefence package integrates with Parlant's framework to provide automatic content moderation and compliance checking. Here's how to use it:

from parlant.contrib.activefence import ActiveFence

# Configure Parlant server to use ActiveFence moderation services
# Will use environment variables for configuration
async with p.Server(configure_container=ActiveFence().configure_container) as server:

For the ActiveFence integration to work, an API key must be configured. This and more can be supplied using environment variables. The following environment variables can be used to configure ActiveFence integration:

Variable Description Default
ACTIVEFENCE_API_KEY ActiveFence API key for authentication None (required)
ACTIVEFENCE_APP_NAME Application name for identification Unknown
ACTIVEFENCE_BLOCKED_MESSAGE Message to display when content is blocked "The generated message was blocked by guardrails."

These values can also be passed directly when initializing the container:

from parlant.contrib.activefence import ActiveFence

moderation = ActiveFence(api_key="API_KEY",app_name="APP_NAME", blocked_message="This message was blocked")
async with p.Server(configure_container=moderation.configure_container) as server:

Impact

Using ActiveFence's moderation as shown will analyze messages sent by users to the AI agent, and the agent's response to them. This helps manage abusive messages, protect the application from malicious prompts and ensure the agent responses align to your policies.

User messages blocked by ActiveFence will not reach the agent, but it will get a flagged message indication a censored user request. You can guide the agent to respond to such messages using the Parlant guidelines, like so:

await agent.create_guideline(
        condition="the customer's last message is censored",
        action="respond with a polite refusal to answer the question, mention that the message was censored based on guardrails analysis",
    )

Analysis of the agent responses works a bit different. If the ActiveFence analysis marks the response as BLOCKED, the message itself will not be returned to the user, and instead a preconfigured block message will be returned. This message can be configured as described above. If a policy violation is detected but not flagged to be blocked, a warning is logged using Parlant's internal logger. This warning message will look like this: [warning ] [ReuwnpD7Gzn::process][MessageEventComposer][CannedResponseGenerator] Prevented sending a non-compliant message: 'However, I can't respond to your previous message because it was censored based on our guardrails analysis. If you have another question or need assistance, feel free to ask.'.

Example

Here is a complete example of setting up a Parlant server with ActiveFence moderation:

import asyncio
import parlant.sdk as p
from parlant.contrib.activefence import ActiveFence

async def main():
    async with p.Server(configure_container=ActiveFence(api_key="<API_KEY>",app_name="test").configure_container) as server:
        agent = await server.create_agent(
            name="Otto Carmen",
            description="You work at a computer parts store",
        )
        print(agent.id)

        blocked = await agent.create_guideline(
            condition="the customer's last message is censored",
            action="respond with a polite refusal to answer the question, mention that the message was censored based on guardrails analysis",
        )

asyncio.run(main())

And this is an example of a basic client that calls this server, and prints the messages returned by the agent to the console:

import asyncio
from parlant.client import ParlantClient

async def main():

    client = ParlantClient(base_url='http://localhost:8800')
    session = client.sessions.create(
        agent_id='<AGENT ID>',
        allow_greeting=False,
        title="test",
    )
    session_id = session.id
    client.sessions.create_event(
        session_id,
        kind="message",
        source="customer",
        message='Should I sue about this?',
        moderation="auto",
    )

    last_offset = 0
    while (True):
        try:
            events = client.sessions.list_events(session_id=session_id,
                min_offset=last_offset,
                wait_for_data=30,
                kinds="message",
            )
            for event in events:
                print(event)
                last_offset = max(last_offset, event.offset + 1)
        except Exception as e:
            print(e)

asyncio.run(main())

Enabled moderation="auto" will trigger the user prompt analysis, and if the ActiveFence policy is configured for it, it will block the message for including legal advice, even if the LLM is not configured to respond to this.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for parlant-activefence 0.1.3

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

Source distribution (sdist)

Source distribution for parlant-activefence 0.1.3
File Size Uploaded Provenance Actions
parlant_activefence-0.1.3.tar.gz 8.4 kB With provenance Details for parlant_activefence-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for parlant-activefence 0.1.3
File Interpreter ABI Platform Actions
parlant_activefence-0.1.3-py3-none-any.whl Python 3 none any Details for parlant_activefence-0.1.3-py3-none-any.whl

Total release size: 16.8 kB

Release files / parlant_activefence-0.1.3.tar.gz

Download URL parlant_activefence-0.1.3.tar.gz
Size 8.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d15765e8ca5982b8b78871630608251ef9b080772fcd571ff496d8998287dc75
BLAKE2b-256 checksum
How to use checksums
b5ca90c0bef40cd706276d7215b93fc33cfe86aa8ffd79aa45478c8c6e8bb7d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Oct 20, 2026.

Transparency log

Release files / parlant_activefence-0.1.3-py3-none-any.whl

Download URL parlant_activefence-0.1.3-py3-none-any.whl
Size 8.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f0c972a4c9dd9ca6894fc6cdcf81c1e55d79aaee47e57df6a8c188caad3f7465
BLAKE2b-256 checksum
How to use checksums
3e1699dd9a79a097c0ccc8e164219c8f3af884cc7ba87efb13a27e51511b58c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Oct 20, 2026.

Transparency log

Security for parlant-activefence 0.1.3

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 parlant_activefence-0.1.3.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 Oct 20, 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