fix: abort cleanly in batch mode (--exit) when Ollama is unreachable#4977
Open
Frank-Schruefer wants to merge 1 commit intoAider-AI:mainfrom
Open
fix: abort cleanly in batch mode (--exit) when Ollama is unreachable#4977Frank-Schruefer wants to merge 1 commit intoAider-AI:mainfrom
Frank-Schruefer wants to merge 1 commit intoAider-AI:mainfrom
Conversation
When Ollama returns a connection error during model info lookup, aider
previously treated it as a non-fatal warning and continued with "sane
defaults", opening the interactive TUI. In batch mode (--exit), this
causes the TUI output to be written to the redirected stdout instead of
aborting cleanly.
- ModelInfoManager.get_model_info: re-raise exceptions whose message
starts with "OllamaError:" instead of silently swallowing them
- Model.get_model_info: catch OllamaError, store on self.ollama_error,
return {} to allow interactive mode to continue with sane defaults
- main.py: if ollama_error is set and --exit is active, emit a clear
error message and return 1
Interactive mode is unaffected: the warning and sane-defaults behaviour
remain unchanged.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1ae6ba3 to
84df006
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When Ollama is unreachable (e.g. connection refused), aider treats the error as a non-fatal warning and continues with "sane defaults". In batch mode (
--exit --message), this causes aider to open its interactive TUI anyway, dumping ANSI escape sequences to stdout. If stdout is redirected to a file, the file is filled with TUI garbage instead of the expected output.Root cause
ModelInfoManager.get_model_infocatches all exceptions fromlitellm.get_model_infoand silently swallows them (printing the message but continuing). The Ollama connection error is raised by litellm as a plainExceptionwith a message starting with"OllamaError:".Fix
models.pyModelInfoManager.get_model_info: re-raise exceptions whose message starts with"OllamaError:"instead of swallowing themmodels.pyModel.get_model_info: catch the re-raised error, store it onself.ollama_error, and return{}— this preserves the existing interactive-mode behaviour (sane defaults, warning shown)main.py: after model setup, ifmain_model.ollama_erroris set and--exitis active, emit a clear error message and return 1Behaviour
--exit)