LemonCore.Config.Agent (lemon_core v0.1.0)

View Source

Agent behavior configuration.

Inspired by Ironclaw's config/agent.rs, this module handles agent-specific configuration like retry behavior, compaction settings, and shell configuration.

Configuration

Preferred configuration is loaded from [defaults] + [runtime]. Legacy [agent] remains supported for backward compatibility.

[defaults]
provider = "anthropic"
model = "claude-sonnet-4-20250514"
thinking_level = "medium"

[runtime]
extension_paths = ["./my-extensions"]
theme = "lemon"

[runtime.extensions]
enabled = true
auto_load_default_paths = false

[runtime.compaction]
enabled = true
reserve_tokens = 16384
keep_recent_tokens = 20000

[runtime.retry]
enabled = true
max_retries = 3
base_delay_ms = 1000

[runtime.shell]
path = "/bin/zsh"
command_prefix = ""

Environment variables override file configuration:

  • LEMON_DEFAULT_PROVIDER
  • LEMON_DEFAULT_MODEL
  • LEMON_DEFAULT_THINKING_LEVEL
  • LEMON_EXTENSION_PATHS (comma-separated)
  • LEMON_EXTENSIONS_ENABLED
  • LEMON_EXTENSIONS_AUTO_LOAD_DEFAULT_PATHS
  • LEMON_THEME

Summary

Functions

Returns the default agent configuration as a map.

Resolves agent configuration from settings and environment variables.

Types

t()

@type t() :: %LemonCore.Config.Agent{
  budget_defaults: %{max_children: integer()},
  cli: map(),
  compaction: %{
    enabled: boolean(),
    reserve_tokens: integer(),
    keep_recent_tokens: integer()
  },
  default_model: String.t(),
  default_provider: String.t(),
  default_thinking_level: String.t(),
  extension_paths: [String.t()],
  extensions: %{enabled: boolean(), auto_load_default_paths: boolean()},
  provider_routing: map(),
  retry: %{enabled: boolean(), max_retries: integer(), base_delay_ms: integer()},
  shell: %{path: String.t() | nil, command_prefix: String.t() | nil},
  theme: String.t()
}

Functions

defaults()

@spec defaults() :: map()

Returns the default agent configuration as a map.

This is used as the base configuration that gets overridden by user settings.

resolve(settings)

@spec resolve(map()) :: t()

Resolves agent configuration from settings and environment variables.

Priority: environment variables > TOML config > defaults