Skip to content

Commit d2c4a03

Browse files
fix: use model_id without provider prefix when loading settings (#280)
* fix: use model_id without provider prefix when loading settings When loading settings in basic mode, the model_select dropdown was being set to the full model string (e.g., 'cerebras/zai-glm-4.6') but the dropdown options only contain model_ids without the provider prefix (e.g., 'zai-glm-4.6'). This caused an InvalidSelectValueError when opening the settings screen with a previously configured model. The fix uses the model variable (extracted from splitting llm.model by '/') instead of the full llm.model string when setting model_select.value. Also updated the test to reflect the correct behavior where model options don't include the provider prefix. Co-authored-by: openhands <openhands@all-hands.dev> * fix: shorten long comments to pass linter --------- Co-authored-by: openhands <openhands@all-hands.dev>
1 parent ce1b108 commit d2c4a03

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

openhands_cli/tui/modals/settings/settings_screen.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ def _load_current_settings(self) -> None:
174174

175175
# Update model options and select current model
176176
self._update_model_options(provider)
177-
self.model_select.value = llm.model
177+
# Use model without provider prefix (dropdown options don't have it)
178+
self.model_select.value = model
178179

179180
# API Key (show masked version)
180181
if llm.api_key:

tests/refactor/modals/settings/test_settings_screen.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,10 @@ async def test_load_current_settings_basic_mode(
132132
screen.current_agent = fake_agent_store.load()
133133

134134
with patch.object(ss, "get_model_options") as mock_get_options:
135+
# Model options don't include provider prefix
135136
mock_get_options.return_value = [
136-
("GPT-4o Mini", "openai/gpt-4o-mini"),
137-
("GPT-4o", "openai/gpt-4o"),
137+
("gpt-4o-mini", "gpt-4o-mini"),
138+
("gpt-4o", "gpt-4o"),
138139
]
139140
screen._load_current_settings()
140141

@@ -147,7 +148,8 @@ async def test_load_current_settings_basic_mode(
147148
assert screen.is_advanced_mode is False
148149
assert mode_select.value == "basic"
149150
assert provider_select.value == "openai"
150-
assert model_select.value == "openai/gpt-4o-mini"
151+
# Model select value should be model_id without provider prefix
152+
assert model_select.value == "gpt-4o-mini"
151153

152154
placeholder = api_key_input.placeholder
153155
assert placeholder.startswith("Current: tes")

0 commit comments

Comments
 (0)