Create and manage development environments for AI agent database testing and iteration. Use GibsonAI's natural language database management to set up isolated environments for agent development and testing.

Key Features

Environment Separation

  • Development Database: Separate database for development and testing
  • Production Database: Live database for production agents
  • Schema Isolation: Independent schema evolution in each environment
  • Safe Testing: Test changes without affecting production data

Natural Language Management

  • Schema Creation: Create database schemas using natural language
  • Table Operations: Add, modify, and remove tables with simple prompts
  • Environment Switching: Switch between development and production contexts
  • Version Control: Track schema changes across environments

Implementation Examples

Setting Up Development Environment

# Using Gibson CLI for development environment
# Create development database schema
# gibson modify users "Create a users table with id, username, email, created_at"
# gibson modify conversations "Create conversations table with user_id, agent_id, message, response"
# gibson code models
# gibson merge

# Test schema changes in development
# gibson modify users "Add last_login column to users table"
# gibson code models
# (Test the changes before applying to production)

Environment Configuration

# Development environment configuration
dev_config = {
    "database": "development",
    "api_key": "dev_api_key",
    "base_url": "https://api.gibsonai.com/v1/-"
}

# Production environment configuration
prod_config = {
    "database": "production",
    "api_key": "prod_api_key",
    "base_url": "https://api.gibsonai.com/v1/-"
}

Testing Agent Database Operations

import requests

class AgentDatabaseTester:
    def __init__(self, environment="development"):
        self.environment = environment
        self.api_key = "dev_api_key" if environment == "development" else "prod_api_key"
        self.base_url = "https://api.gibsonai.com/v1/-"
        self.headers = {"Authorization": f"Bearer {self.api_key}"}

    def test_user_creation(self):
        """Test user creation in development environment"""
        test_user = {
            "username": "test_user",
            "email": "test@example.com",
            "created_at": "2024-01-15T10:30:00Z"
        }

        response = requests.post(
            f"{self.base_url}/users",
            json=test_user,
            headers=self.headers
        )

        if response.status_code == 201:
            print("✓ User creation test passed")
            return response.json()
        else:
            print(f"✗ User creation test failed: {response.status_code}")
            return None

    def test_conversation_logging(self, user_id):
        """Test conversation logging"""
        test_conversation = {
            "user_id": user_id,
            "agent_id": "agent_001",
            "message": "Hello, I need help with my order",
            "response": "I'd be happy to help with your order. Can you provide your order number?"
        }

        response = requests.post(
            f"{self.base_url}/conversations",
            json=test_conversation,
            headers=self.headers
        )

        if response.status_code == 201:
            print("✓ Conversation logging test passed")
            return response.json()
        else:
            print(f"✗ Conversation logging test failed: {response.status_code}")
            return None

    def test_data_queries(self):
        """Test natural language queries"""
        query_request = {
            "query": "Show me all users created in the last 24 hours"
        }

        response = requests.post(
            f"{self.base_url}/query",
            json=query_request,
            headers=self.headers
        )

        if response.status_code == 200:
            print("✓ Query test passed")
            return response.json()
        else:
            print(f"✗ Query test failed: {response.status_code}")
            return None

Schema Migration Testing

def test_schema_migration():
    """Test schema changes in development before production"""

    # 1. Test schema modification
    # gibson modify users "Add preferences column as JSON to users table"
    # gibson code models

    # 2. Test data operations with new schema
    tester = AgentDatabaseTester("development")

    # Test creating user with new preferences field
    test_user = {
        "username": "test_user_2",
        "email": "test2@example.com",
        "preferences": {"theme": "dark", "notifications": True}
    }

    response = requests.post(
        f"{tester.base_url}/users",
        json=test_user,
        headers=tester.headers
    )

    if response.status_code == 201:
        print("✓ Schema migration test passed")
        # Now safe to apply to production
        # gibson merge  # Apply changes to production database
    else:
        print("✗ Schema migration test failed")
        # Rollback changes
        # gibson forget last

Environment Workflows

Development Workflow

# 1. Create new features in development
# gibson modify feature_table "Create new table for feature testing"
# gibson code models

# 2. Test the feature
def test_new_feature():
    # Run tests against development database
    pass

# 3. Validate schema changes
def validate_schema():
    # Check schema integrity
    pass

# 4. Deploy to production
# gibson merge  # Apply changes to production

Agent Testing Workflow

