hsliuping/TradingAgents-CN · warning · RuntimeWarning

Model '{self.model}' is not in the known model list for prov

Error message

Model '{self.model}' is not in the known model list for provider '{self.get_provider_name()}'. Continuing anyway.

What it means

A RuntimeWarning from warn_if_unknown_model (invoked via get_llm): the configured model name is not in the provider's known model list, but the client proceeds anyway. Providers generally accept arbitrary model strings, so this is advisory — the request may still fail server-side with a model-not-found API error, or succeed if the model exists but the list is stale. It fires whenever validate_model() returns False for the chosen client class.

Source

Thrown at tradingagents/llm_clients/base_client.py:48

class BaseLLMClient(ABC):
    """Minimal provider wrapper used by CLI and future graph integration."""

    def __init__(self, model: str, base_url: Optional[str] = None, **kwargs):
        self.model = model
        self.base_url = base_url
        self.kwargs = kwargs

    def get_provider_name(self) -> str:
        provider = getattr(self, "provider", None)
        if provider:
            return str(provider)
        return self.__class__.__name__.removesuffix("Client").lower()

    def warn_if_unknown_model(self) -> None:
        if self.validate_model():
            return

        warnings.warn(
            (
                f"Model '{self.model}' is not in the known model list for "
                f"provider '{self.get_provider_name()}'. Continuing anyway."
            ),
            RuntimeWarning,
            stacklevel=2,
        )

    @abstractmethod
    def get_llm(self) -> Any:
        """Return the configured LangChain client."""

    @abstractmethod
    def validate_model(self) -> bool:
        """Return whether the model is known for the provider."""

View on GitHub (pinned to 74783e8817)

Solutions

  1. Verify the model string against the provider's current model list and fix typos (most common cause).
  2. If the model genuinely exists (new release or custom deployment), ignore or filter the warning — requests will still be sent.
  3. Upgrade the library so its known-model list includes recent models.

Example fix

# before
client = OpenAIClient(model="gpt-4o-minni")  # typo -> RuntimeWarning

# after
client = OpenAIClient(model="gpt-4o-mini")
Defensive patterns

Strategy: validation

Validate before calling

known = {"gpt-4o", "gpt-4o-mini", "claude-3-5-sonnet", "claude-3-5-haiku"}  # mirror your provider's list
if model not in known:
    print(f"warning: {model!r} may not exist on this provider; verify spelling")
client = get_llm(model=model, ...)

Type guard

def looks_like_valid_model(model: str) -> bool:
    """Heuristic guard: non-empty string, no spaces, plausible provider prefix."""
    return isinstance(model, str) and 0 < len(model.strip()) and " " not in model

Try / catch

import warnings
with warnings.catch_warnings(record=True) as caught:
    client = get_llm(model=model)
for w in caught:
    if issubclass(w.category, RuntimeWarning) and "not in the known model list" in str(w.message):
        logging.getLogger(__name__).warning("possible model typo: %s", model)
# then handle the real API error separately if the call fails

Prevention

When it happens

Trigger: Setting model to a newly released or typo'd name (e.g. 'claude-3-5-sonet', 'gpt-4o-mini-2048') and calling get_llm(); using a custom/fine-tuned model alias not in the hardcoded list; pointing base_url at a proxy with renamed models.

Common situations: Typos in model config/env vars; bleeding-edge models released after the library's model list; self-hosted gateways with custom model names; users alarmed by the warning in logs even though requests work.

Related errors


AI-assisted analysis of hsliuping/TradingAgents-CN@74783e8817 (2026-08-28). Data as JSON: /api/errors/a811a0fce9b3f86f. Report an issue: GitHub.