MemPalace/mempalace · error · LLMError
Empty response from {self.name} (model={self.model})
Error message
Empty response from {self.name} (model={self.model}) What it means
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.
Source
Thrown at mempalace/llm_client.py:360
"model": self.model,
"messages": [
{"role": "system", "content": system},
{"role": "user", "content": user},
],
"temperature": 0.1,
}
if json_mode:
body["response_format"] = {"type": "json_object"}
headers = {}
if self.api_key:
headers["Authorization"] = f"Bearer {self.api_key}"
data = _http_post_json(self._resolve_url(), body, headers=headers, timeout=self.timeout)
try:
text = data["choices"][0]["message"]["content"]
except (KeyError, IndexError, TypeError) as e:
raise LLMError(f"Unexpected response shape: {e}") from e
if not text:
raise LLMError(f"Empty response from {self.name} (model={self.model})")
return LLMResponse(text=text, model=self.model, provider=self.name, raw=data)
# ==================== ANTHROPIC ====================
class AnthropicProvider(LLMProvider):
name = "anthropic"
DEFAULT_ENDPOINT = "https://api.anthropic.com"
API_VERSION = "2023-06-01"
def __init__(
self,
model: str,
api_key: Optional[str] = None,
endpoint: Optional[str] = None,
timeout: int = 120,
**_: object,View on GitHub (pinned to 06cb6987f0)
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
Defensive patterns
Strategy: retry
Try / catch
from mempalace.llm_client import LLMError
for attempt in range(2):
try:
return provider.classify(system, user, json_mode=True)
except LLMError as e:
if "Empty response" in str(e) and attempt == 0:
continue # empty generation — retry once
raise Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Empty response from Ollama (model={self.model})
- Empty response from Anthropic (model={self.model})
- openai-compat provider requires --llm-endpoint
- Unexpected response shape: {e}
- LLM_ENDPOINT must use http:// or https:// (got scheme {schem
AI-assisted analysis of MemPalace/mempalace@06cb6987f0 (2026-08-15).
Data as JSON: /api/errors/7a9d802073d98a12.
Report an issue: GitHub.