Config Validation Guide
The configuration validation system ensures your YAML configuration files are properly structured, contain valid settings, and reference accessible resources. This comprehensive guide covers all aspects of configuration validation from schema validation to environment setup.
Validation Overviewâ
Configuration validation operates at multiple levels to ensure complete system integrity:
- YAML Structure: Valid YAML syntax and root-level organization
- Schema Validation: Pydantic model validation for type safety
- Path Validation: File and directory existence verification
- LLM Configuration: Provider setup and API key validation
- Cross-Reference: Inter-section dependency validation
- Environment: System variable and dependency checks
YAML Structure Validationâ
Basic Format Requirementsâ
Configuration files must be valid YAML dictionaries:
# â
Valid: Dictionary at root level
paths:
custom_agents: "./custom_agents"
llm:
openai:
api_key: "your_api_key"
# â Invalid: List at root level
- paths:
custom_agents: "./custom_agents"
- llm:
openai:
api_key: "your_api_key"
Section Organizationâ
The validator recognizes these standard configuration sections:
paths
: Directory and file path configurationsllm
: LLM provider settings and API keysmemory
: Memory and conversation managementprompts
: Prompt template configurationexecution
: Execution policies and behaviortracing
: Monitoring and debugging setup
Common Typo Detectionâ
The system provides helpful suggestions for common section name typos:
# Common typos and suggestions
path: "..." # â ī¸ Did you mean 'paths'?
llms: "..." # â ī¸ Did you mean 'llm'?
memories: "..." # â ī¸ Did you mean 'memory'?
prompt: "..." # â ī¸ Did you mean 'prompts'?
exec: "..." # â ī¸ Did you mean 'execution'?
trace: "..." # â ī¸ Did you mean 'tracing'?
Schema Validationâ
Pydantic Model Validationâ
All configuration sections are validated against Pydantic models for type safety:
# â
Valid configuration
execution:
timeout_seconds: 300 # Valid: integer
retry_attempts: 3 # Valid: integer
parallel_execution: true # Valid: boolean
# â Invalid configuration
execution:
timeout_seconds: "five" # â Error: Expected integer, got string
retry_attempts: 3.5 # â Error: Expected integer, got float
parallel_execution: "yes" # â Error: Expected boolean, got string
Field Validation Examplesâ
String Fields
# Valid string configurations
prompts:
directory: "./prompts" # â
Valid path string
template_prefix: "agentmap_" # â
Valid prefix string
# Invalid string configurations
prompts:
directory: 123 # â Error: Expected string, got integer
Boolean Fields
# Valid boolean configurations
tracing:
enabled: true # â
Valid boolean
debug_mode: false # â
Valid boolean
# Invalid boolean configurations
tracing:
enabled: "true" # â Error: Expected boolean, got string
debug_mode: 1 # â Error: Expected boolean, got integer
Nested Object Validation
# Valid nested configuration
llm:
openai:
api_key: "sk-..." # â
Valid string
model: "gpt-4" # â
Valid model name
temperature: 0.7 # â
Valid float
# Invalid nested configuration
llm:
openai:
api_key: 123 # â Error: Expected string, got integer
temperature: "medium" # â Error: Expected number, got string
Path Validationâ
File Path Validationâ
The system validates paths for existence and accessibility:
# CSV file validation
csv_path: "./workflows/main.csv"
# Validation checks:
# â
File exists and is readable
# â ī¸ Warning: File doesn't exist (will be created)
# â Error: Path exists but is a directory, not a file
# â ī¸ Warning: Path doesn't have .csv extension
Directory Path Validationâ
Directory paths are validated for existence and permissions:
paths:
custom_agents: "./custom_agents" # â
Directory exists
functions: "./functions" # âšī¸ Directory will be created
compiled_graphs: "/invalid/path" # â ī¸ Parent directory doesn't exist
# Validation behavior:
# - Existing directories: â
Valid
# - Non-existing with valid parent: âšī¸ Info (will be created)
# - Invalid parent directory: â ī¸ Warning
# - Path exists but is a file: â Error
Storage Configuration Pathsâ
Storage configuration paths receive special handling:
storage_config_path: "./storage_config.yaml"
# Validation logic:
# - File exists: â
Valid, will be loaded
# - File doesn't exist: âšī¸ Info (will be created when needed)
# - Path is directory: â Error
# - Parent doesn't exist: â ī¸ Warning
Prompts Directory Validationâ
Prompts-related paths are validated for accessibility:
prompts:
directory: "./prompts" # âšī¸ Will be created if needed
registry_file: "./prompt_registry.yaml" # âšī¸ Will be created if needed
# Validation checks:
# - Valid parent directory required
# - Write permissions verified
# - File extension consistency checked
LLM Provider Configurationâ
Supported Providersâ
The system validates configuration for major LLM providers:
- OpenAI: GPT models and API configuration
- Anthropic: Claude models and API setup
- Google: Gemini models and authentication
API Key Validationâ
API keys are validated for format and presence:
llm:
openai:
api_key: "sk-proj-..." # â
Valid format and length
anthropic:
api_key: "sk-ant-..." # â
Valid format
google:
api_key: "AIza..." # â
Valid format
# Common issues:
llm:
openai:
api_key: "your_api_key" # â Error: Placeholder value detected
api_key: "sk-123" # â ī¸ Warning: API key seems too short
Environment Variable Integrationâ
The system checks for API keys in environment variables:
# No API key in config file
llm:
openai:
model: "gpt-4"
# api_key not specified
# Validation checks:
# â
Info: OpenAI API key found in OPENAI_API_KEY environment variable
# â ī¸ Warning: No API key configured for openai (check OPENAI_API_KEY)
Environment Variable Mapping:
- OpenAI:
OPENAI_API_KEY
- Anthropic:
ANTHROPIC_API_KEY
- Google:
GOOGLE_API_KEY
Model Name Validationâ
The system provides guidance on model names:
llm:
openai:
model: "gpt-4" # â
Known model
model: "gpt-4-custom-fine-tune" # âšī¸ Non-standard model noted
# Known models by provider:
# OpenAI: gpt-3.5-turbo, gpt-4, gpt-4-turbo-preview, gpt-4o
# Anthropic: claude-3-5-sonnet-20241022, claude-3-opus-20240229, claude-3-haiku-20240307
# Google: gemini-1.0-pro, gemini-1.5-pro-latest, gemini-pro
Temperature Validationâ
Temperature settings are validated for reasonable ranges:
llm:
openai:
temperature: 0.7 # â
Valid range (0-2)
temperature: 2.5 # â ī¸ Warning: Outside typical range 0-2
temperature: "medium" # â Error: Must be a number
Cross-Reference Validationâ
Tracing Configurationâ
When tracing is enabled, the system validates dependent configurations:
tracing:
enabled: true
mode: "langsmith"
project: "my_project"
langsmith_api_key: "ls_..."
# Validation checks:
# â
Valid: All required fields present
# â ī¸ Warning: API key not found (check LANGCHAIN_API_KEY environment variable)
# â ī¸ Warning: Project name appears to be placeholder
LangSmith Mode Validation:
tracing:
enabled: true
mode: "langsmith"
project: "your_project_name" # â ī¸ Warning: Placeholder detected
langsmith_api_key: "" # â ī¸ Warning: Check LANGCHAIN_API_KEY env var
Local Mode Validation:
tracing:
enabled: true
mode: "local"
local_directory: "./traces" # âšī¸ Directory will be created
local_directory: "/invalid/path" # â ī¸ Warning: Parent directory doesn't exist
Execution Policy Validationâ
Execution policies are validated for completeness:
execution:
success_policy:
type: "critical_nodes"
critical_nodes: [] # â ī¸ Warning: No critical nodes specified
execution:
success_policy:
type: "custom"
custom_function: "" # â Error: Custom function not specified
Policy Type Validation:
all_nodes
: No additional configuration requiredcritical_nodes
: Requires non-empty critical_nodes listcustom
: Requires custom_function specification
Validation Output Examplesâ
Successful Validationâ
đ Validating configuration file: agentmap_config.yaml
â
Configuration file format is valid
âšī¸ Found 4 configuration sections: paths, llm, execution, tracing
â
Configuration schema validation passed
âšī¸ Custom agents directory will be created: ./custom_agents
âšī¸ OpenAI API key found in environment variable OPENAI_API_KEY
âšī¸ LLM providers configured: openai, anthropic
â
Validation completed successfully
Validation with Warningsâ
đ Validating configuration file: agentmap_config.yaml
â
Configuration file format is valid
âšī¸ Found 3 configuration sections: paths, llm, tracing
â ī¸ Config Validation Warnings:
1. No API key configured for anthropic
Field: llm.anthropic.api_key
Suggestion: Set api_key in config or ANTHROPIC_API_KEY environment variable
2. Tracing enabled but project name not configured
Field: tracing.project
Suggestion: Set a meaningful project name for tracing
âšī¸ Validation complete with 0 errors and 2 warnings
Validation with Errorsâ
đ Validating configuration file: agentmap_config.yaml
â Config Validation Errors:
1. Schema validation error: Expected boolean, got string
Field: execution.parallel_execution
Value: "true"
2. CSV path is not a file: ./workflows/
Field: csv_path
3. OpenAI API key appears to be a placeholder
Field: llm.openai.api_key, Value: your_api_key_here
Suggestion: Replace with your actual API key
Common Configuration Errorsâ
Schema Validation Errorsâ
Type Mismatches
# â String where boolean expected
execution:
parallel_execution: "true" # Should be: true
# â String where number expected
llm:
openai:
temperature: "0.7" # Should be: 0.7
# â Number where string expected
paths:
custom_agents: 123 # Should be: "./custom_agents"
Path Configuration Errorsâ
Invalid Path References
# â Directory specified for file path
csv_path: "./workflows/" # Should be: "./workflows/main.csv"
# â Non-existent parent directory
paths:
custom_agents: "/nonexistent/agents" # Parent /nonexistent/ doesn't exist
LLM Configuration Errorsâ
API Key Issues
llm:
openai:
api_key: "your_api_key" # â Placeholder value
api_key: "sk-123" # â ī¸ Too short
api_key: "" # â ī¸ Empty (check environment)
Model Configuration Issues
llm:
openai:
model: 123 # â Should be string
temperature: "hot" # â Should be number
Best Practicesâ
Configuration Organizationâ
- Logical Grouping: Group related settings in appropriate sections
- Environment Variables: Use environment variables for sensitive data
- Default Values: Rely on system defaults for optional settings
- Documentation: Comment complex configurations
Development Environmentâ
- Local Configuration: Keep local config separate from version control
- Environment-Specific: Use different configs for dev/staging/production
- Validation First: Always validate before deployment
- Secret Management: Never commit API keys to version control
Production Deploymentâ
- Complete Validation: Run full validation before deployment
- Environment Variables: Use environment variables for production secrets
- Path Verification: Ensure all paths are accessible in production environment
- Monitoring Setup: Configure tracing for production monitoring
Advanced Configurationâ
Multiple LLM Providersâ
llm:
openai:
api_key: "sk-..."
model: "gpt-4"
temperature: 0.7
anthropic:
api_key: "sk-ant-..."
model: "claude-3-5-sonnet-20241022"
temperature: 0.5
google:
api_key: "AIza..."
model: "gemini-1.5-pro-latest"
Custom Path Configurationâ
paths:
custom_agents: "./agents"
functions: "./functions"
compiled_graphs: "./build/graphs"
logs: "./logs"
cache: "./cache"
Advanced Execution Policiesâ
execution:
timeout_seconds: 300
retry_attempts: 3
success_policy:
type: "critical_nodes"
critical_nodes: ["validation", "approval", "finalization"]
failure_policy:
type: "custom"
custom_function: "handle_workflow_failure"
Comprehensive Tracing Setupâ
tracing:
enabled: true
mode: "langsmith"
project: "production_agentmap"
langsmith_api_key: "ls_..."
tags: ["production", "v2.1"]
metadata:
environment: "prod"
version: "2.1.0"
Related Documentationâ
- Validation System Overview: Complete validation system architecture
- Configuration Reference: Complete configuration options
- Environment Variables: Environment setup guide
- CLI Validation Commands: Command-line validation tools
- LLM Service Configuration: LLM provider setup details
Next Stepsâ
- Validate Your Config: Run
agentmap validate config --config your_config.yaml
- Fix Configuration Issues: Address errors and warnings systematically
- Set Up Environment: Configure environment variables for production
- Complete Validation: Use validation cache for optimal performance