{"record":{"id":"d3130e5bd4b77bdc","repo":"HKUDS/Vibe-Trading","slug":"langchain-model-name-is-not-set","errorCode":null,"errorMessage":"LANGCHAIN_MODEL_NAME is not set","messagePattern":"LANGCHAIN_MODEL_NAME is not set","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"agent/src/providers/llm.py","lineNumber":1411,"sourceCode":"\n\ndef build_llm(*, model_name: Optional[str] = None, callbacks: Any = None) -> Any:\n    \"\"\"Construct the configured LangChain chat model.\n\n    Args:\n        model_name: Model name; defaults to LANGCHAIN_MODEL_NAME.\n        callbacks: Optional LangChain callbacks.\n\n    Returns:\n        Provider-specific LangChain chat model.\n\n    Raises:\n        RuntimeError: If langchain-openai is missing or LANGCHAIN_MODEL_NAME is unset.\n    \"\"\"\n    _sync_provider_env()\n    name = model_name or get_env_config().llm.langchain_model_name.strip()\n    if not name:\n        raise RuntimeError(\"LANGCHAIN_MODEL_NAME is not set\")\n    temperature = get_env_config().llm.langchain_temperature\n    provider = get_env_config().llm.langchain_provider.lower()\n    caps = get_provider_capabilities(provider, name)\n    if provider in {\"openai-codex\", \"openai_codex\"}:\n        from src.providers.openai_codex import OpenAICodexLLM\n\n        effort = get_env_config().llm.langchain_reasoning_effort.strip().lower()\n        return OpenAICodexLLM(\n            model=name,\n            temperature=temperature,\n            timeout=get_env_config().llm.timeout_seconds,\n            reasoning_effort=effort or None,\n        )\n\n    if provider in {\"copilot\", \"github-copilot\"}:\n        from src.providers.copilot_auth import CopilotSDKLLM\n\n        return CopilotSDKLLM(","sourceCodeStart":1393,"sourceCodeEnd":1429,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/providers/llm.py#L1393-L1429","documentation":"build_llm requires a model name, and neither the model_name argument nor the LANGCHAIN_MODEL_NAME environment variable provided one (empty/whitespace after strip). This is a configuration guard before any client is constructed.","triggerScenarios":"Calling build_llm() with no model_name and LANGCHAIN_MODEL_NAME unset, empty, or whitespace; .env file not loaded in the current shell; CI environment missing the variable.","commonSituations":"New machine/container without the .env file copied; variable renamed or commented out; tests running in an environment that scrubs env vars.","solutions":["Set LANGCHAIN_MODEL_NAME in your environment or .env (e.g. export LANGCHAIN_MODEL_NAME=claude-sonnet-4)","Pass model_name explicitly to build_llm(model_name=...)","Check the env file is actually loaded: python -c \"from src.env_config import get_env_config; print(repr(get_env_config().llm.langchain_model_name))\""],"exampleFix":"# before\nllm = build_llm()  # LANGCHAIN_MODEL_NAME unset\n\n# after\nexport LANGCHAIN_MODEL_NAME=gpt-4o\nllm = build_llm()","handlingStrategy":"validation","validationCode":"name = model_name or os.environ.get('LANGCHAIN_MODEL_NAME', '').strip()\nif not name:\n    raise SystemExit('LANGCHAIN_MODEL_NAME is required')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Fail fast at app startup on missing critical env vars","Use a settings schema (pydantic) that marks LANGCHAIN_MODEL_NAME required"],"tags":["configuration","missing-env-var","llm-provider"],"backgroundTag":"missing-env-var","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}