{"record":{"id":"51fbe256f2c481b3","repo":"datawhalechina/hello-agents","slug":"llm-timeout-0","errorCode":null,"errorMessage":"LLM_TIMEOUT 必须大于 0","messagePattern":"LLM_TIMEOUT 必须大于 0","errorType":"exception","errorClass":"ConfigurationError","httpStatus":null,"severity":"error","filePath":"Co-creation-projects/zenith191-RequirementClarifierAgent/src/config.py","lineNumber":80,"sourceCode":"            for name, value in (\n                (\"LLM_MODEL_ID\", self.model),\n                (\"LLM_API_KEY\", self.api_key),\n                (\"LLM_BASE_URL\", self.base_url),\n            )\n            if not value\n        ]\n        if missing:\n            raise ConfigurationError(\n                \"缺少 LLM 配置：\" + \", \".join(missing) + \"。请先复制并填写 .env。\"\n            )\n\n        lowered_key = self.api_key.casefold()\n        if lowered_key.startswith(\"your_\") or lowered_key in {\"changeme\", \"replace_me\"}:\n            raise ConfigurationError(\"LLM_API_KEY 仍是占位符，请在 .env 中填写真实密钥\")\n        if not 0 <= self.temperature <= 2:\n            raise ConfigurationError(\"LLM_TEMPERATURE 必须位于 0 到 2 之间\")\n        if self.timeout <= 0:\n            raise ConfigurationError(\"LLM_TIMEOUT 必须大于 0\")\n","sourceCodeStart":62,"sourceCodeEnd":81,"githubUrl":"https://github.com/datawhalechina/hello-agents/blob/606a07d341a47be773fab7f4b71177f53f96b2c3/Co-creation-projects/zenith191-RequirementClarifierAgent/src/config.py#L62-L81","documentation":"Raised by LLMSettings validation when LLM_TIMEOUT is <= 0. A non-positive timeout would make every request fail immediately or behave undefined, so it is rejected up front. Note the type check happens earlier: a non-integer string raises '必须是整数' first; this error means the value parsed fine but is 0 or negative.","triggerScenarios":"Setting LLM_TIMEOUT=0 (sometimes done to mean 'no timeout'), LLM_TIMEOUT=-1 copied from a socket-timeout convention, or passing timeout=0 programmatically.","commonSituations":"Developer intends 'disable timeout' and uses 0 or -1 as in other libraries; CI env carries a negative test value; misreading units (0 seconds vs 0 minutes).","solutions":["Set a positive integer of seconds, e.g. LLM_TIMEOUT=120 (the default).","For long LLM calls, raise it (e.g. 300) rather than zeroing it — this config has no 'infinite' mode.","Remove the variable to accept the default 120."],"exampleFix":"# .env before\nLLM_TIMEOUT=0\n\n# .env after\nLLM_TIMEOUT=120","handlingStrategy":"validation","validationCode":"import os\n\ntimeout = int(os.getenv(\"LLM_TIMEOUT\", \"120\"))\nif timeout <= 0:\n    raise SystemExit(\"LLM_TIMEOUT must be a positive integer of seconds\")","typeGuard":null,"tryCatchPattern":"try:\n    settings = LLMSettings.from_env()\nexcept ConfigurationError as e:\n    if \"TIMEOUT\" in str(e):\n        os.environ.pop(\"LLM_TIMEOUT\", None)  # fall back to default 120\n        settings = LLMSettings.from_env()\n    else:\n        raise","preventionTips":["Remember this config has no 'infinite timeout' — always a positive seconds value.","Size timeouts above your slowest expected LLM call (long prompts can take 60s+).","Unit-test the config loader with boundary values 0, 1, and a large value."],"tags":["python","configuration","validation","timeout"],"backgroundTag":null,"analyzedSha":"606a07d341a47be773fab7f4b71177f53f96b2c3","analyzedAt":"2026-08-14T22:57:27.446Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}