Overview
Goose’s configuration system supports:- Dynamic configuration keys
- Type-safe value retrieval via serde
- Environment variable overrides
- YAML-based persistence (
~/.config/goose/config.yaml) - Secure secret storage in system keyring
- File-based secret fallback
- Configuration migrations
Configuration Precedence
Values are loaded in order:- Environment variables (exact key match, e.g.,
OPENAI_API_KEY) - Configuration file (
~/.config/goose/config.yaml) - Default values (from
defaults.yamlor built-in defaults)
Secret Precedence
- Environment variables (exact key match)
- System keyring (macOS Keychain, Windows Credential Manager, Linux Secret Service)
- Secrets file (
~/.config/goose/secrets.yaml, if keyring disabled viaGOOSE_DISABLE_KEYRING)
Config Struct
crates/goose/src/config/base.rs:103-109
Constructor Methods
global()
Get the global Config instance.crates/goose/src/config/base.rs:237-239
Example:
new()
Create a Config with custom paths (primarily for testing).Path to YAML config file
Keyring service name
crates/goose/src/config/base.rs:245-255
new_with_file_secrets()
Create Config using file-based secrets.Path to config YAML
Path to secrets YAML
crates/goose/src/config/base.rs:261-274
Reading Configuration
get_param()
Get a configuration parameter with type inference.Configuration key (e.g., “openai_api_key”)
ConfigError::NotFound- Key not found in config, env, or defaultsConfigError::DeserializeError- Value cannot be deserialized to type T
all_values()
Get all configuration values as a HashMap.crates/goose/src/config/base.rs:338-347
Writing Configuration
set_param()
Set a configuration parameter.Configuration key
Value to store (must be Serialize)
remove_param()
Remove a configuration parameter.Configuration key to remove
Secret Management
set_secret()
Store a secret securely.Secret key
Secret value
get_secret()
Retrieve a secret.Secret key
remove_secret()
Delete a secret.Secret key to remove
all_secrets()
Get all secret keys (not values).File Operations
path()
Get the config file path.crates/goose/src/config/base.rs:300-302
exists()
Check if config file exists.crates/goose/src/config/base.rs:292-294
clear()
Delete the config file.crates/goose/src/config/base.rs:296-298
Built-in Configuration Keys
Goose recognizes several standard configuration keys:get_goose_mode()
Get the operating mode.GooseMode::Auto, GooseMode::Chat, or GooseMode::Agentic
GooseMode
crates/goose/src/config/goose_mode.rs
Other Built-in Keys
GOOSE_DISABLE_SESSION_NAMING- Disable auto-generated session namesGOOSE_TOOL_CALL_CUTOFF- Max tool calls before summarization (default: 10)GOOSE_AUTO_COMPACT_THRESHOLD- Context percentage to trigger auto-compaction (default: 0.8)
Error Types
ConfigError
crates/goose/src/config/base.rs:21-37
Configuration key not found
Value cannot be deserialized to requested type
I/O error reading/writing config file
Error accessing system keyring
Naming Conventions
Goose recommends:- Use
snake_casefor configuration keys - Prefix Goose-specific keys with
goose_(e.g.,goose_mode) - Environment variables use
UPPERCASE(e.g.,OPENAI_API_KEY) - The system automatically converts
snake_case→UPPERCASEwhen checking environment variables