class AgentEnvironmentTester:
    def __init__(self):
        self.dev_tester = AgentDatabaseTester("development")
        self.prod_tester = AgentDatabaseTester("production")

    def run_development_tests(self):
        """Run comprehensive tests in development"""
        print("Running development environment tests...")

        # Test user operations
        user = self.dev_tester.test_user_creation()
        if user:
            self.dev_tester.test_conversation_logging(user["id"])

        # Test queries
        self.dev_tester.test_data_queries()

        print("Development tests completed")

    def validate_production_readiness(self):
        """Validate that changes are ready for production"""
        print("Validating production readiness...")

        # Check schema consistency
        # Verify data integrity
        # Test performance

        print("Production validation completed")

    def deploy_to_production(self):
        """Deploy validated changes to production"""
        print("Deploying to production...")

        # Apply schema changes
        # gibson merge

        print("Production deployment completed")

Use Cases

Agent Development

Perfect for:

  • Testing new agent features
  • Validating database schema changes
  • Experimenting with different data models
  • Debugging agent database interactions

Schema Evolution

Enable:

  • Safe schema modifications
  • Testing complex migrations
  • Validating data integrity
  • Rolling back problematic changes

Team Collaboration

Support:

  • Shared development environments
  • Consistent schema management
  • Collaborative testing
  • Knowledge sharing

Environment Management

Development Environment

# Development environment setup
def setup_dev_environment():
    # Create development database schema
    # gibson modify users "Create users table for development testing"
    # gibson modify agent_logs "Create agent_logs table for tracking agent behavior"
    # gibson code models
    # gibson merge

    # Populate with test data
    create_test_data()

    print("Development environment ready")

def create_test_data():
    """Create test data for development"""
    test_users = [
        {"username": "dev_user_1", "email": "dev1@example.com"},
        {"username": "dev_user_2", "email": "dev2@example.com"}
    ]

    # Create test users
    for user in test_users:
        requests.post(
            "https://api.gibsonai.com/v1/-/users",
            json=user,
            headers={"Authorization": "Bearer dev_api_key"}
        )

Production Environment

# Production environment management
def prepare_production_deployment():
    """Prepare for production deployment"""

    # Validate development changes
    if validate_development_changes():
        # Apply to production
        # gibson merge
        print("Production deployment successful")
    else:
        print("Development validation failed")

def validate_development_changes():
    """Validate changes before production deployment"""

    # Check schema integrity
    # Verify data migrations
    # Test performance
    # Validate security

    return True  # Return validation result

Benefits for AI Agent Development

Safe Development

  • Isolated Testing: Test changes without affecting production
  • Schema Validation: Validate schema changes before deployment
  • Data Integrity: Ensure data consistency across environments
  • Risk Mitigation: Reduce risk of production issues

Faster Iteration

  • Rapid Development: Quick schema changes in development
  • Immediate Testing: Test changes immediately
  • Natural Language: Use natural language for schema modifications
  • Automated Models: Automatic generation of Python models

Team Collaboration

  • Shared Environments: Team members can share development environments
  • Consistent Schemas: Ensure consistency across team
  • Knowledge Transfer: Easy knowledge sharing through natural language
  • Collaborative Testing: Team-based testing and validation

Best Practices

Environment Separation

  • Clear Boundaries: Keep development and production separate
  • Consistent Naming: Use consistent naming conventions
  • Access Control: Proper access controls for each environment
  • Documentation: Document environment-specific configurations

Testing Strategy

  • Comprehensive Tests: Test all agent database operations
  • Schema Validation: Validate schema changes thoroughly
  • Performance Testing: Test performance in development
  • Security Testing: Ensure security measures are effective

Deployment Process

  • Validation First: Always validate in development
  • Gradual Rollout: Deploy changes gradually
  • Monitor Performance: Monitor production after deployment
  • Rollback Plan: Have rollback procedures ready

Getting Started

  1. Set up Development Environment: Create separate development database
  2. Configure API Keys: Set up separate API keys for each environment
  3. Create Test Schema: Define initial database schema for testing
  4. Develop Testing Workflow: Create systematic testing procedures
  5. Validate and Deploy: Test thoroughly before production deployment

Gibson CLI Commands

# Development environment commands
gibson modify table_name "description of changes"
gibson code models
gibson code schemas

# Apply changes to development
gibson merge

# Reset development environment
gibson forget last
gibson build datastore

Ready to set up development environments for your AI agents? Get started with GibsonAI.