Vocabulary help returns 503 when the model returns a term that is not an exact substring of a short selection
Version: v1.7.2 (main has the same check in deeptutor/reading/vocabulary.py)
LLM: GLM-5.3 via an OpenAI-compatible endpoint
What happened
In Reading, I selected the short phrase redstone dust in an uploaded Markdown material and ran Vocabulary help → Explain vocabulary. The request failed with:
POST /api/reading/materials/<id>/extensions/vocabulary/actions/explain → 503
{"detail": {"message": "This reading action is temporarily unavailable.", "recoverable": true, "reason": "Vocabulary terms must come from the selection."}}
Selecting the whole sentence instead worked (200, three terms returned).
Why it seems to happen
_vocabulary() rejects the entire response if any single term fails _term_comes_from_selection(), which requires the normalized term to appear verbatim (word-bounded) in the selection. With a short selection, the model is more likely to return a related form (inflection, singular/plural, or a closely related word), and one such term makes the whole action fail. Because the 503 body does not include the offending term, users can't tell what went wrong.
Expected A short selection still gets an explanation. Some options:
- Drop terms that don't match the selection and return the rest; only fail if none remain.
- Retry once with a stricter instruction before failing.
- Include the rejected term in the error reason (or logs) for debugging.
Steps to reproduce
- Upload a short Markdown text as a Reading material and enable the vocabulary extension.
- Select a two-word phrase (e.g.
redstone dust). - Run Explain vocabulary; it intermittently returns 503 with the reason above.
I'm happy to open a PR for option 1 (and a unit test) if that approach sounds right.
Verified fixed on the current local dev branch (38f9ed2e5ca9), with regression checks.
will be fixed in the next releases!