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

reasoning-options.test.ts

50 lines1.5 KB

1import { describe, expect, it } from 'vitest'
2import { opencodeReasoningOptions } from '../src/adapters/text'
3import { OPENCODE_MODEL_REASONING } from '../src/model-meta'
4​
5describe('OpenCode chat({ reasoning }) model options', () => {
6 it('Claude: thinking with a token budget, disabled for off', () => {
7 const reasoning = OPENCODE_MODEL_REASONING['anthropic/claude-sonnet-4-5']
8 expect(
9 opencodeReasoningOptions(
10 'claude-sonnet-4-5',
11 { level: 'medium', summary: true },
12 reasoning,
13 ),
14 ).toEqual({ thinking: { type: 'enabled', budgetTokens: 8192 } })
15 expect(
16 opencodeReasoningOptions(
17 'claude-sonnet-4-5',
18 { level: 'high', summary: true, budgetTokens: 3000 },
19 reasoning,
20 ),
21 ).toEqual({ thinking: { type: 'enabled', budgetTokens: 3000 } })
22 expect(
23 opencodeReasoningOptions(
24 'claude-sonnet-4-5',
25 { level: 'off', summary: true },
26 reasoning,
27 ),
28 ).toEqual({ thinking: { type: 'disabled' } })
29 })
30​
31 it('other models: reasoningEffort and reasoningSummary', () => {
32 expect(
33 opencodeReasoningOptions(
34 'gpt-5.2',
35 { level: 'xhigh', summary: true },
36 OPENCODE_MODEL_REASONING['openai/gpt-5.2'],
37 ),
38 ).toEqual({ reasoningEffort: 'xhigh', reasoningSummary: 'auto' })
39 })
40​
41 it('sends nothing without a request', () => {
42 expect(
43 opencodeReasoningOptions(
44 'gpt-5.2',
45 undefined,
46 OPENCODE_MODEL_REASONING['openai/gpt-5.2'],
47 ),
48 ).toBeUndefined()
49 })
50})