Skip to main content
The Config system provides flexible configuration management with environment variable overrides, YAML persistence, and secure secret storage.

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:
  1. Environment variables (exact key match, e.g., OPENAI_API_KEY)
  2. Configuration file (~/.config/goose/config.yaml)
  3. Default values (from defaults.yaml or built-in defaults)

Secret Precedence

  1. Environment variables (exact key match)
  2. System keyring (macOS Keychain, Windows Credential Manager, Linux Secret Service)
  3. Secrets file (~/.config/goose/secrets.yaml, if keyring disabled via GOOSE_DISABLE_KEYRING)

Config Struct

Source: crates/goose/src/config/base.rs:103-109

Constructor Methods

global()

Get the global Config instance.
Returns: Reference to the global singleton Config Source: crates/goose/src/config/base.rs:237-239 Example:

new()

Create a Config with custom paths (primarily for testing).
P: AsRef<Path>
required
Path to YAML config file
&str
required
Keyring service name
Source: crates/goose/src/config/base.rs:245-255

new_with_file_secrets()

Create Config using file-based secrets.
P1: AsRef<Path>
required
Path to config YAML
P2: AsRef<Path>
required
Path to secrets YAML
Source: crates/goose/src/config/base.rs:261-274

Reading Configuration

get_param()

Get a configuration parameter with type inference.
&str
required
Configuration key (e.g., “openai_api_key”)
Returns: Deserialized value of type T Errors:
  • ConfigError::NotFound - Key not found in config, env, or defaults
  • ConfigError::DeserializeError - Value cannot be deserialized to type T
Example:

all_values()

Get all configuration values as a HashMap.
Returns: All config keys and values Source: crates/goose/src/config/base.rs:338-347

Writing Configuration

set_param()

Set a configuration parameter.
&str
required
Configuration key
&T
required
Value to store (must be Serialize)
Example:

remove_param()

Remove a configuration parameter.
&str
required
Configuration key to remove

Secret Management

set_secret()

Store a secret securely.
&str
required
Secret key
&str
required
Secret value
Storage: Uses system keyring by default, falls back to encrypted file if keyring unavailable. Example:

get_secret()

Retrieve a secret.
&str
required
Secret key
Returns: Secret value Example:

remove_secret()

Delete a secret.
&str
required
Secret key to remove

all_secrets()

Get all secret keys (not values).
Returns: Vector of secret key names

File Operations

path()

Get the config file path.
Returns: Path to config.yaml Source: crates/goose/src/config/base.rs:300-302

exists()

Check if config file exists.
Source: crates/goose/src/config/base.rs:292-294

clear()

Delete the config file.
Source: 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.
Returns: GooseMode::Auto, GooseMode::Chat, or GooseMode::Agentic

GooseMode

Source: crates/goose/src/config/goose_mode.rs

Other Built-in Keys

  • GOOSE_DISABLE_SESSION_NAMING - Disable auto-generated session names
  • GOOSE_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

Source: crates/goose/src/config/base.rs:21-37
String
Configuration key not found
String
Value cannot be deserialized to requested type
std::io::Error
I/O error reading/writing config file
String
Error accessing system keyring

Naming Conventions

Goose recommends:
  • Use snake_case for 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_caseUPPERCASE when checking environment variables
Example:
  • Agent - Uses Config for provider settings
  • Session - Session-specific configuration