Configuration Loading and Management API¶
This section documents the HoloDeck configuration system, including YAML loading, validation, environment variable substitution, and default configuration management.
Overview¶
The configuration system is built on three pillars:
- Loading: Parse YAML agent configuration files
- Validation: Validate against Pydantic models with detailed error messages
- Merging: Combine default settings, user config, and environment overrides
ConfigLoader¶
The main entry point for loading HoloDeck agent configurations.
ConfigLoader()
¶
Loads and validates agent configuration from YAML files.
This class handles: - Parsing YAML files into Python dictionaries - Loading global configuration from ~/.holodeck/config.yaml - Merging configurations with proper precedence - Resolving file references (instructions, tools) - Converting validation errors into human-readable messages - Environment variable substitution
Initialize the ConfigLoader.
Source code in src/holodeck/config/loader.py
151 152 153 | |
Environment Variable Utilities¶
Support for dynamic configuration using environment variables with ${VAR_NAME} pattern.
substitute_env_vars(text)
¶
Substitute environment variables in text using ${VAR_NAME} pattern.
Replaces all occurrences of ${VAR_NAME} with the corresponding environment variable value. Raises ConfigError if a referenced variable does not exist.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Text potentially containing ${VAR_NAME} patterns |
required |
Returns:
| Type | Description |
|---|---|
str
|
Text with all environment variables substituted |
Raises:
| Type | Description |
|---|---|
ConfigError
|
If a referenced environment variable does not exist |
Example
import os os.environ["API_KEY"] = "secret123" substitute_env_vars("key: ${API_KEY}") 'key: secret123'
Source code in src/holodeck/config/env_loader.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | |
get_env_var(key, default=None)
¶
Get environment variable with optional default.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Environment variable name |
required |
default
|
Any
|
Default value if variable not set |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
Environment variable value or default |
Source code in src/holodeck/config/env_loader.py
58 59 60 61 62 63 64 65 66 67 68 | |
load_env_file(path)
¶
Load environment variables from a .env file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path to .env file |
required |
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
Dictionary of loaded environment variables |
Raises:
| Type | Description |
|---|---|
ConfigError
|
If file cannot be read |
Source code in src/holodeck/config/env_loader.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
Configuration Validation¶
Schema validation and error normalization utilities for configuration validation.
normalize_errors(errors)
¶
Convert raw error messages to human-readable format.
Processes error messages to be more user-friendly and actionable, removing technical jargon where possible.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
errors
|
list[str]
|
List of error message strings |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
List of normalized, human-readable error messages |
Source code in src/holodeck/config/validator.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | |
flatten_pydantic_errors(exc)
¶
Flatten Pydantic ValidationError into human-readable messages.
Converts Pydantic's nested error structure into a flat list of user-friendly error messages that include field names and descriptions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exc
|
ValidationError
|
Pydantic ValidationError exception |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
List of human-readable error messages, one per field error |
Example
from pydantic import BaseModel, ValidationError class Model(BaseModel): ... name: str try: ... Model(name=123) ... except ValidationError as e: ... msgs = flatten_pydantic_errors(e) ... # msgs contains human-readable descriptions
Source code in src/holodeck/config/validator.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
validate_field_exists(data, field, field_type)
¶
Validate that a required field exists and has correct type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Any]
|
Dictionary to validate |
required |
field
|
str
|
Field name to check |
required |
field_type
|
type
|
Expected type for the field |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If field is missing or has wrong type |
Source code in src/holodeck/config/validator.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |
validate_mutually_exclusive(data, fields)
¶
Validate that exactly one of the given fields is present.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Any]
|
Dictionary to validate |
required |
fields
|
list[str]
|
List of mutually exclusive field names |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If not exactly one field is present |
Source code in src/holodeck/config/validator.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
validate_range(value, min_val, max_val, name='value')
¶
Validate that a numeric value is within a range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
float
|
Value to validate |
required |
min_val
|
float
|
Minimum allowed value (inclusive) |
required |
max_val
|
float
|
Maximum allowed value (inclusive) |
required |
name
|
str
|
Name of the field for error messages |
'value'
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If value is outside the range |
Source code in src/holodeck/config/validator.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | |
validate_enum(value, allowed, name='value')
¶
Validate that a string is one of allowed values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
Value to validate |
required |
allowed
|
list[str]
|
List of allowed values |
required |
name
|
str
|
Name of the field for error messages |
'value'
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If value is not in allowed list |
Source code in src/holodeck/config/validator.py
138 139 140 141 142 143 144 145 146 147 148 149 150 | |
validate_path_exists(path, description='file')
¶
Validate that a file or directory exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path to validate |
required |
description
|
str
|
Description of path for error messages |
'file'
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If path does not exist |
Source code in src/holodeck/config/validator.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
Default Configuration¶
Utilities for generating default configuration templates for common components.
get_default_model_config(provider='openai')
¶
Get default model configuration for a provider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
str
|
LLM provider name (openai, azure_openai, anthropic, ollama) |
'openai'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary with default model configuration |
Source code in src/holodeck/config/defaults.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | |
get_default_tool_config(tool_type=None)
¶
Get default configuration template for a tool type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool_type
|
str | None
|
Tool type (vectorstore, function, mcp, prompt). If None, returns generic. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary with default tool configuration |
Source code in src/holodeck/config/defaults.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
get_default_evaluation_config(metric_name=None)
¶
Get default evaluation configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metric_name
|
str | None
|
Specific metric name. If None, returns generic structure. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary with default evaluation configuration |
Source code in src/holodeck/config/defaults.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
Configuration Merging¶
ConfigMerger
¶
Merges configurations with proper precedence and inheritance rules.
merge_agent_with_global(agent_config, global_config)
staticmethod
¶
Merge agent configuration with global configuration.
Agent-level settings take precedence. When inherit_global is False, only agent settings are used.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_config
|
dict[str, Any]
|
Agent configuration from agent.yaml |
required |
global_config
|
GlobalConfig | None
|
Merged global configuration (user + project level) |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Merged configuration dict with agent settings taking precedence |
Source code in src/holodeck/config/merge.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
merge_global_configs(user_config, project_config)
staticmethod
¶
Merge user-level and project-level global configurations.
Project-level config overrides user-level config when both are present.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_config
|
GlobalConfig | None
|
Global configuration from ~/.holodeck/config.yml|yaml |
required |
project_config
|
GlobalConfig | None
|
Global configuration from project root config.yml|yaml |
required |
Returns:
| Type | Description |
|---|---|
GlobalConfig | None
|
Merged GlobalConfig instance, or None if neither config exists |
Source code in src/holodeck/config/merge.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
Related Documentation¶
- Data Models: Configuration model definitions
- CLI Commands: CLI API reference
- YAML Schema: Agent configuration YAML format