Skip to content

fix(laya-ts): forward a detected "en" so lang_temperatures.en applies - #1337

Merged
NandhaKishorM merged 1 commit into
NandhaKishorM:mainfrom
thread3d:fix/laya-ts-detect-en
Oct 24, 2026
Merged

NandhaKishorM merged 1 commit into
NandhaKishorM:mainfrom
thread3d:fix/laya-ts-detect-en

Conversation

@thread3d

Copy link
Copy Markdown
Contributor

What

Router.predict and Router.predictBatch forward the detected language unchanged instead of replacing "en" with null.

Why

The comment this replaced claimed Python's analyse never names English ("it only ever names non-English"). That is false: laya/lang.py returns language="en", and router.py forwards decision.detection.language with no special case, so an en entry in lang_temperatures is applied there. Here it was dead code: the same Agent honoured {lang: "en"} when called directly and ignored it through Router, so confidences differed from Python and from the agent's own answer.

How it was verified

cd laya-ts && npx vitest run tests/lang-temperature.test.ts

Checklist

  • Focused on one change (split unrelated work into another PR)
  • Rebased on the latest main (branch cut from upstream/main at 0.4.14)
  • Tests pass locally
  • Docs or examples updated when the public API changed

router.ts replaced the detected language with null when it was "en", on the belief --
stated in the comment it carried -- that Python's analyse never names English ("it only
ever names non-English"). That is false: laya/lang.py returns language="en" for English
Latin text, and router.py.predict forwards decision.detection.language with no special
case, so an "en" entry in lang_temperatures is applied there. Here it was dead code: the
same Agent honoured {lang: "en"} when called directly and ignored it through Router, so
confidences differed from Python and from the agent's own answer.

Both paths (predict and predictBatch) now forward the detected language unchanged. The
tests that asserted the old behaviour are rewritten, and an end-to-end case pins that an
"en" override moves the reported probability (0.7311 at temperature 2 vs 0.8808 at the
base 1.0) through Router.predict, not merely the forwarded option.
@NandhaKishorM
NandhaKishorM merged commit e4c0e91 into NandhaKishorM:main Oct 24, 2026
46 of 50 checks passed
NandhaKishorM added a commit that referenced this pull request Oct 24, 2026
33 PRs. Server hardening (#1331, #1332, #1333), TypeScript parity
(#1330, #1336, #1337, #1338, #1339, #1340, #1341, #1342, #1343),
fail-closed input handling in evals and the integrations (#1317, #1318,
#1319, #1320, #1321, #1322, #1326, #1335), exact and faster script
detection (#1334, #1349), JVM and .NET resource handling (#1327, #1328,
#1329, #1346), port goldens and clipping (#1324 excluded, #1325, #1344,
#1345), CI (#1323, #1347, #1348).

Verified before tagging: all 92 suites pass, 610 tests. ruff clean on
both lists. laya-ts 1247 tests across 44 files, tsc --noEmit clean.
Version agrees across pyproject.toml, laya.__version__ and nix/package.nix.
README carries 0.4.15 only.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@thread3d
thread3d deleted the fix/laya-ts-detect-en branch October 28, 2026 10:37
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