This page documents how Agent Zero manages sensitive credentials and configuration through project-specific variables and secrets. Projects provide isolated storage for API keys, passwords, and other sensitive data that agents can use without directly seeing the values. This prevents credential leakage in logs, memory, and agent outputs while enabling secure automation.
For general configuration and settings management, see Settings System. For environment variables used during initial setup, see Environment Variables. For project directory structure and organization, see Project Structure.
Agent Zero stores secrets through a multi-layer system implemented in python/helpers/settings.py153-154 and managed by the secrets manager helper.
| Layer | Implementation | Scope | Code Reference |
|---|---|---|---|
Settings secrets Field | Settings.secrets: str | Project-scoped | python/helpers/settings.py153-154 |
.env File | /a0/usr/.env key=value | Global system credentials | python/helpers/settings.py450-453 |
| Settings Authentication | Settings.auth_login, auth_password, etc. | UI and system auth | python/helpers/settings.py123-125 |
Sources: python/helpers/settings.py53-160 python/helpers/settings.py440-460 python/helpers/settings.py490-508
Sources: README.md123-124 knowledge/main/about/installation.md169-183
The global .env file stores system authentication credentials and is separate from project-scoped secrets managed by the secrets manager.
/a0/usr/.env
The .env file stores system-level authentication only:
| Variable | Purpose | Code Reference |
|---|---|---|
AUTH_LOGIN | Web UI username | python/helpers/settings.py450 |
AUTH_PASSWORD | Web UI password | python/helpers/settings.py451 |
RFC_PASSWORD | Remote function call password | python/helpers/settings.py452 |
ROOT_PASSWORD | Container root password | python/helpers/settings.py453 |
API_KEY_* | LLM provider keys (legacy) | python/helpers/settings.py491-493 |
Authentication values are written back to .env via python/helpers/settings.py490-503:
Note: The .env file should not be version controlled. API keys stored here are legacy; new implementations use the secrets manager for project-scoped credentials.
Sources: python/helpers/settings.py440-460 python/helpers/settings.py490-508
Project-scoped secrets are managed by the SecretsManager class, which provides context-aware secret storage and retrieval.
From code in python/tools/browser_agent.py156-157:
| Method | Purpose | Returns | Code Reference |
|---|---|---|---|
load_secrets() | Load all secrets for current context | dict[str, str] | browser_agent.py157 |
read_secrets_raw() | Get raw secrets file content | str | settings.py458 |
get_masked_secrets() | Get secrets with values masked | str | settings.py314 |
save_secrets_with_merge(content) | Save secrets preserving comments/order | None | settings.py508 |
mask_values(text, placeholder) | Redact secret values from text | str | browser_agent.py219 |
From python/tools/browser_agent.py219:
This prevents secret values from appearing in agent prompts or outputs.
Secrets are stored in the Settings.secrets field python/helpers/settings.py154 and loaded via:
Sources: python/helpers/settings.py154 python/helpers/settings.py311-316 python/helpers/settings.py456-460 python/helpers/settings.py505-508 python/tools/browser_agent.py156-157 python/tools/browser_agent.py219
Secrets are loaded when a SecretsManager is instantiated with an AgentContext. The manager provides context-aware access to project-scoped secrets.
From python/tools/browser_agent.py156-171:
This ensures:
AgentContextSources: python/tools/browser_agent.py156-171 python/tools/browser_agent.py219 agent.py45-296
A key security feature is that agents can use secrets without seeing their values. This prevents credential leakage in conversation logs, memory storage, and agent outputs.
| Mechanism | Description | Example |
|---|---|---|
| Variable Substitution | Agent references $SECRET_NAME, replaced at runtime | $DATABASE_PASSWORD → actual value |
| Output Redaction | Secret values removed from tool outputs | p@ssw0rd123 → ***SECRET*** |
| Memory Isolation | Secrets never stored in agent memory/embeddings | No secret values in FAISS database |
| Log Sanitization | Chat logs and history exclude secret values | Conversation history safe to export |
The mask_values() method redacts secret values from any text output:
Before Masking:
After Masking:
From python/tools/browser_agent.py156-171:
secrets_dict = secrets_manager.load_secrets()sensitive_datamessage = secrets_manager.mask_values(message, placeholder="<secret>{key}</secret>")The browser-use library receives secrets in a format it can use (<secret>KEY_NAME</secret>), and the actual values are injected by the browser agent during execution. The main Agent Zero agent never sees the raw secret values.
Sources: python/tools/browser_agent.py156-171 python/tools/browser_agent.py219
Project-specific secrets ensure complete isolation between different projects, preventing credential leakage across client boundaries.
| Benefit | Description |
|---|---|
| Multi-Client Safety | Each client's credentials completely isolated |
| No Cross-Contamination | Project A agent cannot access Project B secrets |
| Audit Trail | Secret usage tracked per project |
| Compliance | Meets data separation requirements for regulated industries |
Scenario: Managing two clients with different API credentials.
Project Structure:
/a0/usr/projects/
├── acme-corp/
│ └── secrets/
│ └── credentials.env
│ ACME_API_KEY=acme_xxxxxxxxxxxxx
│ ACME_DB_PASSWORD=acme_secure_pass
│
└── globex-inc/
└── secrets/
└── credentials.env
GLOBEX_API_KEY=globex_yyyyyyyyyyyy
GLOBEX_DB_PASSWORD=globex_secure_pass
Agent in acme-corp project:
ACME_API_KEY and ACME_DB_PASSWORDGLOBEX_API_KEY or GLOBEX_DB_PASSWORD.env keys (e.g., OPENAI_API_KEY)Agent in globex-inc project:
GLOBEX_API_KEY and GLOBEX_DB_PASSWORDACME_API_KEY or ACME_DB_PASSWORD.env keys (e.g., OPENAI_API_KEY)Sources: README.md123-124 README.md32-34
Method 1: Direct File Edit
Edit /a0/usr/.env:
Add secrets:
Restart container for changes to take effect.
Method 2: Settings UI
.envMethod 1: File System
Create secret files in project's secrets/ directory:
Method 2: Via Agent (Future Enhancement)
Agents can be instructed to create secrets files programmatically:
Agent: "Create a secret in this project for DATABASE_PASSWORD with value from user"
User: "The password is: secure_db_pass_123"
Agent: *writes to secrets/database.env without exposing value*
To rotate a secret:
.env or project secrets/*.envFor active contexts, restart is required to load updated secrets.
Sources: docs/setup/installation.md291-303
The Settings TypedDict includes both variables and secrets fields python/helpers/settings.py153-154:
| Field | Purpose | Storage Format | Code Reference |
|---|---|---|---|
variables | Non-sensitive configuration values | String (likely key=value format) | settings.py153 |
secrets | Sensitive credentials | String (managed by SecretsManager) | settings.py154 |
Both are stored as strings in settings.json but are loaded and processed differently by the settings system.
The A0_SET_* prefix in .env provides initial defaults that are merged into settings.json:
From python/helpers/settings.py21-51:
Example .env configuration:
The A0_SET_* variables are only used if settings.json doesn't exist or is missing those values. Once settings are saved via the UI, settings.json takes precedence.
Sources: python/helpers/settings.py21-51 python/helpers/settings.py153-154 python/helpers/settings.py512-602
Tools access secrets via the SecretsManager obtained from AgentContext:
Reference: Tool base class in python/helpers/tool.py example usage in python/tools/browser_agent.py156-157
Extensions have access to the agent and can retrieve secrets the same way:
The Settings interface reads and writes secrets through the manager:
Reading (from python/helpers/settings.py311-316):
Writing (from python/helpers/settings.py505-508):
The save_secrets_with_merge method preserves comments and order in the secrets file, making manual editing easier.
Sources: python/helpers/settings.py311-316 python/helpers/settings.py505-508 python/tools/browser_agent.py156-157
Use project secrets for client-specific credentials
Use global secrets for shared services
Organize secrets by service
secrets/database.env - All database credentialssecrets/apis.env - External API keyssecrets/production.env - Production-only secretsNever commit secrets to version control
.env and secrets/ to .gitignore.env.example with dummy values for documentationUse descriptive secret names
STRIPE_PRODUCTION_KEY, ACME_CLIENT_API_KEYKEY1, PASSWORD, SECRETRotate secrets regularly
Audit secret access
For managing multiple clients:
/a0/usr/projects/
├── client-alpha/
│ ├── secrets/
│ │ ├── production.env # Production credentials
│ │ └── staging.env # Staging credentials
│ └── skills/
├── client-beta/
│ ├── secrets/
│ │ ├── api_keys.env # All API keys
│ │ └── databases.env # All DB credentials
│ └── skills/
└── internal-tools/
├── secrets/
│ └── github.env # GitHub tokens for repos
└── skills/
Each project maintains complete isolation of sensitive credentials.
Sources: README.md123-124 README.md32-34
Symptom: Tool or agent cannot access expected secret
Diagnostic Steps:
Verify secrets manager is initialized:
Check secret name (case-sensitive):
Verify secrets are loaded for context project:
Symptom: Secret value visible in agent output or logs
Solutions:
Apply output masking:
Check browser agent integration: From python/tools/browser_agent.py219:
Avoid printing secrets directly:
Symptom: Changes in Settings UI don't persist
Check:
Verify merge logic is preserving content: From python/helpers/settings.py505-508:
Ensure no exceptions during save:
Check logs for errors in _write_sensitive_settings()
Verify Settings.secrets field is being written:
Symptom: UI login fails or passwords don't work
Check:
Verify .env contains auth fields:
Check loading in settings: From python/helpers/settings.py450-453:
Restart container after .env changes
Sources: python/helpers/settings.py311-316 python/helpers/settings.py440-460 python/helpers/settings.py505-508 python/tools/browser_agent.py219
Agent Zero's variables and secrets system provides:
.env key=value syntaxThis architecture enables secure multi-client workflows where sensitive credentials are properly isolated and never leak into conversation logs, memory systems, or agent outputs.
For setting up projects with secrets, see Managing Projects. For understanding how project isolation works at the memory and knowledge level, see Project Isolation.
Refresh this wiki