infiniflow/ragflow · error · ValueError

Invalid model config for Browser llm_id={llm_id}

Error message

Invalid model config for Browser llm_id={llm_id}

What it means

Raised in the Browser agent component's _build_browser_llm (agent/component/browser.py) when the tenant's resolved model configuration yields no usable model name: cfg has neither 'model_name' nor 'model', and self._param.llm_id is also empty/None after normalization. This means the component was configured with an LLM binding that is broken or empty, so no browser-use Chat model can be constructed.

Source

Thrown at agent/component/browser.py:411

        if explicit:
            return explicit

        provider = self._infer_provider_name(cfg)
        fallback = str(FACTORY_DEFAULT_BASE_URL.get(provider, "")).strip()
        return fallback if fallback else ""

    def _build_browser_llm(self):
        from browser_use.llm import ChatBrowserUse, ChatOpenAI

        chat_model_config = resolve_model_config(
            self._canvas.get_tenant_id(),
            resolve_model_type(self._canvas.get_tenant_id(), self._param.llm_id),
            self._param.llm_id,
        )
        cfg = self._as_model_config_dict(chat_model_config)
        model_name = self._normalize_model_name(cfg.get("model_name") or cfg.get("model") or self._param.llm_id)
        if not model_name:
            raise ValueError(f"Invalid model config for Browser llm_id={self._param.llm_id}")
        base_url = self._resolve_openai_compatible_base_url(cfg)

        # ChatBrowserUse only supports bu-* models. For tenant models, use OpenAI-compatible adapter.
        if model_name.startswith("bu-") or model_name.startswith("browser-use/"):
            llm_kwargs = {
                "model": model_name,
                "api_key": cfg.get("api_key"),
                "base_url": base_url,
                "temperature": self._param.temperature,
                "max_retries": self._param.max_retries,
            }
            llm_kwargs = {k: v for k, v in llm_kwargs.items() if v not in (None, "")}
            return ChatBrowserUse(**llm_kwargs)

        # browser-use Agent defaults to json_schema response_format and may use tool_choice via
        # ChatDeepSeek. Many providers (e.g. DeepSeek thinking models) reject both. Use ChatOpenAI
        # with schema-in-prompt and without forced structured output on the first run.
        llm_kwargs = {

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Open the Browser component in the agent editor and re-select a valid, currently configured LLM from the tenant's model list
  2. Verify the model exists: check the tenant's LLM/provider settings page and that the llm_id referenced in the canvas JSON resolves to a row with a model name
  3. If llm_id was left blank intentionally, pick a default model — the component requires one
  4. After re-creating the model (e.g. re-adding the API key), re-select it in the component so a fresh llm_id is stored

Example fix

# before (canvas JSON)
"llm_id": ""   # or a stale id of a deleted model

# after
"llm_id": "<id-of-currently-configured-model@tenant>"
Defensive patterns

Strategy: validation

Validate before calling

from api.db.services.llm import LLMService  # conceptually

def resolve_browser_llm_id(tenant_id, llm_id):
    if not llm_id:
        raise ValueError('Browser component requires an llm_id')
    # verify the model still exists for this tenant before running the canvas
    exists, cfg = tenant_model_lookup(tenant_id, llm_id)
    if not exists or not (cfg.get('model_name') or cfg.get('model')):
        raise ValueError(f'llm_id {llm_id} has no resolvable model name; re-select the model')
    return llm_id

Type guard

def has_resolvable_model_name(cfg: dict) -> bool:
    return bool(cfg.get('model_name') or cfg.get('model'))

Try / catch

try:
    component.run(...)
except ValueError as e:
    if 'Invalid model config for Browser' in str(e):
        mark_component_needs_reconfig(component, 'Re-select the LLM in the Browser component')
    else:
        raise

Prevention

When it happens

Trigger: Adding a Browser component to an agent canvas and selecting an llm_id whose tenant model record is missing/deleted, or leaving llm_id empty when the model config lookup returns nothing; also when the model was removed from the tenant's provider settings but the canvas still references it. Fires when the component initializes its LLM at run time.

Common situations: Deleted or re-configured LLM providers leaving stale llm_id references in saved canvases; multi-tenant setups where the model belongs to another tenant; API keys rotated and the model row dropped; canvas JSON copied between environments without matching model setups.

Related errors


AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15). Data as JSON: /api/errors/8ead02a118bd9694. Report an issue: GitHub.