Skip to content

Conversation

wojons
Copy link

@wojons wojons commented Aug 21, 2025

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_BASE
  • A0_CHAT_MODEL_CTX_LENGTH, A0_CHAT_MODEL_CTX_HISTORY, A0_CHAT_MODEL_VISION
  • A0_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_BASE
  • A0_UTIL_MODEL_CTX_LENGTH, A0_UTIL_MODEL_CTX_INPUT
  • A0_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_BASE
  • A0_EMBED_MODEL_RL_REQUESTS, A0_EMBED_MODEL_RL_INPUT

Browser Model Configuration

  • A0_BROWSER_MODEL_PROVIDER, A0_BROWSER_MODEL_NAME, A0_BROWSER_MODEL_API_BASE
  • A0_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_INTERVAL
  • A0_MEMORY_RECALL_HISTORY_LEN, A0_MEMORY_RECALL_MEMORIES_MAX_SEARCH, A0_MEMORY_RECALL_SOLUTIONS_MAX_SEARCH
  • A0_MEMORY_RECALL_MEMORIES_MAX_RESULT, A0_MEMORY_RECALL_SOLUTIONS_MAX_RESULT
  • A0_MEMORY_RECALL_SIMILARITY_THRESHOLD, A0_MEMORY_RECALL_QUERY_PREP, A0_MEMORY_RECALL_POST_FILTER
  • A0_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_GROQ
  • A0_API_KEY_HUGGINGFACE, A0_API_KEY_LM_STUDIO, A0_API_KEY_MISTRAL, A0_API_KEY_OLLAMA
  • A0_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_TIMEOUT
  • A0_TTS_KOKORO

MCP Configuration

  • A0_MCP_SERVERS, A0_MCP_CLIENT_INIT_TIMEOUT, A0_MCP_CLIENT_TOOL_TIMEOUT
  • A0_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_SERVERS environment 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

wojons added 2 commits August 20, 2025 22:49
Enable full configuration of Agent Zero through Docker environment variables, addressing the need for simplified deployments and automation. This change allows all critical settings to be configured via environment variables prefixed with A0_, including:

- Core model configuration (chat, utility, embedding, browser)
- Memory system parameters
- Authentication and security settings
- API keys management
- Agent profiles and behavior
- Remote function call configuration
- Speech processing options
- MCP server settings

This implementation fulfills the requirement for easier Docker-based deployments and configuration management as requested in the ticket. All settings previously only available through the UI or settings.json can now be configured via environment variables, making containerized deployments more consistent and automation-friendly.

BREAKING CHANGE: Some environment variable names have been standardized to the A0_ prefix convention. Existing deployments using non-prefixed variables will need to update their configuration.
…ironment variable handling

- Restructured settings.py for better readability and maintainability
- Added dedicated _get_envvar_settings function for environment variable processing
- Renamed authentication environment variables from A0_AUTH_* to A0_SET_AUTH_* for consistency
- Added debug print statements for troubleshooting settings loading
- Normalized default settings to use hardcoded values instead of env var fallbacks

BREAKING CHANGE: Authentication environment variables have been renamed from A0_AUTH_LOGIN and A0_AUTH_PASSWORD to A0_SET_AUTH_LOGIN and A0_SET_AUTH_PASSWORD respectively. Update your environment configuration accordingly.
@wojons
Copy link
Author

wojons commented Aug 22, 2025

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.py for 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_* to A0_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_LOGINA0_SET_AUTH_LOGIN
    • A0_AUTH_PASSWORDA0_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.

@FringeNet
Copy link

FringeNet commented Aug 29, 2025

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.

copy[key] = value # make default instead

# mcp server token is set automatically
copy["mcp_server_token"] = create_auth_token()
Copy link

@FringeNet FringeNet Aug 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like so:

# mcp server token is set automatically (use custom external API key if provided)
    custom_external_key = dotenv.get_dotenv_value("A0_EXTERNAL_API_KEY")
    if custom_external_key:
        copy["mcp_server_token"] = custom_external_key
    else:
        copy["mcp_server_token"] = create_auth_token()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants