Skip to main content

👍
allow-agent

A lightweight Python framework for agent content moderation.


Installation

pip install allow-agent

What is allow-agent?

allow-agent is a simple yet powerful framework that automatically intercepts outbound HTTP requests made by AI agents. It gives you complete visibility and control over what your AI agents are doing behind the scenes.

Quick Start

1. Define a Request Handler

Place this at the top of your file to automatically intercept all outbound API requests:

from allow_agent import *

# This decorator enables automatic request interception
@request
def request(url, method, headers, body):
    if url == "https://api.openai.com/v1/chat/completions":
        print(f"OpenAI API Request: {body['messages'][0]}")
        
    return True  # Allow all requests by default

2. Use the rest normally

The handler will automatically intercept all outbound requests. No need for any special configuration.

# Your code works normally - requests are automatically intercepted
from openai import OpenAI

client = OpenAI()
response = client.chat.completions.create(
    model="o1-mini",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "This is a test prompt."}
    ]
)
print(response.choices[0].message.content)

Compatibility

Library Status
openai ✅ Supported
anthropic 🔄 Coming soon
langchain 🔄 Coming soon
browser-use 🔄 Coming soon
aisuite 🔄 Coming soon
requests 🔄 Coming soon
google-generativeai 🔄 Coming soon

Block requests

@request
def request(url, method, headers, body):
    # Block requests containing sensitive keywords
    if "api.openai.com" in url:
        messages_text = str(body.get("messages", ""))
        sensitive_terms = ["password", "credit card", "ssn"]
        
        for term in sensitive_terms:
            if term in messages_text.lower():
                print(f"Blocked request containing sensitive term: {term}")
                return False  # Block the request
                
    return True  # Allow all other requests

Common Use Cases

  • Logging: Monitor all prompts sent to AI models
  • Content Filtering: Block requests containing sensitive information
  • Cost Control: Limit the number or size of API calls
  • Compliance: Ensure all AI interactions follow regulatory requirements
  • Debugging: Inspect exactly what data is being sent to external services

⭐ Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Release files for allow-agent 1.1.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 allow-agent 1.1.0
File Size Uploaded
allow_agent-1.1.0.tar.gz 8.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for allow-agent 1.1.0
File Interpreter ABI Platform
allow_agent-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.7 kB

Release files / allow_agent-1.1.0.tar.gz

Download URL allow_agent-1.1.0.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a70c93a154b6020b323556f661aa7e5957978ff582f337ec67f13dc6bf554b2c
BLAKE2b-256 checksum
How to use checksums
d39ee66d9fe0c59dd7e01ea2caa9d3bdbb593e72ae56959ff7f2cfe800196029
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.11

Release files / allow_agent-1.1.0-py3-none-any.whl

Download URL allow_agent-1.1.0-py3-none-any.whl
Size 8.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
070a7f4f251fc831baafa25e8d1496cc36323ba3358f54acfaf2a8bda49b3884
BLAKE2b-256 checksum
How to use checksums
1adf13980d14e2aee0fd0c1c9cd414add3f72e7268dd6d8c581ee2251231d807
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.11

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.0

2 release files

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