Skip to content

fix(model): detect English requests with URLs in userLanguage (#111) - #167

Draft
santinofuentesAI wants to merge 2 commits into
DojoCodingLabs:mainfrom
santinofuentesAI:fix/user-language-urls-en
Draft

santinofuentesAI wants to merge 2 commits into
DojoCodingLabs:mainfrom
santinofuentesAI:fix/user-language-urls-en

Conversation

@santinofuentesAI

@santinofuentesAI santinofuentesAI commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Closes #111

Fixes userLanguage() in packages/model/src/prompt.ts so requests containing URLs are detected from the user's prose outside links rather than falling back to the phone's locale or letting URL segments skew detection:

  • Strips URLs (https?://\S+ and www.\S+) before scoring language signals, returning undefined when only links or neutral text remain (so phone locale still decides).
  • Counts non-colliding Spanish and English word hits (plus Spanish diacritics/punctuation [¿¡ñáéíóú]) instead of short-circuiting on Spanish before checking English, and adds everyday Spanish and English verbs/connectors (read, and, summarize, for, it, open, check, explain, translate, lee, resúmeme, página/pagina, esta, etc.).
  • Keeps shared/ambiguous words (a, me, resume, no) out of cross-language competition (a is checked only when neither language has stronger matches, with a comment explaining why), preserving Spanish detection on phrases like "resume esta página: https://recetas.example/sopa" and "resume esta pagina: https://recetas.example/sopa".
  • Wrote failing tests first in packages/model/test/prompt-language.test.ts before updating packages/model/src/prompt.ts.

Vision fit

Serves VISION.md principle 5 ("Spanish and English, first-class"): a request phrased in English (including short URL prompts like refusal-recetario-6) now gets English detection and English code refusals regardless of whether the phone locale is es-419, without regressing Spanish requests that share ambiguous words like resume.

Non-negotiables

  • This keeps every non-negotiable in AGENTS.md as it is.
  • Or it changes one, and this is the accepted RFC: #

Checklist

  • It closes one issue, linked above, or it's a small fix (a typo, a broken link, a wrong comment). A feature has an accepted proposal.
  • I wrote the failing test first. It fails without this change and passes with it.
  • These pass: pnpm check:privacy, pnpm typecheck, pnpm lint, pnpm test and node scripts/guard/check.mjs --patterns scripts/guard/patterns.txt. (Checked against origin/main.)
  • No new network call, telemetry, analytics, ads or crash reporting. (A new request in an app adapter is explained below, with its host, skill and risk.)
  • No new dependency, or the reason for each one is below.
  • Every UI string is in packages/copy, in es-419 and en, with matching keys and placeholders, and no em or en dashes.
  • Tests, fixtures and screenshots use made-up data only.

Model path

  • This doesn't touch the model path: packages/model, agent, skills or eval, the prompt, the router, tool descriptions, normalizers, examples or the model file.
  • It does. The eval numbers from before and after are below, run as docs/evals.md says. No held-out case was tuned on.

packages/model/test/prompt-language.test.ts and the full @hermit/model suite (20 files, 629 tests) plus all repo gates pass locally. No held-out case or eval fixture was read or edited.

Marked Draft because I don't have llama-server and the GGUF model locally to run the before/after model evals (mac-eval.ts first-win, va, holdout, and bot-eval.ts) requested in #111.

Screenshots

  • No UI change.
  • UI change. Each changed screen is below, in both themes and both languages, with made-up data.

New dependencies and network calls

n/a

AI agents

  • No AI agent wrote any part of this.
  • An AI agent helped. Which one, and what it did: Antigravity assisted with writing the TDD test cases, designing the URL-stripping and balanced word scoring in userLanguage, running the test suite and all five repo gates, and drafting this PR description.
  • I read and ran everything in this pull request, and I can explain it.

…dingLabs#111)

Signed-off-by: Santino Fuentes <santinofuentesAI@users.noreply.github.com>
…dingLabs#111)

Signed-off-by: Santino Fuentes <santinofuentesAI@users.noreply.github.com>
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.

Bots: refuse in English when the request is in English

1 participant