fix: guard against None model in call_utility_model to prevent crash#1460
Open
gdeyoung wants to merge 1 commit intoagent0ai:mainfrom
Open
fix: guard against None model in call_utility_model to prevent crash#1460gdeyoung wants to merge 1 commit intoagent0ai:mainfrom
gdeyoung wants to merge 1 commit intoagent0ai:mainfrom
Conversation
When get_utility_model() returns None (e.g., model resolution failure, missing config), the agent crashes trying to use it. Add a defensive guard that logs a warning and returns empty string instead.
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.
TL;DR — Agent crashes when utility model resolution returns None
call_utility_model()gets the model name fromget_utility_model()but never checks if it'sNone. If model resolution fails (missing config, bad provider name, etc.), the agent crashes with an unhandled exception. A simpleNoneguard logs a warning and returns an empty string, allowing the agent to continue operating.One defensive check prevents a crash when model configuration is incomplete.
Problem
In
agent.py,call_utility_model()at line ~759:When
get_utility_model()returnsNone(e.g., missingutility_modelin settings, provider not configured), the agent crashes instead of gracefully degrading.Solution
Add a None guard immediately after model resolution:
The agent logs a warning and continues operating instead of crashing.
Impact
Changes
agent.pyif model is Noneguard afterget_utility_model()Testing
Related