Skip to content
Source
Sign inSign up
TanStack/schemas
Open History to see the last commit

dashscope-native-budget-scope.test.ts

80 lines2.3 KB

1import { expect, it } from 'vitest'
2import docs from './fixtures/native-reasoning-docs.json'
3import {
4 applyDashscopeThinking,
5 parseDashscopeThinking,
6 DASHSCOPE_THINKING_URL,
7} from './dashscope-thinking.ts'
8​
9it('reads mandatory budget mode only for native thinking-only models in explicit budget families', () => {
10 const parsed = parseDashscopeThinking(docs[DASHSCOPE_THINKING_URL])
11 for (const rawId of [
12 'qwen3.7-max-2026-05-17',
13 'qwen3.8-2.4t-a95b',
14 'qwen3.6-35b-a3b',
15 'qwen3.7-max-preview',
16 'kimi-k2.7-code',
17 'glm-5.3',
18 'qwen3-next-80b-a3b-thinking',
19 'qwen3-30b-a3b-thinking-2507',
20 'qwen3-235b-a22b-thinking-2507',
21 ]) {
22 const model = applyDashscopeThinking(
23 { rawId, activity: 'chat' },
24 { ...parsed, hash: 'source' },
25 )
26 expect(model.reasoning).toEqual({
27 mode: 'budget',
28 mandatory: rawId === 'qwen3.6-35b-a3b' ? null : true,
29 })
30 expect(model.requestMap).toBeUndefined()
31 }
32 expect(
33 applyDashscopeThinking(
34 { rawId: 'qwq-plus', activity: 'chat' },
35 { ...parsed, hash: 'source' },
36 ).reasoning,
37 ).toBeUndefined()
38 expect(
39 applyDashscopeThinking(
40 { rawId: 'qwen3-unpublished', activity: 'chat' },
41 { ...parsed, hash: 'source' },
42 ).reasoning,
43 ).toBeUndefined()
44})
45it('does not derive budget scope from code examples or malformed scope declarations', () => {
46 const text = docs[DASHSCOPE_THINKING_URL]
47 expect(() =>
48 parseDashscopeThinking(
49 text.replace(
50 /Applicable to [^\n]+? series models\./,
51 'Applicable to invalid family labels series models.',
52 ),
53 ),
54 ).toThrow()
55 expect(() =>
56 parseDashscopeThinking(
57 text.replace(/ {2}`thinking_budget`Parameter[^\n]+/, '```\n$&\n```'),
58 ),
59 ).toThrow()
60})
61​
62it('rejects negated native budget applicability and thinking-only declarations', () => {
63 const text = docs[DASHSCOPE_THINKING_URL]
64 expect(() =>
65 parseDashscopeThinking(
66 text.replace(
67 'Applicable to Qwen3.8',
68 'Do not assume Applicable to Qwen3.8',
69 ),
70 ),
71 ).toThrow('negated native budget')
72 expect(() =>
73 parseDashscopeThinking(
74 text.replace(
75 'Supports thinking mode only',
76 'Does not support thinking mode only',
77 ),
78 ),
79 ).toThrow('negated native model mode')
80})