Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
fix(llm): treat empty override_llm_key as no-override (#5924)
Aaron Perez171fc805ec45
diff --git a/skyvern/forge/sdk/api/llm/api_handler_factory.py b/skyvern/forge/sdk/api/llm/api_handler_factory.pyindex 1382d4631..add314c12 100644--- a/skyvern/forge/sdk/api/llm/api_handler_factory.py+++ b/skyvern/forge/sdk/api/llm/api_handler_factory.py@@ -665,7 +665,8 @@ class LLMAPIHandlerFactory:# the GPT-4.1 fallback variants — and the existing contract on this method (see comment# below) is that explicit overrides honor the exact model choice. We respect that.# Flex routing is treated as default-path tier optimization, not a model rewriter.- if override_llm_key is None:+ # Treat empty string as "no override" — block models persist `llm_key=""` rather than NULL.+ if not override_llm_key:flex_handler = LLMAPIHandlerFactory._maybe_get_flex_handler(default)if flex_handler is not None:return flex_handlerdiff --git a/tests/unit/test_api_handler_factory.py b/tests/unit/test_api_handler_factory.pyindex bd9acec1c..7f0a6318e 100644--- a/tests/unit/test_api_handler_factory.py+++ b/tests/unit/test_api_handler_factory.py@@ -330,3 +330,23 @@ def test_aiohttp_transport_disabled_for_per_request_timeouts() -> None:"""Importing the LLM package disables litellm's aiohttp transport so per-request `timeout` is honored."""assert litellm.disable_aiohttp_transport is Trueassert api_handler_factory.litellm.disable_aiohttp_transport is True++[email protected]("override", [None, ""])+def test_get_override_llm_api_handler_treats_empty_as_no_override(+ override: str | None, monkeypatch: pytest.MonkeyPatch+) -> None:+ """Empty override_llm_key must return default — not the dummy handler.++ Block models persist `llm_key=""` rather than NULL when the user hasn't picked a+ model; SKY-9674 narrowed the gate to `is None`, which routed those calls to+ `dummy_llm_api_handler` and broke text_prompt blocks on staging.+ """++ async def default_handler(*_: object, **__: object) -> dict[str, str]:+ return {"ok": True}++ monkeypatch.setattr(LLMAPIHandlerFactory, "_maybe_get_flex_handler", staticmethod(lambda _default: None))++ resolved = LLMAPIHandlerFactory.get_override_llm_api_handler(override, default=default_handler)+ assert resolved is default_handler