kimi-desktop 0.1.6: separate reasoning effort and an optional context input budget for the primary and secondary roles.
The change (f07e7f4a..1d14a185, since the round-6 approval):
- The settings page and API save `<role>ReasoningEffort` and `<role>ContextTokens` for each role. Only efforts and context limits the catalog publishes are offered; an unknown limit allows no custom budget.
- Inference drops Kimi's top-level `thinking`, `reasoning` and `reasoning_effort`, and sends the chosen effort, or none for the provider default. Kimi's native menu aliases no longer choose the model.
- A custom budget counts a copy of the request through magpie's `/v1/messages/count_tokens`. Over the budget gives 400 `context_length_exceeded`; a failed count gives fixed 503 `context_count_unavailable`. No generation is sent in either case. Without a budget, nothing extra is sent.
- Role-scoped worker profiles (`v2:[model, role]`) tell primary from secondary even on the same model. Older roleless profiles keep their binding and use defaults.
- 1d14a185 removes blank lines only.
Run at 1d14a1859f63fd4bb512d492d1de419ad3e6c79a on mote (macOS, Bun 1.4.2, HOME/TMPDIR/XDG in the run's own folder):
- `bun test` in packages/kimi-desktop: 626 pass, 0 fail, 29 files.
- `bun scripts/check.mjs kimi-desktop`: exit 0.
- 14 hand breaks, each red in the package suite:
- drop `applyReasoningOptions`;
- strip thinking fields only when an effort is set;
- drop the budget check, or make it `>=`;
- `useFresh` false, or without its model check;
- a legacy roleless profile treated as primary;
- a profile name without its role;
- no `registerRoles`;
- no `optionsMatch` in save;
- no `refreshLiveModelOptions`;
- count with `redirect: 'follow'`, or with no reply size limit;
- a 131072 fallback for an unknown catalog context.
- CI at the head: test and on-npm pass. The PR merges onto main f379bf90+ with no conflicts.
Not blocking, left for a follow-up:
- Each inference now reads connection.json (adapter.mjs:547) with no fallback to the live connection. An unreadable file turns every request into 502, even without a budget.
- The comment above `applyReasoningOptions` ("Preserve the legacy connection untouched…") no longer matches the always-strip policy.
88 lines
3.3 KiB
JavaScript
88 lines
3.3 KiB
JavaScript
import { describe, expect, test } from 'bun:test';
|
|
import { normalizeModels } from './catalog.mjs';
|
|
|
|
// Synthetic catalog rows only. No network, no real user config, no paid tools.
|
|
const row = overrides => ({
|
|
id: 'moonshot/kimi-k2.5-options-synthetic',
|
|
display_name: 'Kimi K2.5 Synthetic',
|
|
...overrides,
|
|
});
|
|
|
|
const modelFor = overrides => normalizeModels({ data: [row(overrides)] })[0];
|
|
|
|
describe('catalog independent options capability metadata', () => {
|
|
test('exposes explicit known efforts and explicit context_window', () => {
|
|
const model = modelFor({
|
|
context_window: 262144,
|
|
supported_reasoning_levels: [
|
|
{ effort: 'low' },
|
|
{ effort: 'high' },
|
|
{ effort: 'low' },
|
|
{ effort: 'experimental-unknown' },
|
|
{},
|
|
],
|
|
});
|
|
expect(model.options).toEqual({ reasoningEfforts: ['low', 'high'], contextWindow: 262144 });
|
|
});
|
|
|
|
test('uses explicit valid context_length only when context_window is absent', () => {
|
|
const model = modelFor({
|
|
context_length: 200000,
|
|
supported_reasoning_levels: [{ effort: 'medium' }],
|
|
});
|
|
expect(model.options).toEqual({ reasoningEfforts: ['medium'], contextWindow: 200000 });
|
|
});
|
|
|
|
test('keeps unknown context and unknown efforts conservative, never 131072', () => {
|
|
const model = modelFor({
|
|
supported_reasoning_levels: [{ effort: 'mystery' }, {}, { effort: '' }],
|
|
});
|
|
expect(model.options).toEqual({ reasoningEfforts: [], contextWindow: null });
|
|
});
|
|
|
|
test('reasoning=false offers no thinking effort even when levels are advertised', () => {
|
|
const model = modelFor({
|
|
reasoning: false,
|
|
context_window: 131072,
|
|
supported_reasoning_levels: [{ effort: 'high' }, { effort: 'low' }],
|
|
});
|
|
expect(model.options).toEqual({ reasoningEfforts: [], contextWindow: 131072 });
|
|
});
|
|
|
|
test('valid context_window wins over a valid context_length', () => {
|
|
const model = modelFor({ context_window: 32000, context_length: 64000 });
|
|
expect(model.options).toEqual({ reasoningEfforts: [], contextWindow: 32000 });
|
|
});
|
|
|
|
test('unknown options context leaves the existing runtime fallback untouched', () => {
|
|
const model = modelFor({});
|
|
expect(model.options).toEqual({ reasoningEfforts: [], contextWindow: null });
|
|
expect(model.runtime.maxContextSize).toBe(131072);
|
|
});
|
|
|
|
test('non-positive or non-safe-integer declared contexts are unknown for both context fields', () => {
|
|
for (const field of ['context_window', 'context_length']) {
|
|
for (const value of [0, -1, 1.5, Number.MAX_SAFE_INTEGER + 1]) {
|
|
const model = modelFor({ [field]: value });
|
|
expect(model.options.contextWindow).toBe(null);
|
|
}
|
|
}
|
|
});
|
|
|
|
test('invalid context_window falls through to a valid context_length', () => {
|
|
const model = modelFor({
|
|
context_window: -1,
|
|
context_length: 64000,
|
|
});
|
|
expect(model.options).toEqual({ reasoningEfforts: [], contextWindow: 64000 });
|
|
});
|
|
|
|
test('options has exactly the two independent capability keys, no invented default effort', () => {
|
|
const model = modelFor({
|
|
context_window: 100000,
|
|
supported_reasoning_levels: [{ effort: 'high' }, { effort: 'medium' }],
|
|
});
|
|
expect(model.options).toEqual({ reasoningEfforts: ['high', 'medium'], contextWindow: 100000 });
|
|
});
|
|
});
|