Web Interface Guide

The DevOps Agent web interface provides a modern, browser-based way to interact with your agents. This guide covers everything from basic setup to advanced configuration and troubleshooting.

🌐 Overview

The web interface offers:

  • Modern UI: Responsive design accessible from any browser
  • Session Persistence: Conversations survive server restarts
  • Automatic Recovery: Graceful handling of interrupted sessions
  • Real-time Streaming: Live responses via Server-Sent Events
  • Artifact Management: Upload, download, and manage files
  • CORS Support: Cross-origin integration capabilities

πŸš€ Quick Start

# No local setup required - uses packaged agents
adk web-packaged --session_db_url "sqlite:///sessions.db"

# Access in browser
open http://localhost:8000

Local Agents Setup

# Start the web interface with local agents
adk web agents/

# Access in browser
open http://localhost:8000
# Use SQLite for session persistence
adk web-packaged --session_db_url "sqlite:///sessions.db"

# Access in browser
open http://localhost:8000

πŸ“‹ Command Reference

Available Commands

adk web-packaged [OPTIONS]

Local Agents Command

adk web AGENTS_DIR [OPTIONS]

Common Examples

# Zero-setup with persistent sessions (recommended)
adk web-packaged --session_db_url "sqlite:///sessions.db"

# Local agents with persistent sessions
adk web agents/ --session_db_url "sqlite:///sessions.db"

# Custom port and host (zero-setup)
adk web-packaged --host 0.0.0.0 --port 8080 --session_db_url "sqlite:///sessions.db"

# Production configuration (zero-setup)
adk web-packaged \
  --host 0.0.0.0 \
  --port 8080 \
  --session_db_url "postgresql://user:pass@host:port/db" \
  --artifact_storage_uri "gs://my-bucket" \
  --allow_origins "https://mydomain.com" \
  --trace_to_cloud

# Suppress auto-reload message
adk web-packaged --no-reload --session_db_url "sqlite:///sessions.db"

πŸ”„ Command Comparison

web-packaged vs web

Feature web-packaged web
Setup Required None Local agents directory
Agents Source Bundled with package Local filesystem
Use Case Quick demos, instant start Development, custom agents
Installation Works with uvx immediately Requires local agent files
Customization Limited to packaged agents Full customization

When to Use Each

Use web-packaged when:

  • βœ… Quick demos or testing
  • βœ… Installing via uvx from git
  • βœ… No local setup desired
  • βœ… Using standard DevOps agent

Use web when:

  • βœ… Developing custom agents
  • βœ… Need to modify agent behavior
  • βœ… Working with local agent files
  • βœ… Building custom workflows

βš™οΈ Configuration Options

Core Options

Option Description Default Example
--host Binding host 127.0.0.1 --host 0.0.0.0
--port Server port 8000 --port 8080
--reload/--no-reload Auto-reload True --no-reload

Session Management

Option Description Use Case
No option In-memory sessions Quick testing, sessions lost on restart
--session_db_url "sqlite:///sessions.db" SQLite database Development, local persistence
--session_db_url "postgresql://..." PostgreSQL Production, shared database
--session_db_url "agentengine://resource_id" Google Cloud Managed cloud sessions

Advanced Options

Option Description Example
--artifact_storage_uri Artifact storage location gs://my-bucket
--allow_origins CORS allowed origins https://mydomain.com
--trace_to_cloud Enable cloud tracing Flag only
--log_level Logging verbosity DEBUG, INFO, WARNING

πŸ—„οΈ Session Management

Session Storage Types

1. In-Memory Sessions (Default)

adk web agents/

Characteristics:

  • βœ… Fast startup
  • βœ… No setup required
  • ❌ Sessions lost on restart
  • ❌ Not suitable for production

Use Cases:

  • Quick testing
  • Development experiments
  • Temporary interactions
adk web agents/ --session_db_url "sqlite:///sessions.db"

Characteristics:

  • βœ… Persistent across restarts
  • βœ… Single file storage
  • βœ… No external dependencies
  • βœ… Automatic database creation
  • ❌ Single-user only

Use Cases:

  • Local development
  • Personal projects
  • Persistent testing

3. PostgreSQL Sessions (Production)

adk web agents/ --session_db_url "postgresql://user:password@host:5432/dbname"

Characteristics:

  • βœ… Multi-user support
  • βœ… High availability
  • βœ… Backup and recovery
  • βœ… Scalable
  • ❌ Requires database setup

Use Cases:

  • Production deployments
  • Team environments
  • Enterprise usage

4. Agent Engine Sessions (Google Cloud)

adk web agents/ --session_db_url "agentengine://your-resource-id"

Characteristics:

  • βœ… Fully managed
  • βœ… Google Cloud integration
  • βœ… Automatic scaling
  • βœ… Built-in monitoring
  • ❌ Requires Google Cloud setup

Use Cases:

  • Google Cloud environments
  • Managed deployments
  • Enterprise Google Cloud usage

🌍 Network Configuration

Local Development

# Default - localhost only
adk web agents/ --session_db_url "sqlite:///sessions.db"
# Access: http://localhost:8000

Network Access

# Allow network access
adk web agents/ --host 0.0.0.0 --port 8080 --session_db_url "sqlite:///sessions.db"
# Access: http://your-ip:8080

CORS Configuration

# Single origin
adk web agents/ --allow_origins "https://mydomain.com"

# Multiple origins
adk web agents/ \
  --allow_origins "https://mydomain.com" \
  --allow_origins "https://app.mydomain.com" \
  --allow_origins "http://localhost:3000"

πŸ”§ Troubleshooting

Common Issues

Session Not Found Errors

