Skip to main content
Unified Python SDK for Agent Control - providing agent protection, monitoring, and rule enforcement in one clean package.

Installation

Quick Start

Simple Initialization

With Full Metadata

Features

1. Simple Initialization

One line to set up your agent with full protection:
This automatically:
  • Creates an Agent instance with your metadata
  • Discovers and loads rules.yaml
  • Registers with the Agent Control server
  • Enables the @control() decorator

2. Decorator-Based Protection

Protect any function with server-defined controls:

3. HTTP Client

Use the client directly for custom workflows:

4. Agent Metadata

Access your agent information:

Complete Example

API Reference

Initialization

agent_control.init()

Initialize Agent Control with your agent’s information. Parameters:
  • agent_name: Human-readable name
  • agent_id: UUID string (or UUID instance)
  • agent_description: Optional description
  • agent_version: Optional version string
  • server_url: Optional server URL (defaults to AGENT_CONTROL_URL env var)
  • rules_file: Optional rules file path (auto-discovered if not provided)
  • **kwargs: Additional metadata
Returns: Agent instance

Decorator

@control()

Decorator to protect a function with server-defined controls. Parameters:
  • policy: Optional policy name to use (defaults to agent’s assigned policy)
Example:

Client

AgentControlClient

Async HTTP client for Agent Control server. Methods:
  • health_check() - Check server health
  • Use with module functions like agent_control.agents.*, agent_control.controls.*, etc.
Example:

Models

If agent-control-models is installed, these classes are available:
  • Agent - Agent metadata
  • ProtectionRequest - Protection request model
  • ProtectionResult - Protection result with helper methods
  • HealthResponse - Health check response

Configuration

Environment Variables

  • AGENT_CONTROL_URL - Server URL (default: http://localhost:8000)
  • AGENT_CONTROL_API_KEY - API key for authentication (optional)

Server-Defined Controls

Controls are defined on the server via the API or web dashboard, not in code. This keeps security policies centrally managed and allows updating controls without redeploying your application. See the Reference Guide for complete control configuration documentation.

Package Name

This package is named agent-control-sdk (with hyphen in PyPI) and imported as agent_control (with underscore in Python):
Basic usage:

SDK Logging

The SDK uses Python’s standard logging module with loggers under the agent_control.* namespace. Following library best practices, the SDK only adds a NullHandler - your application controls where logs go and how they’re formatted.

Configuring SDK Logs in Your Application

Option 2: SDK settings (control log categories)

Controlling What the SDK Logs

The SDK provides behavioral settings to control which categories of logs are emitted:
These behavioral settings work independently of log levels:
  • Behavioral settings: Control which categories of logs the SDK emits
  • Log levels: Control which logs are displayed (via Python’s logging module)

Logging Environment Variables

Configure SDK logging via environment variables:

Using SDK Loggers in Your Code

If you’re extending the SDK or want consistent logging:
Default Settings:
  • log_enabled: true
  • All behavioral settings: enabled

Development

Examples

See the examples directory for complete examples:

Documentation