{"record":{"id":"7a9d802073d98a12","repo":"MemPalace/mempalace","slug":"empty-response-from-self-name-model-self-model","errorCode":null,"errorMessage":"Empty response from {self.name} (model={self.model})","messagePattern":"Empty response from (.+?) \\(model=(.+?)\\)","errorType":"exception","errorClass":"LLMError","httpStatus":null,"severity":"error","filePath":"mempalace/llm_client.py","lineNumber":360,"sourceCode":"            \"model\": self.model,\n            \"messages\": [\n                {\"role\": \"system\", \"content\": system},\n                {\"role\": \"user\", \"content\": user},\n            ],\n            \"temperature\": 0.1,\n        }\n        if json_mode:\n            body[\"response_format\"] = {\"type\": \"json_object\"}\n        headers = {}\n        if self.api_key:\n            headers[\"Authorization\"] = f\"Bearer {self.api_key}\"\n        data = _http_post_json(self._resolve_url(), body, headers=headers, timeout=self.timeout)\n        try:\n            text = data[\"choices\"][0][\"message\"][\"content\"]\n        except (KeyError, IndexError, TypeError) as e:\n            raise LLMError(f\"Unexpected response shape: {e}\") from e\n        if not text:\n            raise LLMError(f\"Empty response from {self.name} (model={self.model})\")\n        return LLMResponse(text=text, model=self.model, provider=self.name, raw=data)\n\n\n# ==================== ANTHROPIC ====================\n\n\nclass AnthropicProvider(LLMProvider):\n    name = \"anthropic\"\n    DEFAULT_ENDPOINT = \"https://api.anthropic.com\"\n    API_VERSION = \"2023-06-01\"\n\n    def __init__(\n        self,\n        model: str,\n        api_key: Optional[str] = None,\n        endpoint: Optional[str] = None,\n        timeout: int = 120,\n        **_: object,","sourceCodeStart":342,"sourceCodeEnd":378,"githubUrl":"https://github.com/MemPalace/mempalace/blob/06cb6987f02610784fefbad4b2bd5d026d164ba6/mempalace/llm_client.py#L342-L378","documentation":"LLMError raised by OpenAICompatProvider.classify() when choices[0].message.content exists but is empty. The request and parsing succeeded; the model simply generated zero content tokens.","triggerScenarios":"Models that return only tool calls or reasoning with no final content; content filtered/empty under response_format json_object when the model cannot produce valid JSON; degenerate outputs from too-small num_ctx or max_tokens.","commonSituations":"json_mode=True with models that ignore or choke on JSON instructions; reasoning models spending the entire budget on hidden reasoning; nearly-empty prompts producing one blank token.","solutions":["Retry once — empty generations are often transient sampling artifacts","Relax json_mode or lower temperature to get actual content","Use an instruct-tuned model with solid JSON support","Raise max_tokens/context so the model has room for a final answer"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"from mempalace.llm_client import LLMError\n\nfor attempt in range(2):\n    try:\n        return provider.classify(system, user, json_mode=True)\n    except LLMError as e:\n        if \"Empty response\" in str(e) and attempt == 0:\n            continue  # empty generation — retry once\n        raise","preventionTips":["Prefer json-mode-capable instruct models for structured tasks","Set temperature low (the provider already uses 0.1) and prompts explicit","Log raw responses on failure to distinguish empty content from shape issues"],"tags":["llm","openai-compat","empty-response","models"],"backgroundTag":null,"analyzedSha":"06cb6987f02610784fefbad4b2bd5d026d164ba6","analyzedAt":"2026-08-15T03:03:36.213Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}