Problem: Browser shows β€œSession not found” errors after server restart.

Solution:

# Use persistent sessions
adk web agents/ --session_db_url "sqlite:///sessions.db"

Explanation: In-memory sessions are lost when the server restarts. The web interface now includes automatic session recovery, but persistent storage is recommended.

Port Already in Use

Problem: Address already in use error.

Solutions:

# Use different port
adk web agents/ --port 8080

# Find and kill existing process
lsof -ti:8000 | xargs kill -9

# Check what's using the port
lsof -i :8000

Static Files Not Loading

Problem: Web interface shows blank page or missing styles.

Solutions:

  1. Restart the server - Files are served automatically
  2. Check browser console for error messages
  3. Clear browser cache and refresh
  4. Verify server logs for any errors

CORS Errors

Problem: Cross-origin requests blocked.

Solution:

# Add your domain to allowed origins
adk web agents/ --allow_origins "https://yourdomain.com"

# For development with multiple origins
adk web agents/ \
  --allow_origins "http://localhost:3000" \
  --allow_origins "https://yourdomain.com"

Auto-reload Warnings

Problem: Seeing β€œReload mode is not supported” message.

Solution:

# Suppress the message (normal behavior)
adk web agents/ --no-reload --session_db_url "sqlite:///sessions.db"

Explanation: This is expected behavior. The web interface works correctly without reload mode.

Database Issues

SQLite Permission Errors

# Check directory permissions
ls -la $(dirname sessions.db)

# Ensure write permissions
chmod 755 $(dirname sessions.db)

# Use absolute path
adk web agents/ --session_db_url "sqlite:///$(pwd)/sessions.db"

PostgreSQL Connection Issues

# Test connection
psql "postgresql://user:password@host:5432/dbname" -c "SELECT 1;"

# Check network connectivity
telnet host 5432

# Verify credentials and database exists

Performance Issues

Slow Response Times

  1. Check system resources (CPU, memory)
  2. Monitor database performance for persistent sessions
  3. Enable tracing for detailed analysis:
    adk web agents/ --trace_to_cloud --log_level DEBUG
    

Memory Usage

  1. Use persistent sessions to reduce memory overhead
  2. Monitor session count in production
  3. Implement session cleanup for long-running deployments

πŸš€ Production Deployment

Basic Production Setup

adk web agents/ \
  --host 0.0.0.0 \
  --port 8000 \
  --session_db_url "postgresql://user:pass@db:5432/sessions" \
  --artifact_storage_uri "gs://production-artifacts" \
  --allow_origins "https://yourapp.com" \
  --trace_to_cloud \
  --no-reload

Docker Deployment

# Dockerfile
FROM python:3.11-slim
WORKDIR /app
COPY . .
RUN pip install google-adk
EXPOSE 8000
CMD ["adk", "web", "agents/", "--host", "0.0.0.0", "--session_db_url", "postgresql://..."]

Environment Variables

# Set in production environment
export GOOGLE_API_KEY=your_api_key
export GOOGLE_CLOUD_PROJECT=your_project
export DATABASE_URL=postgresql://...
export ARTIFACT_STORAGE_URI=gs://...

# Use in command
adk web agents/ \
  --session_db_url "$DATABASE_URL" \
  --artifact_storage_uri "$ARTIFACT_STORAGE_URI"

Health Checks

# Basic health check
curl http://localhost:8000/list-apps

# Detailed health check with session creation
curl -X POST http://localhost:8000/apps/devops/users/health/sessions \
  -H "Content-Type: application/json" \
  -d '{}'

πŸ” Monitoring and Debugging

Enable Debug Logging

adk web agents/ \
  --log_level DEBUG \
  --trace_to_cloud \
  --session_db_url "sqlite:///sessions.db"

Log Analysis

Key log messages to monitor:

  • Session {id} not found, creating new session - Automatic recovery
  • INFO: Reload mode is not supported - Expected behavior
  • Started server process - Successful startup
  • Database connection messages - Session storage health

Performance Monitoring

  • Response times for /run and /run_sse endpoints
  • Session creation/retrieval times
  • Database query performance
  • Memory usage trends

πŸ“š API Reference

The web interface exposes these key endpoints:

Session Management

  • GET /apps/{app}/users/{user}/sessions - List sessions
  • POST /apps/{app}/users/{user}/sessions - Create session
  • GET /apps/{app}/users/{user}/sessions/{id} - Get session

Agent Interaction

  • POST /run - Execute agent (non-streaming)
  • POST /run_sse - Execute agent (streaming)

Utility

  • GET /list-apps - List available agents
  • GET / - Redirect to web UI
  • GET /dev-ui/ - Web interface

🎯 Best Practices

Development

  1. Use persistent sessions: --session_db_url "sqlite:///sessions.db"
  2. Enable debug logging: --log_level DEBUG
  3. Use custom ports: Avoid conflicts with other services
  4. Regular database cleanup: Monitor SQLite file size

Production

  1. Use PostgreSQL: For multi-user environments
  2. Configure CORS: Restrict to known domains
  3. Enable tracing: For monitoring and debugging
  4. Use environment variables: For sensitive configuration
  5. Implement health checks: Monitor service availability
  6. Regular backups: For session databases

Security

  1. Restrict host binding: Use 127.0.0.1 for local-only access
  2. Configure CORS carefully: Only allow necessary origins
  3. Use HTTPS: In production environments
  4. Secure database connections: Use encrypted connections
  5. Monitor access logs: Track usage patterns

The web interface provides a powerful, modern way to interact with your DevOps agents. With proper session management and configuration, it offers a reliable, scalable solution for both development and production use cases.