Agent Configuration System
This comprehensive guide covers the complete agent configuration system in AgenticGoKit, including configuration-driven development, validation, hot-reload, and management tools.
Table of Contents
- Overview
- Configuration Structure
- Agent Configuration
- Configuration Resolution
- Validation System
- Hot-Reload Support
- CLI Management Tools
- Template System
- Best Practices
- Migration Guide
- Troubleshooting
Overview
The AgenticGoKit agent configuration system provides a comprehensive, flexible approach to defining and managing multi-agent systems through configuration files rather than hardcoded values.
Key Features
- Configuration-Driven Development: Define agents through TOML configuration
- Comprehensive Validation: Extensive validation with helpful error messages
- Hot-Reload Support: Dynamic configuration updates without restart
- Environment Overrides: Environment variable support for deployment
- Template System: Pre-built templates for common use cases
- CLI Management: Powerful CLI tools for configuration management
- Performance Optimization: Built-in performance recommendations
Benefits
- Rapid Development: Create sophisticated agents without coding
- Easy Deployment: Environment-specific configurations
- Maintainability: Centralized configuration management
- Flexibility: Runtime configuration changes
- Reliability: Comprehensive validation and error handling
Configuration Structure
Basic Configuration File (agentflow.toml
)
# Project Information
[agent_flow]
name = "my-agent-system"
version = "1.0.0"
provider = "openai"
# Global LLM Configuration
[llm]
provider = "openai"
model = "gpt-4"
temperature = 0.7
max_tokens = 2000
# Runtime Settings
[runtime]
max_concurrent_agents = 10
timeout_seconds = 30
# Logging Configuration
[logging]
level = "info"
format = "json"
# Agent Definitions
[agents.researcher]
role = "research_specialist"
description = "Conducts comprehensive research on various topics"
system_prompt = """
You are a research specialist focused on gathering accurate information.
Your role is to find authoritative sources and provide well-researched content.
"""
capabilities = ["information_gathering", "fact_checking", "source_identification"]
enabled = true
timeout_seconds = 45
# Agent-specific LLM overrides
[agents.researcher.llm]
temperature = 0.3
max_tokens = 2500
# Retry policy for reliability
[agents.researcher.retry_policy]
max_retries = 3
base_delay_ms = 1000
max_delay_ms = 5000
backoff_factor = 2.0
# Rate limiting
[agents.researcher.rate_limit]
requests_per_second = 10
burst_size = 20
# Agent metadata
[agents.researcher.metadata]
specialization = "research"
priority = "high"
cost_tier = "standard"
# Orchestration Configuration
[orchestration]
mode = "sequential"
timeout_seconds = 300
sequential_agents = ["researcher", "analyzer", "writer"]
# Memory System (optional)
[agent_memory]
provider = "pgvector"
connection = "postgres://user:password@localhost:15432/agentflow"
dimensions = 1536
enable_rag = true
chunk_size = 1500
chunk_overlap = 150
# MCP Configuration (optional)
[mcp]
enabled = true
enable_discovery = true
connection_timeout = 5000
[[mcp.servers]]
name = "web_search"
type = "stdio"
command = "npx @modelcontextprotocol/server-brave-search"
enabled = true
Agent Configuration
Core Agent Settings
Every agent requires these fundamental settings:
[agents.agent_name]
role = "agent_role" # Functional role identifier
description = "Agent description" # Human-readable description
system_prompt = """Multi-line prompt""" # Detailed system instructions
capabilities = ["cap1", "cap2"] # List of agent capabilities
enabled = true # Enable/disable agent
timeout_seconds = 30 # Execution timeout
Advanced Agent Settings
LLM Configuration Override
[agents.agent_name.llm]
provider = "openai" # Override global provider
model = "gpt-4" # Specific model
temperature = 0.3 # Creativity control
max_tokens = 2000 # Response length limit
top_p = 0.9 # Nucleus sampling
frequency_penalty = 0.1 # Repetition penalty
presence_penalty = 0.1 # Topic diversity
Retry Policy Configuration
[agents.agent_name.retry_policy]
max_retries = 3 # Maximum retry attempts
base_delay_ms = 1000 # Initial delay
max_delay_ms = 5000 # Maximum delay cap
backoff_factor = 2.0 # Exponential backoff
Rate Limiting
[agents.agent_name.rate_limit]
requests_per_second = 10 # Rate limit
burst_size = 20 # Burst capacity
Metadata and Tagging
[agents.agent_name.metadata]
specialization = "data_processing" # Agent specialization
priority = "high" # Processing priority
cost_tier = "premium" # Cost classification
team = "research" # Team assignment
version = "2.1" # Agent version
Capability System
AgenticGoKit includes a comprehensive capability system:
Research Capabilities
information_gathering
- Web search and data collectionfact_checking
- Information verificationsource_identification
- Source credibility assessmentdata_processing
- Data cleaning and transformation
Analysis Capabilities
pattern_recognition
- Pattern detection in datatrend_analysis
- Trend identification and analysisinsight_generation
- Insight extraction from datadata_analysis
- Statistical and analytical processing
Content Capabilities
text_analysis
- Text processing and analysissummarization
- Content summarizationtranslation
- Language translationcontent_creation
- Original content generationediting
- Content editing and improvement
Development Capabilities
code_generation
- Code creation and scaffoldingcode_review
- Code quality assessmentdebugging
- Error identification and fixingtesting
- Test creation and executiondocumentation
- Documentation generation
Configuration Resolution
The configuration system uses a hierarchical resolution approach:
Resolution Order
- Environment Variables (highest priority)
- Agent-Specific Configuration
- Global Configuration
- System Defaults (lowest priority)
Environment Variable Overrides
# Global LLM settings
export AGENTFLOW_LLM_PROVIDER="azure"
export AGENTFLOW_LLM_TEMPERATURE="0.5"
export AGENTFLOW_LLM_MAX_TOKENS="1500"
# Agent-specific settings
export AGENTFLOW_AGENT_RESEARCHER_ROLE="senior_researcher"
export AGENTFLOW_AGENT_RESEARCHER_TIMEOUT_SECONDS="60"
# Agent-specific LLM settings
export AGENTFLOW_AGENT_RESEARCHER_LLM_TEMPERATURE="0.2"
export AGENTFLOW_AGENT_RESEARCHER_LLM_MAX_TOKENS="3000"
Configuration Resolution Example
// Load and resolve configuration
config, err := core.LoadConfig("agentflow.toml")
if err != nil {
log.Fatal(err)
}
// Create resolver
resolver := core.NewConfigResolver()
// Resolve agent configuration
resolvedConfig, err := resolver.ResolveAgentConfig("researcher", config)
if err != nil {
log.Fatal(err)
}
// Use resolved configuration
fmt.Printf("Agent: %s\n", resolvedConfig.Name)
fmt.Printf("Role: %s\n", resolvedConfig.Role)
fmt.Printf("Temperature: %.2f\n", resolvedConfig.LLMConfig.Temperature)
Validation System
Comprehensive Validation
The validation system performs extensive checks:
Configuration Structure Validation
- TOML syntax and structure
- Required field presence
- Data type validation
- Value range validation
Agent Configuration Validation
- Role and capability validation
- System prompt completeness
- LLM parameter ranges
- Timeout and retry settings
Cross-Reference Validation
- Orchestration agent references
- Capability consistency
- Provider compatibility
Performance Validation
- Resource usage optimization
- Timeout recommendations
- Cost optimization suggestions
Using the Validation System
// Create validator
validator := core.NewDefaultConfigValidator()
// Validate complete configuration
errors := validator.ValidateConfig(config)
// Process validation results
for _, err := range errors {
fmt.Printf("Field: %s\n", err.Field)
fmt.Printf("Issue: %s\n", err.Message)
fmt.Printf("Suggestion: %s\n", err.Suggestion)
}
CLI Validation
# Basic validation
agentcli validate
# Comprehensive validation with suggestions
agentcli validate --level strict --verbose
# Validate specific aspects
agentcli validate --scope agents-only
agentcli validate --scope config-only
# Output in different formats
agentcli validate --output json
agentcli validate --output yaml
Hot-Reload Support
Configuration Hot-Reload
The system supports dynamic configuration updates:
// Create config reloader
reloader, err := core.NewConfigReloader("agentflow.toml")
if err != nil {
log.Fatal(err)
}
// Set up change handler
reloader.OnConfigChange(func(newConfig *core.Config) {
fmt.Println("Configuration updated!")
// Update agents with new configuration
})
// Start watching for changes
reloader.Start()
defer reloader.Stop()
Safe Reload Process
- File Change Detection: Monitor configuration file changes
- Validation: Validate new configuration before applying
- Rollback: Automatic rollback on validation failure
- Agent Update: Update running agents with new settings
- Notification: Notify system of successful updates
Hot-Reload Features
- Validation Before Apply: Prevents invalid configurations
- Atomic Updates: All-or-nothing configuration changes
- Rollback Support: Automatic rollback on failures
- Event Notifications: Configuration change events
- Graceful Updates: Non-disruptive agent updates
CLI Management Tools
Configuration Validation
# Validate current project
agentcli validate
# Validate with comprehensive checks
agentcli validate --level complete --verbose
# Validate specific configuration file
agentcli validate my-config.toml
# Show optimization suggestions
agentcli validate --suggestions
Configuration Generation
# Generate configuration from existing code
agentcli config generate
# Generate to specific file
agentcli config generate my-config.toml
# Generate in different format
agentcli config generate --format yaml config.yaml
Configuration Migration
# Migrate to latest format
agentcli config migrate
# Migrate specific file
agentcli config migrate old-config.toml
# Preview migration changes
agentcli config migrate --dry-run
Configuration Optimization
# Optimize for performance
agentcli config optimize --focus performance
# Show optimization recommendations
agentcli config optimize --recommend-only
# Optimize specific aspects
agentcli config optimize --focus cost
agentcli config optimize --focus reliability
Template-Based Configuration
# List available templates
agentcli config template --list
# Generate from template
agentcli config template research-assistant > config.toml
# Customize template
agentcli config template rag-system --memory pgvector --embedding openai
Template System
Available Templates
Research Assistant
agentcli create research-project --template research-assistant
- Multi-agent research system
- Web search and fact-checking
- Information synthesis
- Citation management
Content Creation Pipeline
agentcli create content-system --template content-creation
- Research and writing workflow
- SEO optimization
- Quality assurance
- Multi-format output
Customer Support System
agentcli create support-system --template customer-support
- Ticket classification and routing
- Automated resolution
- Escalation management
- Satisfaction tracking
RAG System
agentcli create knowledge-base --template custom-rag
- Document processing and indexing
- Semantic search and retrieval
- Context-aware responses
- Multi-modal support
Custom Templates
Create custom templates in YAML format:
name: "Custom Template"
description: "Template for specific use case"
features:
- "custom-feature"
config:
numAgents: 3
provider: "openai"
orchestrationMode: "sequential"
agents:
agent1:
role: "custom_role"
description: "Custom agent"
capabilities: ["custom_capability"]
systemPrompt: |
Custom system prompt...
Best Practices
Configuration Organization
- Logical Grouping: Group related agents together
- Consistent Naming: Use descriptive, consistent names
- Documentation: Include clear descriptions and comments
- Version Control: Track configuration changes
- Environment Separation: Separate configs for dev/staging/prod
Agent Design
- Single Responsibility: Each agent should have a clear, focused role
- Capability Alignment: Capabilities should match agent functions
- Prompt Engineering: Invest time in effective system prompts
- Performance Tuning: Optimize LLM parameters for use case
- Error Handling: Configure appropriate retry policies
Performance Optimization
- Timeout Management: Set appropriate timeouts for each agent
- Resource Limits: Configure memory and token limits
- Rate Limiting: Prevent API rate limit issues
- Caching: Use caching for repeated operations
- Monitoring: Track performance metrics
Security Considerations
- Credential Management: Use environment variables for secrets
- Input Validation: Validate all configuration inputs
- Access Control: Limit configuration file access
- Audit Logging: Log configuration changes
- Backup Strategy: Regular configuration backups
Migration Guide
From Hardcoded to Configuration-Driven
Step 1: Generate Initial Configuration
# Generate configuration from existing code
agentcli config generate
Step 2: Review and Customize
# Validate generated configuration
agentcli validate --level complete
# Optimize configuration
agentcli config optimize
Step 3: Update Agent Code
// Before: Hardcoded agent
type ResearchAgent struct {
llm core.ModelProvider
}
func (a *ResearchAgent) Run(ctx context.Context, event core.Event, state core.State) (core.AgentResult, error) {
systemPrompt := "You are a research specialist..." // Hardcoded
temperature := 0.3 // Hardcoded
// ...
}
// After: Configuration-driven agent
type ConfigurableResearchAgent struct {
config core.ResolvedAgentConfig
llm core.ModelProvider
}
func NewConfigurableResearchAgent(config core.ResolvedAgentConfig, llm core.ModelProvider) *ConfigurableResearchAgent {
return &ConfigurableResearchAgent{
config: config,
llm: llm,
}
}
func (a *ConfigurableResearchAgent) Run(ctx context.Context, event core.Event, state core.State) (core.AgentResult, error) {
systemPrompt := a.config.SystemPrompt // From configuration
temperature := a.config.LLMConfig.Temperature // From configuration
// ...
}
Step 4: Test and Validate
# Test with new configuration
go run . -m "test message"
# Validate configuration
agentcli validate --level strict
Version Migration
Configuration Format Updates
When AgenticGoKit introduces new configuration formats:
# Check current version compatibility
agentcli config migrate --dry-run
# Migrate to latest format
agentcli config migrate --backup
# Validate migrated configuration
agentcli validate
Troubleshooting
Common Issues
Configuration Loading Errors
Problem: Configuration file not found or invalid syntax
Solution:
# Check file exists and has correct syntax
agentcli validate --scope config-only
# Generate new configuration if needed
agentcli config generate
Agent Configuration Errors
Problem: Agent configuration validation failures
Solution:
# Validate agent configurations specifically
agentcli validate --scope agents-only --verbose
# Check capability names and requirements
agentcli validate --level complete
Environment Override Issues
Problem: Environment variables not being applied
Solution:
# Check environment variable names
echo $AGENTFLOW_LLM_PROVIDER
echo $AGENTFLOW_AGENT_RESEARCHER_ROLE
# Validate resolved configuration
agentcli validate --verbose
Hot-Reload Problems
Problem: Configuration changes not being applied
Solution:
// Check file watcher is running
reloader.IsWatching() // Should return true
// Check for validation errors in logs
// Ensure file permissions allow reading
Performance Issues
High Memory Usage
Problem: Agents consuming too much memory
Solution:
# Optimize for memory usage
agentcli config optimize --focus memory
# Check token limits and batch sizes
agentcli validate --level strict
Slow Response Times
Problem: Agents taking too long to respond
Solution:
# Optimize for performance
agentcli config optimize --focus performance
# Check timeout settings and LLM parameters
agentcli validate --suggestions
Debugging Tools
Configuration Inspection
# Show resolved configuration
agentcli config show --resolved
# Compare configurations
agentcli config diff config1.toml config2.toml
# Validate specific agent
agentcli validate --agent researcher
Logging and Monitoring
[logging]
level = "debug"
format = "json"
[runtime]
enable_metrics = true
metrics_port = 8080
Advanced Topics
Custom Validation Rules
// Create custom validation rule
type CustomValidationRule struct{}
func (r *CustomValidationRule) Name() string {
return "custom_rule"
}
func (r *CustomValidationRule) Description() string {
return "Custom validation logic"
}
func (r *CustomValidationRule) Validate(config *core.Config) []core.ValidationError {
var errors []core.ValidationError
// Custom validation logic
return errors
}
// Add to validator
validator := core.NewDefaultConfigValidator()
validator.AddValidationRule(&CustomValidationRule{})
Configuration Preprocessing
// Custom configuration preprocessor
type ConfigPreprocessor struct{}
func (p *ConfigPreprocessor) Preprocess(config *core.Config) (*core.Config, error) {
// Apply custom transformations
for name, agent := range config.Agents {
if agent.Role == "" {
agent.Role = fmt.Sprintf("%s_role", name)
config.Agents[name] = agent
}
}
return config, nil
}
Integration with External Systems
# External configuration sources
[external_config]
enabled = true
source = "consul"
endpoint = "http://consul:8500"
prefix = "agentflow/"
# Configuration webhooks
[webhooks]
on_config_change = "http://monitoring:8080/config-changed"
on_validation_error = "http://alerts:8080/validation-error"
Conclusion
The AgenticGoKit agent configuration system provides a powerful, flexible foundation for building and managing sophisticated multi-agent systems. By leveraging configuration-driven development, comprehensive validation, hot-reload capabilities, and powerful management tools, you can create maintainable, scalable, and reliable AI applications.
Key takeaways:
- Start with Templates: Use pre-built templates for common patterns
- Validate Early and Often: Use comprehensive validation to catch issues
- Optimize Continuously: Regularly review and optimize configurations
- Monitor Performance: Track metrics and adjust settings as needed
- Plan for Scale: Design configurations with growth in mind
For additional help and examples, refer to the template system documentation and CLI reference guides.