@@ -175,7 +175,7 @@ def _normalize_aux_provider(provider: Optional[str]) -> str:
175175 # Resolve to the user's actual main provider so named custom providers
176176 # and non-aggregator providers (DeepSeek, Alibaba, etc.) work correctly.
177177 main_prov = (_read_main_provider () or "" ).strip ().lower ()
178- if main_prov and main_prov not in ( "auto" , "main" , "" ) :
178+ if main_prov and main_prov not in { "auto" , "main" , "" } :
179179 normalized = main_prov
180180 else :
181181 return "custom"
@@ -578,7 +578,7 @@ def _convert_content_for_responses(content: Any) -> Any:
578578 if detail :
579579 entry ["detail" ] = detail
580580 converted .append (entry )
581- elif ptype in ( "input_text" , "input_image" ) :
581+ elif ptype in { "input_text" , "input_image" } :
582582 # Already in Responses format — pass through
583583 converted .append (part )
584584 else :
@@ -798,7 +798,7 @@ def _item_get(obj: Any, key: str, default: Any = None) -> Any:
798798 if item_type == "message" :
799799 for part in (_item_get (item , "content" ) or []):
800800 ptype = _item_get (part , "type" )
801- if ptype in ( "output_text" , "text" ) :
801+ if ptype in { "output_text" , "text" } :
802802 text_parts .append (_item_get (part , "text" , "" ))
803803 elif item_type == "function_call" :
804804 tool_calls_raw .append (SimpleNamespace (
@@ -1960,7 +1960,7 @@ def _is_payment_error(exc: Exception) -> bool:
19601960 err_lower = str (exc ).lower ()
19611961 # OpenRouter and other providers include "credits" or "afford" in 402 bodies,
19621962 # but sometimes wrap them in 429 or other codes.
1963- if status in ( 402 , 429 , None ) :
1963+ if status in { 402 , 429 , None } :
19641964 if any (kw in err_lower for kw in ("credits" , "insufficient funds" ,
19651965 "can only afford" , "billing" ,
19661966 "payment required" )):
@@ -2157,7 +2157,7 @@ def _pool_cache_hint(
21572157 if normalized == "auto" :
21582158 runtime = _normalize_main_runtime (main_runtime )
21592159 normalized = _normalize_aux_provider (runtime .get ("provider" ) or _read_main_provider ())
2160- if normalized in ( "" , "auto" , "custom" ) :
2160+ if normalized in { "" , "auto" , "custom" } :
21612161 return ""
21622162 entry = _peek_pool_entry (normalized )
21632163 if entry is None :
@@ -2179,7 +2179,7 @@ def _pool_error_context(exc: Exception) -> Dict[str, Any]:
21792179def _recoverable_pool_provider (resolved_provider : str , client : Any ) -> Optional [str ]:
21802180 """Infer which provider pool can recover the current auxiliary client."""
21812181 normalized = _normalize_aux_provider (resolved_provider )
2182- if normalized not in ( "" , "auto" , "custom" ) :
2182+ if normalized not in { "" , "auto" , "custom" } :
21832183 return normalized
21842184 base = str (getattr (client , "base_url" , "" ) or "" )
21852185 if base_url_host_matches (base , "chatgpt.com" ):
@@ -2496,7 +2496,7 @@ def _resolve_auto(main_runtime: Optional[Dict[str, Any]] = None) -> Tuple[Option
24962496 main_provider = runtime_provider or _read_main_provider ()
24972497 main_model = runtime_model or _read_main_model ()
24982498 if (main_provider and main_model
2499- and main_provider not in ( "auto" , "" ) ):
2499+ and main_provider not in { "auto" , "" } ):
25002500 resolved_provider = main_provider
25012501 explicit_base_url = None
25022502 explicit_api_key = None
@@ -3157,7 +3157,7 @@ def _wrap_if_needed(client_obj, final_model_str: str, base_url_str: str = "",
31573157 return (_to_async_client (client , final_model , is_vision = is_vision ) if async_mode
31583158 else (client , final_model ))
31593159
3160- elif pconfig .auth_type in ( "oauth_device_code" , "oauth_external" ) :
3160+ elif pconfig .auth_type in { "oauth_device_code" , "oauth_external" } :
31613161 # OAuth providers — route through their specific try functions
31623162 if provider == "nous" :
31633163 return resolve_provider_client ("nous" , model , async_mode )
@@ -3266,7 +3266,7 @@ def get_available_vision_backends() -> List[str]:
32663266 available : List [str ] = []
32673267 # 1. Active provider — if the user configured a provider, try it first.
32683268 main_provider = _read_main_provider ()
3269- if main_provider and main_provider not in ( "auto" , "" ) :
3269+ if main_provider and main_provider not in { "auto" , "" } :
32703270 if main_provider in _VISION_AUTO_PROVIDER_ORDER :
32713271 if _strict_vision_backend_available (main_provider ):
32723272 available .append (main_provider )
@@ -3312,7 +3312,7 @@ def _finalize(resolved_provider: str, sync_client: Any, default_model: Optional[
33123312
33133313 if resolved_base_url :
33143314 provider_for_base_override = (
3315- requested if requested and requested not in ( "" , "auto" ) else "custom"
3315+ requested if requested and requested not in { "" , "auto" } else "custom"
33163316 )
33173317 client , final_model = resolve_provider_client (
33183318 provider_for_base_override ,
@@ -3340,7 +3340,7 @@ def _finalize(resolved_provider: str, sync_client: Any, default_model: Optional[
33403340 # 4. Stop
33413341 main_provider = _read_main_provider ()
33423342 main_model = _read_main_model ()
3343- if main_provider and main_provider not in ( "auto" , "" ) :
3343+ if main_provider and main_provider not in { "auto" , "" } :
33443344 vision_model = _PROVIDER_VISION_MODELS .get (main_provider , main_model )
33453345 if main_provider == "nous" :
33463346 sync_client , default_model = _resolve_strict_vision_backend (
@@ -4146,7 +4146,7 @@ def call_llm(
41464146 # credentials were found, fail fast instead of silently routing
41474147 # through OpenRouter (which causes confusing 404s).
41484148 _explicit = (resolved_provider or "" ).strip ().lower ()
4149- if _explicit and _explicit not in ( "auto" , "openrouter" , "custom" ) :
4149+ if _explicit and _explicit not in { "auto" , "openrouter" , "custom" } :
41504150 raise RuntimeError (
41514151 f"Provider '{ _explicit } ' is set in config.yaml but no API key "
41524152 f"was found. Set the { _explicit .upper ()} _API_KEY environment "
@@ -4276,7 +4276,7 @@ def call_llm(
42764276
42774277 # ── Auth refresh retry ───────────────────────────────────────
42784278 if (_is_auth_error (first_err )
4279- and resolved_provider not in ( "auto" , "" , None )
4279+ and resolved_provider not in { "auto" , "" , None }
42804280 and not client_is_nous ):
42814281 if _refresh_provider_credentials (resolved_provider ):
42824282 logger .info (
@@ -4359,7 +4359,7 @@ def call_llm(
43594359 # Only try alternative providers when the user didn't explicitly
43604360 # configure this task's provider. Explicit provider = hard constraint;
43614361 # auto (the default) = best-effort fallback chain. (#7559)
4362- is_auto = resolved_provider in ( "auto" , "" , None )
4362+ is_auto = resolved_provider in { "auto" , "" , None }
43634363 if should_fallback and is_auto :
43644364 if _is_payment_error (first_err ):
43654365 reason = "payment error"
@@ -4515,7 +4515,7 @@ async def async_call_llm(
45154515 )
45164516 if client is None :
45174517 _explicit = (resolved_provider or "" ).strip ().lower ()
4518- if _explicit and _explicit not in ( "auto" , "openrouter" , "custom" ) :
4518+ if _explicit and _explicit not in { "auto" , "openrouter" , "custom" } :
45194519 raise RuntimeError (
45204520 f"Provider '{ _explicit } ' is set in config.yaml but no API key "
45214521 f"was found. Set the { _explicit .upper ()} _API_KEY environment "
@@ -4626,7 +4626,7 @@ async def async_call_llm(
46264626
46274627 # ── Auth refresh retry (mirrors sync call_llm) ───────────────
46284628 if (_is_auth_error (first_err )
4629- and resolved_provider not in ( "auto" , "" , None )
4629+ and resolved_provider not in { "auto" , "" , None }
46304630 and not client_is_nous ):
46314631 if _refresh_provider_credentials (resolved_provider ):
46324632 logger .info (
@@ -4688,7 +4688,7 @@ async def async_call_llm(
46884688 or _is_connection_error (first_err )
46894689 or _is_rate_limit_error (first_err )
46904690 )
4691- is_auto = resolved_provider in ( "auto" , "" , None )
4691+ is_auto = resolved_provider in { "auto" , "" , None }
46924692 if should_fallback and is_auto :
46934693 if _is_payment_error (first_err ):
46944694 reason = "payment error"
0 commit comments