Feat preflight check #43
Conversation
|
Hey @AaineeSinha, the hook point in Before merge we need a few things in the same PR:
Once those are in, happy to review again. Thanks! |
… flag, and add comprehensive unit tests
|
Hey @rosspeili , I've implemented the missing |
|
Thanks for the follow-up @AaineeSinha, this looks good now. The preflight module, LGTM from my side once CI is green. Nice and clean work, and thanks for sticking with the review rounds! |
|
Hey @AaineeSinha you should use your real email when commiting so that you are part of the contributing history. You can change your past commits with your real email and they will be retroactively attributed to you. Now there is a generic github example mail. |
Closes Issue #36
Summary of the Issue & Changes
1. What the Problem Was
When users configured the framework to use local models via Ollama, the CLI would launch straight into the main application menu without checking if Ollama was actually running or if the requested model was downloaded. This led to abrupt runtime crashes or frozen states mid-session if:
ollama servewas omitted).rooms.settings.yamlthat they hadn't pulled locally yet.2. What I Changed (The Solution)
I implemented a robust Preflight Verification Loop that catches these environment misconfigurations early, right after settings load and before any core agent orchestrations run.
Here is the exact breakdown of the architectural changes:
Isolated Preflight Logic (
rooms/ollama_preflight.py): Created a lightweight, dependency-free utility module. It uses Python’s built-inurllibto ping{settings.ollama.base_url}/api/tags. It cleanly parses the JSON payload from Ollama, extracts the local tag names, and safely checks if the model configured undersettings.defaults.litellm_modelexists.CLI Interception Loop (
cli.py): Integrated the check insidecli.pyright after settings initialization. If the default model string starts withollama/, it runs the preflight check. If the server is unreachable or the model tag is missing, it prints a clean warning panel via theRichlibrary with actionable instructions (e.g., prompt to runollama pull), allowing the user to seamlessly troubleshoot or choose to bypass.Bypass Flags for CI/Testing (
cli.py): Added a new--skip-preflightCLI option next to the existing--configsetup. This allows automated tests, CI/CD matrices, or headless runners to skip the network check entirely.Mock Integration Tests (
tests/test_cli_settings_smoke.py): Expanded the test suite to safely validate the new preflight behavior. Usingunittest.mock, I mocked the standard library network handlers to cleanly simulate an absolute connection timeout, a successful response returning a list of valid tags, and a response indicating a missing tag. All tests execute completely locally with zero external network overhead in the CI environment.Documentation Review (
docs/EXAMPLES.md): Appended an advanced CLI execution block to the end of the documentation file to ensure users and developers know exactly how to leverage the new--skip-preflightflag.