Module: Anima::Settings
- Defined in:
- lib/anima/settings.rb
Overview
User-facing configuration backed by ~/.anima/config.toml with hot-reload.
Reads the TOML config file on each access, re-parsing only when the file’s mtime has changed. The config file is created by the installer with all values set — it is the single source of truth for all settings.
Settings are grouped into sections that mirror the TOML file structure:
[llm] — Model selection and response limits
[timeouts] — Network and execution timeouts (seconds)
[shell] — Shell command output limits
[tools] — File and web tool limits
[session] — Conversation behavior
Defined Under Namespace
Classes: MissingConfigError, MissingSettingError
Constant Summary collapse
- DEFAULT_PATH =
File.("~/.anima/config.toml")
Class Method Summary collapse
-
.agent_name ⇒ String
The agent’s display name.
-
.analytical_brain_blocking_on_agent_message ⇒ Boolean
Run the analytical brain asynchronously after the main agent completes.
-
.analytical_brain_blocking_on_user_message ⇒ Boolean
Run the analytical brain synchronously before the main agent on user messages.
-
.analytical_brain_max_tokens ⇒ Integer
Maximum tokens per analytical brain response.
-
.analytical_brain_message_window ⇒ Integer
Number of recent messages to include in the analytical brain’s context window.
-
.api_timeout ⇒ Integer
LLM API request timeout.
-
.command_timeout ⇒ Integer
Shell command execution timeout.
-
.config_path ⇒ String
Active config file path.
-
.config_path=(path) ⇒ Object
Override config file path (for testing).
-
.default_view_mode ⇒ String
View mode applied to new sessions: “basic”, “verbose”, or “debug”.
-
.fast_model ⇒ String
Lightweight model for fast tasks (e.g. session naming).
-
.github_label ⇒ String
Label applied to agent-created feature request issues.
-
.github_repo ⇒ String
Repository for feature requests (
owner/repoformat). -
.interrupt_check_interval ⇒ Numeric
Polling interval for user interrupt checks during long-running commands.
-
.max_file_size ⇒ Integer
Maximum file size for read/edit operations (bytes).
-
.max_output_bytes ⇒ Integer
Maximum bytes of command output before truncation.
-
.max_read_bytes ⇒ Integer
Maximum bytes returned by the read_file tool.
-
.max_read_lines ⇒ Integer
Maximum lines returned by the read_file tool.
-
.max_subagent_response_chars ⇒ Integer
Maximum characters of sub-agent result before head+tail truncation.
-
.max_tokens ⇒ Integer
Maximum tokens per LLM response.
-
.max_tool_response_chars ⇒ Integer
Maximum characters of tool output before head+tail truncation.
-
.max_tool_rounds ⇒ Integer
Maximum consecutive tool execution rounds per LLM message.
-
.max_web_response_bytes ⇒ Integer
Maximum bytes from web GET responses.
-
.mcp_response_timeout ⇒ Integer
MCP server response timeout.
-
.min_web_content_chars ⇒ Integer
Minimum characters of extracted web content before flagging as possibly incomplete.
-
.mneme_eviction_fraction ⇒ Float
Fraction of the viewport to evict in batch when Mneme runs.
-
.mneme_l1_budget_fraction ⇒ Float
Fraction of the main viewport token budget reserved for L1 snapshots.
-
.mneme_l2_budget_fraction ⇒ Float
Fraction of the main viewport token budget reserved for L2 snapshots.
-
.mneme_l2_snapshot_threshold ⇒ Integer
Number of uncovered L1 snapshots that triggers L2 compression.
-
.mneme_max_tokens ⇒ Integer
Maximum tokens per Mneme LLM response.
-
.mneme_pinned_budget_fraction ⇒ Float
Fraction of the main viewport token budget reserved for pinned messages.
-
.mneme_viewport_fraction ⇒ Float
Fraction of the main viewport token budget allocated to Mneme’s viewport.
-
.model ⇒ String
Primary model for conversations.
-
.name_generation_interval ⇒ Integer
Regenerate session name every N messages.
-
.project_files_max_depth ⇒ Integer
Maximum directory depth for project file scanning.
-
.project_files_whitelist ⇒ Array<String>
Filenames to scan for in the working directory.
-
.recall_budget_fraction ⇒ Float
Fraction of the main viewport token budget reserved for recalled memories.
-
.recall_max_results ⇒ Integer
Maximum search results returned per FTS5 query.
-
.recall_max_snippet_tokens ⇒ Integer
Maximum tokens per individual recall snippet.
-
.recall_recency_decay ⇒ Float
Recency decay factor for search ranking (0.0 = pure relevance).
-
.reset! ⇒ Object
Resets to default path and clears cached config.
-
.soul_path ⇒ String
Path to the soul file — the agent’s self-authored identity.
-
.subagent_model ⇒ String
Model for sub-agent sessions.
-
.subagent_token_budget ⇒ Integer
Context window budget for sub-agent sessions.
-
.thinking_budget ⇒ Integer
Maximum character length for the Think tool’s thoughts parameter.
-
.token_budget ⇒ Integer
Context window budget — tokens reserved for conversation history.
-
.tool_timeout ⇒ Integer
Per-tool-call timeout.
-
.web_request_timeout ⇒ Integer
Web fetch request timeout.
Class Method Details
.agent_name ⇒ String
The agent’s display name. Separates engine identity (“Anima”) from agent identity — any agent running on Anima can name itself.
68 |
# File 'lib/anima/settings.rb', line 68 def agent_name = get("agent", "name") |
.analytical_brain_blocking_on_agent_message ⇒ Boolean
Run the analytical brain asynchronously after the main agent completes.
234 |
# File 'lib/anima/settings.rb', line 234 def = get("analytical_brain", "blocking_on_agent_message") |
.analytical_brain_blocking_on_user_message ⇒ Boolean
Run the analytical brain synchronously before the main agent on user messages.
230 |
# File 'lib/anima/settings.rb', line 230 def = get("analytical_brain", "blocking_on_user_message") |
.analytical_brain_max_tokens ⇒ Integer
Maximum tokens per analytical brain response.
226 |
# File 'lib/anima/settings.rb', line 226 def analytical_brain_max_tokens = get("analytical_brain", "max_tokens") |
.analytical_brain_message_window ⇒ Integer
Number of recent messages to include in the analytical brain’s context window.
238 |
# File 'lib/anima/settings.rb', line 238 def = get("analytical_brain", "message_window") |
.api_timeout ⇒ Integer
LLM API request timeout.
112 |
# File 'lib/anima/settings.rb', line 112 def api_timeout = get("timeouts", "api") |
.command_timeout ⇒ Integer
Shell command execution timeout.
116 |
# File 'lib/anima/settings.rb', line 116 def command_timeout = get("timeouts", "command") |
.config_path ⇒ String
Returns active config file path.
53 54 55 |
# File 'lib/anima/settings.rb', line 53 def config_path @config_path || DEFAULT_PATH end |
.config_path=(path) ⇒ Object
Override config file path (for testing). Resets the cache so the next access reads from the new location.
46 47 48 49 50 |
# File 'lib/anima/settings.rb', line 46 def config_path=(path) @config_path = path @config_cache = nil @config_mtime = nil end |
.default_view_mode ⇒ String
View mode applied to new sessions: “basic”, “verbose”, or “debug”. Changing this setting only affects sessions created afterwards.
182 183 184 185 186 187 188 189 |
# File 'lib/anima/settings.rb', line 182 def default_view_mode value = get("session", "default_view_mode") unless Session::VIEW_MODES.include?(value) raise MissingSettingError, "[session] default_view_mode must be one of: #{Session::VIEW_MODES.join(", ")} (got #{value.inspect})" end value end |
.fast_model ⇒ String
Lightweight model for fast tasks (e.g. session naming).
78 |
# File 'lib/anima/settings.rb', line 78 def fast_model = get("llm", "fast_model") |
.github_label ⇒ String
Label applied to agent-created feature request issues.
220 |
# File 'lib/anima/settings.rb', line 220 def github_label = get("github", "label") |
.github_repo ⇒ String
Repository for feature requests (owner/repo format). Falls back to parsing git remote origin when unset.
216 |
# File 'lib/anima/settings.rb', line 216 def github_repo = get("github", "repo") |
.interrupt_check_interval ⇒ Numeric
Polling interval for user interrupt checks during long-running commands. Enforces a 0.5s floor to prevent busy-polling from misconfiguration.
134 135 136 |
# File 'lib/anima/settings.rb', line 134 def interrupt_check_interval [get("timeouts", "interrupt_check"), 0.5].max end |
.max_file_size ⇒ Integer
Maximum file size for read/edit operations (bytes).
148 |
# File 'lib/anima/settings.rb', line 148 def max_file_size = get("tools", "max_file_size") |
.max_output_bytes ⇒ Integer
Maximum bytes of command output before truncation.
142 |
# File 'lib/anima/settings.rb', line 142 def max_output_bytes = get("shell", "max_output_bytes") |
.max_read_bytes ⇒ Integer
Maximum bytes returned by the read_file tool.
156 |
# File 'lib/anima/settings.rb', line 156 def max_read_bytes = get("tools", "max_read_bytes") |
.max_read_lines ⇒ Integer
Maximum lines returned by the read_file tool.
152 |
# File 'lib/anima/settings.rb', line 152 def max_read_lines = get("tools", "max_read_lines") |
.max_subagent_response_chars ⇒ Integer
Maximum characters of sub-agent result before head+tail truncation. Higher than tool threshold because sub-agent output is already curated.
174 |
# File 'lib/anima/settings.rb', line 174 def max_subagent_response_chars = get("tools", "max_subagent_response_chars") |
.max_tokens ⇒ Integer
Maximum tokens per LLM response.
82 |
# File 'lib/anima/settings.rb', line 82 def max_tokens = get("llm", "max_tokens") |
.max_tool_response_chars ⇒ Integer
Maximum characters of tool output before head+tail truncation. Full output saved to a temp file for paginated reading.
169 |
# File 'lib/anima/settings.rb', line 169 def max_tool_response_chars = get("tools", "max_tool_response_chars") |
.max_tool_rounds ⇒ Integer
Maximum consecutive tool execution rounds per LLM message. Prevents runaway tool loops.
87 |
# File 'lib/anima/settings.rb', line 87 def max_tool_rounds = get("llm", "max_tool_rounds") |
.max_web_response_bytes ⇒ Integer
Maximum bytes from web GET responses.
160 |
# File 'lib/anima/settings.rb', line 160 def max_web_response_bytes = get("tools", "max_web_response_bytes") |
.mcp_response_timeout ⇒ Integer
MCP server response timeout.
120 |
# File 'lib/anima/settings.rb', line 120 def mcp_response_timeout = get("timeouts", "mcp_response") |
.min_web_content_chars ⇒ Integer
Minimum characters of extracted web content before flagging as possibly incomplete.
164 |
# File 'lib/anima/settings.rb', line 164 def min_web_content_chars = get("tools", "min_web_content_chars") |
.mneme_eviction_fraction ⇒ Float
Fraction of the viewport to evict in batch when Mneme runs.
264 |
# File 'lib/anima/settings.rb', line 264 def mneme_eviction_fraction = get("mneme", "eviction_fraction") |
.mneme_l1_budget_fraction ⇒ Float
Fraction of the main viewport token budget reserved for L1 snapshots.
252 |
# File 'lib/anima/settings.rb', line 252 def mneme_l1_budget_fraction = get("mneme", "l1_budget_fraction") |
.mneme_l2_budget_fraction ⇒ Float
Fraction of the main viewport token budget reserved for L2 snapshots.
256 |
# File 'lib/anima/settings.rb', line 256 def mneme_l2_budget_fraction = get("mneme", "l2_budget_fraction") |
.mneme_l2_snapshot_threshold ⇒ Integer
Number of uncovered L1 snapshots that triggers L2 compression.
260 |
# File 'lib/anima/settings.rb', line 260 def mneme_l2_snapshot_threshold = get("mneme", "l2_snapshot_threshold") |
.mneme_max_tokens ⇒ Integer
Maximum tokens per Mneme LLM response.
244 |
# File 'lib/anima/settings.rb', line 244 def mneme_max_tokens = get("mneme", "max_tokens") |
.mneme_pinned_budget_fraction ⇒ Float
Fraction of the main viewport token budget reserved for pinned messages. Pinned messages appear between snapshots and the sliding window.
269 |
# File 'lib/anima/settings.rb', line 269 def mneme_pinned_budget_fraction = get("mneme", "pinned_budget_fraction") |
.mneme_viewport_fraction ⇒ Float
Fraction of the main viewport token budget allocated to Mneme’s viewport.
248 |
# File 'lib/anima/settings.rb', line 248 def = get("mneme", "viewport_fraction") |
.model ⇒ String
Primary model for conversations.
74 |
# File 'lib/anima/settings.rb', line 74 def model = get("llm", "model") |
.name_generation_interval ⇒ Integer
Regenerate session name every N messages.
193 |
# File 'lib/anima/settings.rb', line 193 def name_generation_interval = get("session", "name_generation_interval") |
.project_files_max_depth ⇒ Integer
Maximum directory depth for project file scanning.
209 |
# File 'lib/anima/settings.rb', line 209 def project_files_max_depth = get("environment", "project_files_max_depth") |
.project_files_whitelist ⇒ Array<String>
Filenames to scan for in the working directory.
205 |
# File 'lib/anima/settings.rb', line 205 def project_files_whitelist = get("environment", "project_files") |
.recall_budget_fraction ⇒ Float
Fraction of the main viewport token budget reserved for recalled memories.
279 |
# File 'lib/anima/settings.rb', line 279 def recall_budget_fraction = get("recall", "budget_fraction") |
.recall_max_results ⇒ Integer
Maximum search results returned per FTS5 query.
275 |
# File 'lib/anima/settings.rb', line 275 def recall_max_results = get("recall", "max_results") |
.recall_max_snippet_tokens ⇒ Integer
Maximum tokens per individual recall snippet.
283 |
# File 'lib/anima/settings.rb', line 283 def recall_max_snippet_tokens = get("recall", "max_snippet_tokens") |
.recall_recency_decay ⇒ Float
Recency decay factor for search ranking (0.0 = pure relevance).
287 |
# File 'lib/anima/settings.rb', line 287 def recall_recency_decay = get("recall", "recency_decay") |
.reset! ⇒ Object
Resets to default path and clears cached config. Useful in test teardown.
59 60 61 |
# File 'lib/anima/settings.rb', line 59 def reset! self.config_path = nil end |
.soul_path ⇒ String
Path to the soul file — the agent’s self-authored identity.
199 |
# File 'lib/anima/settings.rb', line 199 def soul_path = get("paths", "soul") |
.subagent_model ⇒ String
Model for sub-agent sessions. Sonnet is cost-effective for focused tasks.
101 |
# File 'lib/anima/settings.rb', line 101 def subagent_model = get("llm", "subagent_model") |
.subagent_token_budget ⇒ Integer
Context window budget for sub-agent sessions. Smaller than main to keep sub-agents out of the “dumb zone”.
106 |
# File 'lib/anima/settings.rb', line 106 def subagent_token_budget = get("llm", "subagent_token_budget") |
.thinking_budget ⇒ Integer
Maximum character length for the Think tool’s thoughts parameter. Sub-agents receive half this budget (their tasks are less complex).
97 |
# File 'lib/anima/settings.rb', line 97 def thinking_budget = get("llm", "thinking_budget") |
.token_budget ⇒ Integer
Context window budget — tokens reserved for conversation history. Set this based on your model’s context window minus system prompt.
92 |
# File 'lib/anima/settings.rb', line 92 def token_budget = get("llm", "token_budget") |
.tool_timeout ⇒ Integer
Per-tool-call timeout. Used as the default deadline for orphan detection and as the default value for the tool’s ‘timeout` input parameter.
129 |
# File 'lib/anima/settings.rb', line 129 def tool_timeout = get("timeouts", "tool") |
.web_request_timeout ⇒ Integer
Web fetch request timeout.
124 |
# File 'lib/anima/settings.rb', line 124 def web_request_timeout = get("timeouts", "web_request") |