feat(config): implement comprehensive A0_ environment variable support
feat(config): Implement Comprehensive A0_ Environment Variable Support
Summary
This PR implements full configuration of Agent Zero through Docker environment variables, addressing the need for simplified deployments and automation. All critical settings can now be configured via environment variables prefixed with A0_, making containerized deployments more consistent and automation-friendly. #686
Test Container: wojons/agent-zero:v0.9.4-load-from-env
Changes Implemented
- Added comprehensive support for A0_ prefixed environment variables
- Enabled configuration of all system parameters through environment variables
- Updated settings loading logic to prioritize environment variables
- Maintained backward compatibility with existing .env and settings.json
Environment Variables Now Supported
Core Model Configuration
A0_CHAT_MODEL_PROVIDER,A0_CHAT_MODEL_NAME,A0_CHAT_MODEL_API_BASEA0_CHAT_MODEL_CTX_LENGTH,A0_CHAT_MODEL_CTX_HISTORY,A0_CHAT_MODEL_VISIONA0_CHAT_MODEL_RL_REQUESTS,A0_CHAT_MODEL_RL_INPUT,A0_CHAT_MODEL_RL_OUTPUT
Utility Model Configuration
A0_UTIL_MODEL_PROVIDER,A0_UTIL_MODEL_NAME,A0_UTIL_MODEL_API_BASEA0_UTIL_MODEL_CTX_LENGTH,A0_UTIL_MODEL_CTX_INPUTA0_UTIL_MODEL_RL_REQUESTS,A0_UTIL_MODEL_RL_INPUT,A0_UTIL_MODEL_RL_OUTPUT
Embedding Model Configuration
A0_EMBED_MODEL_PROVIDER,A0_EMBED_MODEL_NAME,A0_EMBED_MODEL_API_BASEA0_EMBED_MODEL_RL_REQUESTS,A0_EMBED_MODEL_RL_INPUT
Browser Model Configuration
A0_BROWSER_MODEL_PROVIDER,A0_BROWSER_MODEL_NAME,A0_BROWSER_MODEL_API_BASEA0_BROWSER_MODEL_VISION,A0_BROWSER_MODEL_RL_REQUESTS,A0_BROWSER_MODEL_RL_INPUT,A0_BROWSER_MODEL_RL_OUTPUT
Memory System Configuration
A0_MEMORY_RECALL_ENABLED,A0_MEMORY_RECALL_DELAYED,A0_MEMORY_RECALL_INTERVALA0_MEMORY_RECALL_HISTORY_LEN,A0_MEMORY_RECALL_MEMORIES_MAX_SEARCH,A0_MEMORY_RECALL_SOLUTIONS_MAX_SEARCHA0_MEMORY_RECALL_MEMORIES_MAX_RESULT,A0_MEMORY_RECALL_SOLUTIONS_MAX_RESULTA0_MEMORY_RECALL_SIMILARITY_THRESHOLD,A0_MEMORY_RECALL_QUERY_PREP,A0_MEMORY_RECALL_POST_FILTERA0_MEMORY_MEMORIZE_ENABLED,A0_MEMORY_MEMORIZE_CONSOLIDATION,A0_MEMORY_MEMORIZE_REPLACE_THRESHOLD
Authentication & Security
A0_AUTH_LOGIN,A0_AUTH_PASSWORD,A0_ROOT_PASSWORD,A0_RFC_PASSWORD
API Keys
A0_API_KEY_ANTHROPIC,A0_API_KEY_DEEPSEEK,A0_API_KEY_GOOGLE,A0_API_KEY_GROQA0_API_KEY_HUGGINGFACE,A0_API_KEY_LM_STUDIO,A0_API_KEY_MISTRAL,A0_API_KEY_OLLAMAA0_API_KEY_OPENAI,A0_API_KEY_AZURE,A0_API_KEY_OPENROUTER,A0_API_KEY_SAMBANOVA,A0_API_KEY_VENICE,A0_API_KEY_OTHER
Agent Configuration
A0_AGENT_PROFILE,A0_AGENT_MEMORY_SUBDIR,A0_AGENT_KNOWLEDGE_SUBDIR
Remote Function Calls
A0_RFC_AUTO_DOCKER,A0_RFC_URL,A0_RFC_PORT_HTTP,A0_RFC_PORT_SSH
Speech Configuration
A0_STT_MODEL_SIZE,A0_STT_LANGUAGE,A0_STT_SILENCE_THRESHOLD,A0_STT_SILENCE_DURATION,A0_STT_WAITING_TIMEOUTA0_TTS_KOKORO
MCP Configuration
A0_MCP_SERVERS,A0_MCP_CLIENT_INIT_TIMEOUT,A0_MCP_CLIENT_TOOL_TIMEOUTA0_MCP_SERVER_ENABLED,A0_A2A_SERVER_ENABLED
Breaking Changes
- Some environment variable names have been standardized to the
A0_prefix convention - Existing deployments using non-prefixed variables will need to update their configuration
- The
A0_MCP_SERVERSenvironment variable now expects a JSON string format
Notes
A0_ROOT_PASSWORD - was not able to figure out how to get this one to work assume i am missing something simple.
A0_RFC_PASSWORD- was not able to test this
A0_MCP_SERVERS - tested and working but might need to check for invaild json and set to blank but waiting feedback
refactor(settings): Reorganize settings loading logic and improve environment variable handling
Summary
This PR refactors the settings system to improve maintainability and consistency in environment variable handling. The changes focus on restructuring the settings loading logic, introducing dedicated functions for environment variable processing, and standardizing naming conventions.
Key Changes
Settings System Restructuring
- Completely reorganized
settings.pyfor better readability and maintainability - Introduced dedicated
_get_envvar_settings()function for environment variable processing - Separated concerns between default settings, environment variables, and file-based settings
- Added debug print statements for troubleshooting settings loading issues
Environment Variable Improvements
- Renamed authentication environment variables from
A0_AUTH_*toA0_SET_AUTH_*for consistency with other configuration variables - Normalized default settings to use hardcoded values instead of environment variable fallbacks
- Improved handling of API keys through environment variables
- Enhanced error logging for settings loading failures
Breaking Changes
-
Authentication environment variables have been renamed but the old ones are still vaild:
A0_AUTH_LOGIN→A0_SET_AUTH_LOGINA0_AUTH_PASSWORD→A0_SET_AUTH_PASSWORD
Update your environment configuration accordingly. This change was made to standardize the naming convention across all configuration variables.
Impact
- Improves the maintainability of the settings system
- Makes environment variable handling more consistent and predictable
- Simplifies debugging of configuration issues
- Provides a cleaner separation between different configuration sources
This refactor addresses technical debt in the settings system while maintaining all existing functionality. The changes are primarily structural and should not affect normal operation once environment variables are updated to the new naming convention.
Might be handy to include the ability to set the external api key as well, since its currently auto generated based on the login/password.
This would make it much easier to set up headless.