Overview

This guide helps you diagnose and fix common issues with AgentWarden integration.

Permission Check Issues

Problem: “No permission found for action”

Symptoms:
result = guard.check(agent_id, "stripe.refund", context)
# result.allowed = False
# result.reason = "No permission found for action 'stripe.refund'"
Causes & Solutions:
Check: Go to dashboard → Agents → [Your Agent] → PermissionsSolution: Create the permission
    Action: stripe.refund
    Max Amount: 100.00
    Requires Approval: No
Check: Verify exact spelling and case
    # Wrong
    guard.check(agent_id, "stripe.Refund", context)  # Capital R
    guard.check(agent_id, "stripe_refund", context)  # Underscore
    
    # Correct
    guard.check(agent_id, "stripe.refund", context)  # Lowercase, dot
Check: Print the agent ID you’re using
    print(f"Using agent ID: {agent_id}")
Solution: Copy the correct agent ID from the dashboard

Problem: “Amount exceeds maximum allowed”

Symptoms:
result = guard.check(agent_id, "stripe.refund", {"amount": 150.00})
# result.reason = "Amount 150.00 exceeds maximum allowed 100.00"
Solutions:
Update the permission’s max_amount in the dashboard:
  1. Go to Agents → [Your Agent] → Permissions
  2. Edit the permission
  3. Increase Max Amount to desired value
  4. Save

Problem: “Agent is not active”

Symptoms:
result.reason = "Agent is not active (status: inactive)"
Solution:
  1. Go to dashboard → Agents
  2. Find the agent
  3. Check status badge
  4. If inactive, click agent → Change status to “Active”

Authentication Issues

Problem: “Invalid API key”

Symptoms:
AuthenticationError: Invalid API key
Diagnosis:
import os

# Print what key is being used
api_key = os.getenv('AGENTWARDEN_API_KEY')
print(f"Using API key: {api_key[:10]}..." if api_key else "API key not found!")
Common causes:
1

Check .env file

    # Verify .env exists
    cat .env
    
    # Check for typos
    AGENTWARDEN_API_KEY=ak_1234567890abcdef  # Correct
    AGENT_WARDEN_API_KEY=...  # Wrong - underscore
    AGENTWARDEN_APIKEY=...     # Wrong - no underscore
2

Verify environment variables load

    from dotenv import load_dotenv
    load_dotenv()  # Must call this!
    
    import os
    print(os.getenv('AGENTWARDEN_API_KEY'))
3

Copy fresh key from dashboard

Settings → General → Copy API Key
4

Check for extra spaces

    # Wrong - has trailing space
    AGENTWARDEN_API_KEY=ak_1234567890abcdef 
    
    # Correct
    AGENTWARDEN_API_KEY=ak_1234567890abcdef

Problem: API key works locally but not in production

Check environment variables in production:
# For systemd service
sudo systemctl show agentwarden --property=Environment

# For Docker
docker exec container_name env | grep AGENTWARDEN

# For Heroku
heroku config:get AGENTWARDEN_API_KEY

# For AWS Lambda
aws lambda get-function-configuration --function-name my-function
Solution: Set environment variable in production environment

Rate Limiting

Problem: “Rate limit exceeded”

Symptoms:
RateLimitError: Rate limit exceeded. Please try again in 60 seconds.
Immediate fix:
import time

# Wait and retry
time.sleep(60)
result = guard.check(agent_id, action, context)
Long-term solutions:
    from agentwarden import RateLimitError
    import time
    
    def check_with_retry(agent_id, action, context, max_retries=3):
        for attempt in range(max_retries):
            try:
                return guard.check(agent_id, action, context)
            except RateLimitError:
                if attempt < max_retries - 1:
                    wait = (2 ** attempt) * 1  # 1s, 2s, 4s
                    time.sleep(wait)
                else:
                    raise

Network Issues

Problem: “Connection timeout” or “Network unreachable”

Diagnosis:
# Test API connectivity
curl -I https://api.agentwarden.io/health

# Check DNS resolution
nslookup api.agentwarden.io

# Test from your server
curl -X POST https://api.agentwarden.io/sdk/check \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"agent_id": "test", "action": "test", "context": {}}'
Solutions:
Ensure outbound HTTPS (port 443) is allowed:
    # Check if port 443 is open
    nc -zv api.agentwarden.io 443
