Files
plugins/packages/kimi-desktop/catalog-thinking.test.mjs
kupakupa 327ec8bc9d kimi-desktop: a model that can't turn thinking off is declared always_thinking (#350)
A model whose catalog lists every reasoning level magpie knows, none of
them "none", is declared always_thinking to Kimi desktop, in its runtime
entry and its menu. Kimi then stops sending an old Off choice to a model
that can't turn thinking off. A model that offers none, lists no levels or
lists an unknown one keeps its old declaration.

Run at the reviewed head fa08b22: bun test packages/kimi-desktop
packages/kimi-work, 65 pass. catalog-thinking.test.mjs against main's
catalog.mjs: 4 of 9 fail (the always_thinking cases), so the test holds the
change. The author's real Kimi 3.2.18.13 runs on Windows are in the PR; not
tried on macOS here.
2026-10-24 15:07:50 +08:00

39 lines
2.1 KiB
JavaScript

import {test, expect} from 'bun:test';
import {normalizeModels, mergeRuntimeModels} from './catalog.mjs';
const row = (id, reasoning, efforts) => ({id: 'fixture/' + id, reasoning,
supported_reasoning_levels: efforts.map(effort => ({effort}))});
test.each([
['required', true, ['low', 'high', 'max'], true],
['single-required-level', true, ['high'], true],
['duplicate-required-level', true, ['high', 'high'], true],
['toggle', true, ['none', 'low', 'high'], false],
['unknown-levels', true, [], false],
['unrecognized-off', true, ['off', 'high'], false],
['future-level', true, ['future', 'high'], false],
['no-thinking', false, ['high'], false],
])('thinking capability: %s', (id, reasoning, efforts, always) => {
const model = normalizeModels({data: [row(id, reasoning, efforts)]})[0];
expect(model.runtime.capabilities.includes('thinking')).toBe(reasoning);
expect(model.runtime.capabilities.includes('always_thinking')).toBe(always);
expect(model.menu.daimonModelConfig.capabilities).toEqual(model.runtime.capabilities);
expect(model.menu.daimonModelConfig.supportEfforts).toEqual(model.runtime.supportEfforts ?? []);
if (efforts.includes('none')) {
expect(model.runtime.supportEfforts).toContain('none');
expect(model.menu.reasoningEffortOptions.some(e => e.reasoningEffort === 'none')).toBe(true);
}
});
test('capability refresh replaces only adapter models and retains native thinking settings', () => {
const required = normalizeModels({data: [row('required', true, ['low', 'high', 'max'])]});
const native = {model: 'native-model', capabilities: ['thinking'], defaultEffort: 'max', user: true};
const obsolete = {...required[0].runtime, capabilities: ['thinking']};
const merged = mergeRuntimeModels([native, obsolete], required);
expect(merged[0]).toBe(native);
expect(merged[1].capabilities).toContain('always_thinking');
expect(merged).toHaveLength(2);
const toggle = normalizeModels({data: [row('required', true, ['none', 'high'])]});
expect(mergeRuntimeModels(merged, toggle)[1].capabilities).not.toContain('always_thinking');
});