Repository navigation
fix(ts): report a bool temperature a checkpoint shipped, not load it silently - #1191
Merged
NandhaKishorM merged 2 commits intoOct 14, 2026
Conversation
…silently The port carries the same load-time diagnostic as `laya/agent.py` and has the same hole: `clampTemperature` refuses a bool and installs the neutral 1.0, and `Number(true)` is exactly that 1.0, so `if (Number(rawV) === applied) continue;` read a JSON `true` as an accepted temperature and said nothing. `false` was reported only because it floats to 0.0 and mismatches. `laya-ts/tests/temperature-loading.test.ts` is the first test over this loop: both bools named on the list and on a bucket, the neutral 1.0 proven to be what the answer is actually scaled by, out-of-range still named per entry, numeric strings and exact numbers still silent, and the non-number class still named. Python's loader got the matching change with the shared `laya.common.temperature_rejected`; the empty-list case is called out rather than "fixed", since `Number([])` is 0 where Python's `float([])` raises.
The assertion said which temperature clampTemperature installs for an empty list, and that value is the one place the port and the reference disagree (Number([]) is 0 so the port bounds it to TEMP_MIN, where Python's float([]) raises and falls back to the neutral 1.0). This test is about the loader naming the entry, not about which fallback it chose, so keep the naming assertion and drop the value.
This was referenced Oct 12, 2026
Owner
|
Merged in 0.4.7, alongside the Python side in #1190. Same bug, same cause, in the port: The test is doing more than naming the warning. It checks the answer is actually scaled by the 1.0 that was installed (logits |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
laya-ts/src/agent.ts:450now refuses to stay quiet when a checkpoint config ships a boolean where atemperature belongs, and
laya-ts/tests/temperature-loading.test.tsis added as the first test overthat load-time diagnostic.
One condition line plus the three comment lines that explain it, and one new test file. No public API
changed, no other behaviour touched.
This is the port of the Python fix that went up as #1190 (
laya.common.temperature_rejected, used bylaya/agent.py,laya/onnx_agent.pyandlaya/calibrate.py). The two loaders carry the samediagnostic and had the same hole, so both now ask the question the clamp itself asks.
Why
clampTemperaturetreats a bool as "not a number" and installs the neutral 1.0. The rejection testthen asked whether the raw value converts to the number it was turned into -- and
Number(true)is1.0, exactly the fallback. So the comparison matched, the entry was judged accepted, and a checkpoint
shipping
"temperature": [true, 2, 3]loaded in silence withtemperature[0]replaced by a value nocalibration ever fitted.
falsewas reported, but only by accident: it floats to 0.0, mismatches the1.0 fallback, and so looks like any other bad entry. Same input class, two opposite outcomes, which is
the tell that the test was re-deriving the clamp's answer instead of asking what the clamp did.
Confidence read off that silent entry is uncalibrated, and nothing told the user. The new path names
both the list entry and the bucket:
Behaviour kept deliberately, and pinned by tests so the next edit cannot lose it: numeric strings that
equal the applied value (
"2"-> 2.0) stay silent, out-of-range values are still named per entry, andnull/undefined/""/{}/"invalid"are still named. The empty list is not "fixed" tomatch Python: JS's
Number([])is 0, so the clamp bounds it toTEMP_MINwhere Python'sfloat([])raises and falls back to 1.0. The test asserts the port's own
[0.5, 2, 3]and says why in a comment.How it was verified
Steps 1-4 run on
npx --yes vitest run, i.e. the repo's own runner against the committed test file, sothe assertions are witnessed rather than assumed. Step 5 is a compiler cross-check. One command in
npm testcould not run here at all and is called out at the end.T1is the arm that matters: reverting only the condition makes exactly one test fail, and it is thetrueone whilefalsestays green.T2andT3break the silent-and-named guarantees in the otherdirections, which is how the harness shows the tests guard the whole behaviour, not just the new line.
Numbers, before and after, for
cfg.temperature = [true, 2, 3]withtemperature_by_options = {"choice:2": true}:agent.temperature[1, 2, 3][1, 2, 3](unchanged)agent.temperatureByOptions{"choice:2": 1}{"choice:2": 1}(unchanged)console.warncalls01, namingtemperature[0]=true -> 1andchoice:2=true -> 1systemOneprobability at the neutral TThe applied values are identical on purpose: this changes only whether the substitution is reported.
What could not run here.
npm testistest:types && vitest, andtest:types(
tsc --noEmit -p tests/tsconfig.types.json) cannot run in this checkout: the vendoredlaya-ts/node_moduleshas no.bin, sonpm run test:typesstops atsh: tsc: command not found,and invoking the local compiler directly leaves one error,
TS2688: Cannot find type definition file for 'node', because@types/nodeis not installed. Worth noting for reviewers: that gate includesonly
types/**/*.ts, so it never compiles any test file, mine included. CI'stypescriptjob does areal
npm cion node 20 and 22 and runsnpm test -- --run, so both halves will be exercised there.Overlap with open work
laya/,tests/vslaya-ts/).laya-ts/src/agent.tsat old 21 (imports) and old 837.git merge-tree --write-tree pr750 fix-ts-bool-temperature-diagnosticexits 0 with no conflicts.laya-ts/src/agent.ts, and a merge simulation conflicts -- but it conflicts identicallywithout my branch (
git merge-tree --write-tree pr340 c73908d9reports the same 14 files and thesame single
CONFLICTinlaya-ts/src/agent.ts), so that is feat(laya-ts): batch inference, tensor-plumbing perf fixes, and DX helpers #340's stale base againstmain, notsomething I add. Concretely, feat(laya-ts): batch inference, tensor-plumbing perf fixes, and DX helpers #340's copy of this loop is byte-identical to
main's, so the lines Ichange are not the collision.
laya-ts/tests/temperature-loading.test.ts; the path does not exist onmainand no open PR adds it.Checklist
main(c73908d9 release: 0.4.6)vitest runis green on the new file (5/5) and the suite has no newfailure; the
test:typeshalf ofnpm testcannot run in this checkout, for the reason statedunder "What could not run here".