DeepTutor icon indicating copy to clipboard operation
DeepTutor copied to clipboard

Vocabulary help returns 503 when the model returns a term that is not an exact substring of a short selection

Open evan188199-tech opened this issue 3 weeks ago • 1 comments

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:

  1. Drop terms that don't match the selection and return the rest; only fail if none remain.
  2. Retry once with a stricter instruction before failing.
  3. Include the rejected term in the error reason (or logs) for debugging.

Steps to reproduce

  1. Upload a short Markdown text as a Reading material and enable the vocabulary extension.
  2. Select a two-word phrase (e.g. redstone dust).
  3. 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.

evan188199-tech avatar Nov 09 '26 23:11 evan188199-tech

Verified fixed on the current local dev branch (38f9ed2e5ca9), with regression checks.

will be fixed in the next releases!

pancacake avatar Nov 14 '26 16:11 pancacake