Skip to content

fix(chat): stop refusing queries that ask to translate - #595

Open
abdulrafey1 wants to merge 1 commit into
mainfrom
refey/fix/lang-07-translate-keyword
Open

fix(chat): stop refusing queries that ask to translate#595
abdulrafey1 wants to merge 1 commit into
mainfrom
refey/fix/lang-07-translate-keyword

Conversation

@abdulrafey1

@abdulrafey1 abdulrafey1 commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Part of: Sparkth UI, emails, API errors, and AI-generated content are English-only

Bottom of the phase-2 generation-language stack. Ships on its own and does not close the issue.

What

Stops the chat scope pre-filter hard-refusing any query containing the word "translate", so a
translation request reaches the LLM scope classifier that can actually judge it.

Changes

  • fix(plugins): remove "translate" from the chat plugin's out-of-scope keyword list
  • test(plugins): add the three previously-refused phrasings, plus a contrast case and two
    non-English queries pinning the pre-filter's fall-through

How to Test

  1. uv run pytest sparkth/plugins/chat/tests/test_scope_validation.py -v — 17 tests pass.
  2. Confirm the fix is load-bearing: re-add "translate" to out_of_scope in
    sparkth/plugins/chat/assets/scope_keywords.json and re-run — test_translation_requests_reach_the_classifier
    fails. Revert.
  3. In the running app, send "translate this into Spanish" to the chat plugin: it is no longer
    met with the fixed refusal sentence.

Notes

No migration, no env var, no dependency. Behaviour change only in the cheap keyword pre-filter —
the LLM classifier still runs on everything that passes it, and "poem", "story", "fiction"
and "rewrite" remain out of scope, so a genuine "translate this poem" is still refused.

The keyword layer cannot express the system prompt's "unrelated to course content" qualifier,
which is why it over-refused. One of the four new phrasings —
translate this outline into Spanish — already passed before this change, because the in-scope
outline short-circuits the check; it is kept as an explicit contrast case and labelled as one.

This description was written with the assistance of an LLM (Claude).

"translate" sat in the out-of-scope keyword list, so any query using the word without
also hitting an in-scope keyword was hard-refused by the pre-filter and never reached
the LLM scope classifier. The keyword layer cannot express the system prompt's
"unrelated to course content" qualifier, so it over-refused: "translate this into
Spanish" was rejected outright.

The classifier still catches the genuine case, and "poem", "story", "fiction" and
"rewrite" remain in the list. Adds the three previously-refused phrasings as regression
cases, plus the research table's contrast case that already passed because an in-scope
keyword short-circuits the check, and two non-English queries pinning the fall-through
the pre-filter has always had but nothing asserted.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@abdulrafey1 abdulrafey1 changed the title refey/fix/lang 07 translate keyword fix(chat): stop refusing queries that ask to translate Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants