Default Model Persistence
Relevant source files
The following files were used as context for generating this wiki page:
Default Model Persistence in ollacc refers to the system's ability to remember a user's preferred Ollama Cloud model across sessions. This feature minimizes friction by allowing the launcher to skip the model selection menu on subsequent runs, directly executing the claude command with the saved configuration.
The persistence mechanism relies on a local configuration file and a set of bash utility functions that manage reading, writing, and clearing the saved model state.
Sources: README.md:27-28, README.md:73-75
Architecture and Storage
The persistence system is built around a flat-file configuration located at ~/.ollacc/config. This file is managed with restricted permissions (chmod 600) to ensure data security, as it also contains sensitive authentication tokens.
Configuration File Structure
The configuration file is designed to be sourced directly by the bash launcher. The key variable for model persistence is OLLAMA_CLAUDE_DEFAULT_MODEL.
| Variable | Purpose | Default Value |
|---|---|---|
OLLAMA_CLAUDE_DEFAULT_MODEL | Stores the slug of the selected default model. | "" |
ANTHROPIC_BASE_URL | The API endpoint for requests. | https://ollama.com |
ANTHROPIC_AUTH_TOKEN | The user's Ollama Cloud API key. | "" |
Sources: install.sh:55-61, lib/auth.sh:12-14, README.md:80-84
Directory and File Management
The install.sh script initializes the persistence environment by creating the necessary directory and skeleton configuration file.
Sources: install.sh:41-43, install.sh:52-62
Persistence Logic Flow
The system manages model persistence through a series of checks during the execution lifecycle. If a default model is set, the menu is bypassed; otherwise, the user is prompted to select a model and optionally save it as the new default.
Model Selection and Saving
The following sequence illustrates how a model is chosen and persisted:
Update Mechanism (config_set)
The config_set function in lib/config.sh handles the actual I/O operations. It uses awk to replace existing keys or appends new ones if the key is missing, ensuring that user comments within the file are preserved. It also utilizes a bash_escape helper to sanitize values before writing them to the file.
Sources: lib/config.sh:13-31, lib/config.sh:40-66
State Management and Resetting
Users can manage the persisted state through specific command-line flags. These flags allow for targeted clearing of the saved model without affecting other configuration settings like API keys.
Flag Handling
The lib/flags.sh module processes state-reset commands before the main application logic begins.
| Flag | Function | Impact |
|---|---|---|
--model-clear | config_unset OLLAMA_CLAUDE_DEFAULT_MODEL | Reverts to menu selection on next run. |
--key-clear | config_unset ANTHROPIC_AUTH_TOKEN | Triggers API key re-prompt. |
Sources: lib/flags.sh:10-22, README.md:75-78
The config_unset Operation
The config_unset function removes specific lines from the configuration file using a temporary file and awk, effectively "forgetting" the persisted model selection.
Sources: lib/config.sh:70-81, lib/flags.sh:12-16
Security Considerations
Because the default model is stored in the same file as the ANTHROPIC_AUTH_TOKEN, the persistence system adheres to strict file permission standards:
- The configuration directory
~/.ollacc/is set tochmod 700. - The configuration file
~/.ollacc/configis set tochmod 600. - These permissions are enforced during installation, initial key entry, and every subsequent update via
config_setorconfig_unset.
Sources: install.sh:43, install.sh:62, lib/config.sh:46, lib/config.sh:65
Conclusion
Default Model Persistence in ollacc provides a seamless user experience by caching model preferences in a secure, bash-compatible configuration file. By utilizing standard Unix tools like awk and sed, the system ensures robust state management that is easy to inspect, manually edit, or reset via built-in flags.