Configuration
Configure Agent Kernel via environment variables or configuration files. This sub module class 'AKConfig' is exported as 'Config'. Its unlikely that you will directly use this class in your code (i.e. need for Advanced usage).
For detailed information about session and memory management configuration, see:
- Session Management - Session configuration and storage backends
- Memory Management - Advanced memory features and caching
Configuration File
Agent Kernel supports YAML and JSON configuration files. By default, it looks for config.yaml in the current working directory.
Basic Configuration File
Create config.yaml:
# Core settings
library_version: "0.1.0"
# Session management
session:
type: redis # or 'in_memory' or 'dynamodb'
redis:
url: redis://localhost:6379
ttl: 604800 # 7 days in seconds
prefix: "ak:sessions:"
dynamodb:
table_name: agent-kernel-sessions
ttl: 604800 # 7 days in seconds
# API server
api:
host: 0.0.0.0
port: 8000
custom_router_prefix: /custom
max_file_size: 2097152 # Maximum file size in bytes (default: 2 MB) that can be sent as attachments
enabled_routes:
agents: true
# Agent-to-Agent communication
a2a:
enabled: true
url: http://localhost:8000/a2a
agents:
- "*" # Enable for all agents
task_store_type: redis
# Model Context Protocol
# The MCP server is always mounted at /mcp on the main API server.
# Full endpoint: http://{api.host}:{api.port}/mcp — use api.port to change the port.
mcp:
enabled: true
expose_agents: true
agents:
- "*" # Expose all agents as MCP tools
stateless_http: false # Run in stateless HTTP mode (default: false)
# WebSocket API configuration (for AWS serverless deployments)
websocket_api:
connection_table:
table_name: "websocket-connections"
ttl: 3600 # Connection TTL in seconds for automatic cleanup
chat_route: "chat" # Default route for chat messages
# Execution configuration (for AWS serverless deployments)
execution:
mode: rest_sync # Execution mode: rest_sync, rest_async, stream, or async (WebSocket)
queues:
input:
url: "https://sqs.us-east-1.amazonaws.com/123456789012/agent-input" # Input SQS queue URL
max_receive_count: 3 # Maximum number of times a message can be received from input queue before being treated as permanently failed
output:
url: "https://sqs.us-east-1.amazonaws.com/123456789012/agent-output" # Output SQS queue URL
max_receive_count: 3 # Maximum number of times a message can be received from output queue before being treated as permanently failed
response_store:
type: redis # Response store type: redis or dynamodb (required for rest_sync and rest_async modes)
retry_count: 5 # Number of retry attempts for response store reads
delay: 5 # Delay in seconds between response store reads retry attempts
redis:
url: "redis://localhost:6379" # Redis connection URL for response storage
prefix: "ak:responses:" # Key prefix for Redis response storage
ttl: 604800 # Redis saved value TTL in seconds
dynamodb:
table_name: "agent-responses" # DynamoDB table name for response storage
ttl: 604800 # DynamoDB item TTL in seconds (0 disables)
# Testing configuration
test:
mode: fallback # Options: fuzzy, judge, fallback
judge:
model: gpt-4o-mini
provider: openai
embedding_model: text-embedding-3-small
# Messaging platform integrations
slack:
agent: "" # Default agent for Slack
agent_acknowledgement: "" # Acknowledgement message
whatsapp:
agent: "" # Default agent for WhatsApp
agent_acknowledgement: "" # Acknowledgement message
verify_token: "" # Webhook verify token
access_token: "" # Business API access token
app_secret: "" # App secret for signature verification
phone_number_id: "" # Business phone number ID
api_version: "v24.0" # API version
messenger:
agent: "" # Default agent for Facebook Messenger
verify_token: "" # Webhook verify token
access_token: "" # Page access token
app_secret: "" # App secret for signature verification
api_version: "v24.0" # Graph API version
instagram:
agent: "" # Default agent for Instagram
verify_token: "" # Webhook verify token
access_token: "" # Business access token
app_secret: "" # App secret for signature verification
instagram_account_id: "" # Business Account ID (IGSID)
api_version: "v21.0" # Graph API version
telegram:
agent: "" # Default agent for Telegram
bot_token: "" # Bot token from BotFather
webhook_secret: "" # Optional webhook security token
api_version: "bot" # Bot API version prefix
# Guardrails configuration
guardrail:
input:
enabled: false # Enable input guardrails
type: openai # Guardrail provider: openai, bedrock, or walledai
pii: true # Enable PII redaction/unmasking (WalledAI only)
# OpenAI-specific fields:
model: gpt-4o-mini # LLM model for guardrail validation (OpenAI only)
config_path: "" # Path to guardrail configuration JSON file (OpenAI only)
# Bedrock-specific fields:
id: "" # AWS Bedrock guardrail ID (Bedrock only)
version: "DRAFT" # AWS Bedrock guardrail version (Bedrock only)
output:
enabled: false # Enable output guardrails
type: openai # Guardrail provider: openai, bedrock, or walledai
pii: true # Enable PII redaction/unmasking (WalledAI only)
# OpenAI-specific fields:
model: gpt-4o-mini # LLM model for guardrail validation (OpenAI only)
config_path: "" # Path to guardrail configuration JSON file (OpenAI only)
# Bedrock-specific fields:
id: "" # AWS Bedrock guardrail ID (Bedrock only)
version: "DRAFT" # AWS Bedrock guardrail version (Bedrock only)
# Logging configuration (optional)
# If omitted, default loggers will not be overridden
logging:
ak:
level: WARNING # Agent Kernel log level: INFO, DEBUG, ERROR, WARNING, CRITICAL
system:
level: WARNING # System/root logger level: INFO, DEBUG, ERROR, WARNING, CRITICAL
Logging is auto-configured on import. Agent Kernel currently initializes logging as part of module import/startup, not only when you explicitly read these configuration values. In practice, that means importing the library may configure the Agent Kernel logger and the system/root logger and may add or change handlers/formatters. Use
logging.ak.levelto control Agent Kernel's own logger verbosity, andlogging.system.levelonly if you want Agent Kernel to affect the process-wide/root logger. If you do not want Agent Kernel to modify application-wide logging, avoid enabling root/system logger.
JSON Configuration
Alternatively, use config.json:
{
"logging": {
"ak": {
"level": "WARNING"
},
"system": {
"level": "WARNING"
}
},
"session": {
"type": "redis",
"redis": {
"url": "redis://localhost:6379",
"ttl": 604800,
"prefix": "ak:sessions:"
},
"dynamodb": {
"table_name": "agent-kernel-sessions",
"ttl": 604800
}
},
"api": {
"host": "0.0.0.0",
"port": 8000,
"custom_router_prefix": "/custom",
"max_file_size": 2097152,
"enabled_routes": {
"agents": true
}
},
"a2a": {
"enabled": true,
"url": "http://localhost:8000/a2a",
"agents": ["*"],
"task_store_type": "redis"
},
"mcp": {
"enabled": true,
"expose_agents": true,
"agents": ["*"],
"stateless_http": false
},
"websocket_api": {
"connection_table": {
"table_name": "websocket-connections",
"ttl": 3600
},
"chat_route": "chat"
},
"execution": {
"mode": "rest_sync",
"queues": {
"input": {
"url": "https://sqs.us-east-1.amazonaws.com/123456789012/agent-input",
"max_receive_count": 3
},
"output": {
"url": "https://sqs.us-east-1.amazonaws.com/123456789012/agent-output",
"max_receive_count": 3
}
},
"response_store": {
"type": "redis",
"retry_count": 5,
"delay": 5,
"redis": {
"url": "redis://localhost:6379",
"prefix": "ak:responses:",
"ttl": 604800
},
"dynamodb": {
"table_name": "agent-responses",
"ttl": 604800
}
}
},
"test": {
"mode": "fallback",
"judge": {
"model": "gpt-4o-mini",
"provider": "openai",
"embedding_model": "text-embedding-3-small"
}
},
"slack": {
"agent": "",
"agent_acknowledgement": ""
},
"whatsapp": {
"agent": "",
"agent_acknowledgement": "",
"verify_token": "",
"access_token": "",
"app_secret": "",
"phone_number_id": "",
"api_version": "v24.0"
},
"messenger": {
"agent": "",
"verify_token": "",
"access_token": "",
"app_secret": "",
"api_version": "v24.0"
},
"instagram": {
"agent": "",
"verify_token": "",
"access_token": "",
"app_secret": "",
"instagram_account_id": "",
"api_version": "v21.0"
},
"telegram": {
"agent": "",
"bot_token": "",
"webhook_secret": "",
"api_version": "bot"
},
"guardrail": {
"input": {
"enabled": false,
"type": "openai",
"model": "gpt-4o-mini",
"config_path": ""
},
"output": {
"enabled": false,
"type": "openai",
"model": "gpt-4o-mini",
"config_path": ""
}
},
"logging": { // Optional - if omitted, default loggers will not be overridden
"ak": {
"level": "WARNING"
},
"system": {
"level": "WARNING"
}
}
}
Custom Configuration File Path
Override the default configuration file path:
export AK_CONFIG_PATH_OVERRIDE=custom-config.yaml
# or
export AK_CONFIG_PATH_OVERRIDE=conf/agent-kernel.json
Environment Variables
All configuration parameters can be set using environment variables with the AK_ prefix. Use double underscores ('__') to separate nested configuration levels.
A name can have single underscores ('_') in its body.
Core Configuration
# Library version (auto-detected from package metadata)
export AK_LIBRARY_VERSION=0.1.0
Session Storage
# Session storage type
export AK_SESSION__TYPE=redis # Options: 'in_memory', 'redis', 'dynamodb' (default: 'in_memory')
# Redis configuration
export AK_SESSION__REDIS__URL=redis://localhost:6379 # default: redis://localhost:6379
export AK_SESSION__REDIS__TTL=604800 # TTL in seconds (default: 604800 = 7 days)
export AK_SESSION__REDIS__PREFIX=ak:sessions: # Key prefix (default: ak:sessions:)
export AK_SESSION__CACHE__SIZE=256 # Enable in-memory session caching with a cache size of 256 sessions
# DynamoDB configuration
export AK_SESSION__DYNAMODB__TABLE_NAME=agent-kernel-sessions # DynamoDB table name (required)
export AK_SESSION__DYNAMODB__TTL=604800 # TTL in seconds (default: 604800 = 7 days, 0 to disable)
export AK_SESSION__CACHE__SIZE=256 # Enable in-memory session caching with a cache size of 256 sessions
API Server
# API server configuration
export AK_API__HOST=0.0.0.0 # default: 0.0.0.0
export AK_API__PORT=8000 # default: 8000
export AK_API__MAX_FILE_SIZE=2097152 # Maximum file size in bytes (default: 2097152 = 2 MB)
# API route configuration
export AK_API__ENABLED_ROUTES__AGENTS=true # Enable agent routes (default: true)
Agent-to-Agent (A2A) Server
# Enable A2A functionality
export AK_A2A__ENABLED=true # default: false
export AK_A2A__URL=http://localhost:8000/a2a # default: http://localhost:8000/a2a
export AK_A2A__AGENTS="agent1,agent2" # Comma-separated list (default: ["*"])
export AK_A2A__TASK_STORE_TYPE=redis # Options: 'in_memory', 'redis' (default: 'in_memory')
Model Context Protocol (MCP) Server
# Enable MCP functionality
export AK_MCP__ENABLED=true # default: false
export AK_MCP__EXPOSE_AGENTS=true # Expose agents as MCP tools (default: false)
export AK_MCP__AGENTS="agent1,agent2" # Comma-separated list (default: ["*"])
export AK_MCP__STATELESS_HTTP=false # Run in stateless HTTP mode, no Mcp-Session-Id (default: false)
# Note: MCP is always served at /mcp on the main API server. Use AK_API__PORT to change the port.
Test Configuration
# Test comparison mode
export AK_TEST__MODE=fallback # Options: 'fuzzy', 'judge', 'fallback' (default: 'fallback')
# Judge configuration (for LLM-based evaluation)
export AK_TEST__JUDGE__MODEL=gpt-4o-mini # LLM model (default: gpt-4o-mini)
export AK_TEST__JUDGE__PROVIDER=openai # LLM provider (default: openai)
export AK_TEST__JUDGE__EMBEDDING_MODEL=text-embedding-3-small # Embedding model (default: text-embedding-3-small)
Messaging Platform Integrations
Slack
export AK_SLACK__AGENT=my-agent # Default agent for Slack interactions
export AK_SLACK__AGENT_ACKNOWLEDGEMENT="Processing your request..." # Acknowledgement message
WhatsApp
export AK_WHATSAPP__AGENT=my-agent # Default agent for WhatsApp interactions
export AK_WHATSAPP__AGENT_ACKNOWLEDGEMENT="Processing..." # Acknowledgement message
export AK_WHATSAPP__VERIFY_TOKEN=your-verify-token # Webhook verify token
export AK_WHATSAPP__ACCESS_TOKEN=your-access-token # Business API access token
export AK_WHATSAPP__APP_SECRET=your-app-secret # App secret for signature verification
export AK_WHATSAPP__PHONE_NUMBER_ID=your-phone-id # Business phone number ID
export AK_WHATSAPP__API_VERSION=v24.0 # API version (default: v24.0)
Facebook Messenger
export AK_MESSENGER__AGENT=my-agent # Default agent for Messenger interactions
export AK_MESSENGER__VERIFY_TOKEN=your-verify-token # Webhook verify token
export AK_MESSENGER__ACCESS_TOKEN=your-access-token # Page access token
export AK_MESSENGER__APP_SECRET=your-app-secret # App secret for signature verification
export AK_MESSENGER__API_VERSION=v24.0 # Graph API version (default: v24.0)
Instagram
export AK_INSTAGRAM__AGENT=my-agent # Default agent for Instagram interactions
export AK_INSTAGRAM__VERIFY_TOKEN=your-verify-token # Webhook verify token
export AK_INSTAGRAM__ACCESS_TOKEN=your-access-token # Business access token
export AK_INSTAGRAM__APP_SECRET=your-app-secret # App secret for signature verification
export AK_INSTAGRAM__INSTAGRAM_ACCOUNT_ID=your-ig-account-id # Business Account ID (IGSID)
export AK_INSTAGRAM__API_VERSION=v21.0 # Graph API version (default: v21.0)
Telegram
export AK_TELEGRAM__AGENT=my-agent # Default agent for Telegram interactions
export AK_TELEGRAM__BOT_TOKEN=your-bot-token # Bot token from BotFather
export AK_TELEGRAM__WEBHOOK_SECRET=your-webhook-secret # Optional webhook security token
export AK_TELEGRAM__API_VERSION=bot # Bot API version prefix (default: bot)