Single source of truth for all agent tunables.
Reads user-facing settings from Minga.Config.Options and defines
sensible defaults for internal tunables. No other agent module should
define @default_* constants or call Config.get(:agent_*) directly.
Call resolve/0 once at session or provider init, then thread the
resulting %Config{} through state and function arguments.
Adding a new setting
- Add the field to the struct and
@type t - Add the default value in
defstruct - If user-configurable, register it in
Minga.Config.Optionsand read it inresolve/0 - If internal-only, the struct default is sufficient
Summary
Functions
Returns the explicitly configured model, or nil when the user has not chosen one.
Returns the explicitly configured model from a specific options server, or nil when unset.
Returns the model used for new sessions when the user has not explicitly configured one.
Returns the model used for new sessions from a specific options server.
Extracts the provider prefix from a model spec string.
Normalizes raw :agent_hooks config declarations into hook structs.
Builds a %Config{} from Options with struct defaults as fallbacks.
Returns the configured model, then the first available credential-backed model.
Returns the configured model from a specific options server, then the first available credential-backed model.
Returns the configured provider, falling back to :auto.
Splits a model spec into {model, provider} regardless of whether the user wrote provider:model or model@provider.
Strips the provider encoding from a model spec string.
Returns the internal sentinel used when no configured provider has an available model.
Returns a config with agent hooks disabled.
Types
@type t() :: %MingaAgent.Config{ agent_hooks: [MingaAgent.Hooks.Hook.t()], api_base_url: String.t(), api_base_url_override: String.t() | nil, api_endpoints: map() | nil, append_system_prompt: String.t(), approval_timeout_ms: pos_integer(), auto_context: boolean(), compaction_keep_recent: pos_integer(), compaction_threshold: float() | nil, destructive_tools: [String.t()], diff_size_threshold: pos_integer(), max_cost: float() | nil, max_file_size: pos_integer(), max_image_size: pos_integer(), max_mention_candidates: pos_integer(), max_retries: non_neg_integer(), max_tokens: pos_integer(), max_turns: pos_integer(), mcp_servers: [MingaAgent.MCP.ServerConfig.t() | map()], memory_max_tokens: pos_integer(), model: String.t(), models: [String.t()], notifications: boolean(), notify_debounce_ms: pos_integer(), notify_on: [atom()], panel_split: pos_integer(), prompt_cache: boolean(), provider: :auto | :native | String.t(), save_debounce_ms: pos_integer(), session_retention_days: pos_integer(), shell_debounce_ms: pos_integer(), subagent_timeout_ms: pos_integer(), system_prompt: String.t(), tool_approval: :destructive | :all | :none, tool_permissions: map() | nil }
Functions
@spec configured_model() :: String.t() | nil
Returns the explicitly configured model, or nil when the user has not chosen one.
@spec configured_model(Minga.Config.Options.server()) :: String.t() | nil
Returns the explicitly configured model from a specific options server, or nil when unset.
@spec default_model() :: String.t()
Returns the model used for new sessions when the user has not explicitly configured one.
@spec default_model(Minga.Config.Options.server()) :: String.t()
Returns the model used for new sessions from a specific options server.
Extracts the provider prefix from a model spec string.
Returns the provider name, or "" if no prefix is present.
@spec normalize_hooks(term()) :: [MingaAgent.Hooks.Hook.t()]
Normalizes raw :agent_hooks config declarations into hook structs.
@spec resolve() :: t()
Builds a %Config{} from Options with struct defaults as fallbacks.
Safe to call before the Options ETS table exists (e.g., in tests or standalone usage). When Options is unavailable, all fields use their struct defaults.
@spec resolve_model() :: String.t()
Returns the configured model, then the first available credential-backed model.
Safe to call before Config is running (catches exits). If no provider has credentials, returns the internal "unknown" sentinel rather than pretending a specific vendor model is ready.
@spec resolve_model(Minga.Config.Options.server()) :: String.t()
Returns the configured model from a specific options server, then the first available credential-backed model.
This keeps per-editor tests and embedded editors from depending on the global options server.
@spec resolve_provider() :: :auto | :native | String.t()
Returns the configured provider, falling back to :auto.
Safe to call before Config is running (catches exits).
Splits a model spec into {model, provider} regardless of whether the user wrote provider:model or model@provider.
Returns {bare_model, nil} when no provider is encoded in the string.
Examples
iex> MingaAgent.Config.split_model_spec("anthropic:claude-sonnet-4")
{"claude-sonnet-4", "anthropic"}
iex> MingaAgent.Config.split_model_spec("claude-sonnet-4@anthropic")
{"claude-sonnet-4", "anthropic"}
iex> MingaAgent.Config.split_model_spec("claude-sonnet-4")
{"claude-sonnet-4", nil}
Strips the provider encoding from a model spec string.
Returns the bare model name. If there's no provider encoding, returns the string unchanged.
@spec unconfigured_model() :: String.t()
Returns the internal sentinel used when no configured provider has an available model.
Returns a config with agent hooks disabled.