If behind a corporate proxy:
    import os
    os.environ['HTTPS_PROXY'] = 'http://proxy.company.com:8080'
    
    guard = AgentWarden(api_key=api_key)
    guard = AgentWarden(
        api_key=api_key,
        timeout=60  # Increase from default 30s
    )
    from agentwarden import NetworkError
    
    for attempt in range(3):
        try:
            result = guard.check(agent_id, action, context)
            break
        except NetworkError:
            if attempt < 2:
                time.sleep(2)
            else:
                # Fail-safe: deny action
                result = {"allowed": False, "reason": "System unavailable"}

Logging Issues

Problem: Logs not appearing in dashboard

Possible causes:
1

Check log call

    # Verify log is actually being called
    print("About to log...")
    guard.log(agent_id, action, "success", context)
    print("Logged successfully")
2

Check for errors

    try:
        guard.log(agent_id, action, "success", context)
    except Exception as e:
        print(f"Logging failed: {e}")
3

Verify agent exists

The agent must exist and belong to your organization
4

Check plan limits

Free plan: 1,000 logs/monthGo to Settings → Plans & Billing to see usage

Problem: “Monthly log limit reached”

Solution options:
  1. Upgrade plan - Settings → Plans & Billing
  2. Log selectively - Only log important actions:
   # Only log high-value actions
   if action in HIGH_VALUE_ACTIONS:
       guard.log(agent_id, action, status, context)
  1. Wait for reset - Limits reset monthly

Integration Issues

Problem: SDK not found

Symptoms:
ModuleNotFoundError: No module named 'agentwarden'
Solution:
# Install SDK
pip install agentwarden

# Verify installation
pip list | grep agentwarden

# Check Python version (requires 3.8+)
python --version

Problem: Agent ID not found

Get your agent ID:
  1. Via Dashboard:
    • Go to Agents
    • Click on agent
    • Copy the ID from the URL or page
  2. Via API:
   curl https://api.agentwarden.io/api/agents \
     -H "Authorization: Bearer YOUR_JWT_TOKEN"
  1. Print in code:
   # List all agents
   response = requests.get(
       'https://api.agentwarden.io/api/agents',
       headers={'Authorization': f'Bearer {jwt_token}'}
   )
   agents = response.json()
   for agent in agents:
       print(f"{agent['name']}: {agent['id']}")

Approval Workflow Issues

Problem: Approvals not showing in dashboard

Check:
  1. Permission has requires_approval = true
  2. Action is being checked (not just executed directly)
  3. You’re logged in with correct organization
Verify approval was created:
result = guard.check(agent_id, action, context)
print(f"Requires approval: {result.requires_approval}")
print(f"Approval ID: {result.approval_id}")

Problem: Can’t approve/deny requests

Possible causes:
  1. Not an admin - Only admins can approve
    • Solution: Have an admin grant you permissions
  2. Approval already decided - Check status
  3. Session expired - Log out and log back in

Performance Issues

Problem: Slow permission checks

Measure latency:
import time

start = time.time()
result = guard.check(agent_id, action, context)
duration = time.time() - start

print(f"Check took {duration:.3f}s")

if duration > 1.0:
    print("⚠️ Slow check detected!")
Solutions:
    # Don't send huge objects
    context = {
        "amount": 50,
        "customer_id": "cus_123"
        # Don't include entire customer object!
    }

Testing Issues

Problem: Tests failing in CI/CD

Common causes:
  1. API key not set in CI:
   # .github/workflows/test.yml
   env:
     AGENTWARDEN_API_KEY: ${{ secrets.AGENTWARDEN_API_KEY }}
  1. Network blocked in CI:
    • Use test mode or mock the SDK
  2. Mock not configured:
   from unittest.mock import Mock, patch
   
   with patch('agentwarden.AgentWarden') as MockGuard:
       mock_guard = MockGuard.return_value
       mock_guard.check.return_value = Mock(allowed=True)
       # Test code...

Debugging Tips

Enable Debug Logging

import logging

# Enable SDK debug logs
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger('agentwarden')
logger.setLevel(logging.DEBUG)

# Now all SDK calls will be logged
guard = AgentWarden(api_key=api_key)
result = guard.check(agent_id, action, context)

Inspect Request/Response

import requests

# Make raw API call to see exact request/response
response = requests.post(
    'https://api.agentwarden.io/sdk/check',
    headers={
        'X-API-Key': api_key,
        'Content-Type': 'application/json'
    },
    json={
        'agent_id': agent_id,
        'action': action,
        'context': context
    }
)

print(f"Status: {response.status_code}")
print(f"Headers: {response.headers}")
print(f"Body: {response.json()}")

Check API Status

# Check if API is up
curl https://status.agentwarden.io

# Or check directly
curl https://api.agentwarden.io/health

Getting Help

If you’re still stuck:

Diagnostic Checklist

When reporting issues, include:

Next Steps