mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-02 08:33:36 +00:00
feat: enhance SDK options with thinking level support
- Introduced a new function, buildThinkingOptions, to handle the conversion of ThinkingLevel to maxThinkingTokens for the Claude SDK. - Updated existing SDK option creation functions to incorporate thinking options, ensuring that maxThinkingTokens are included based on the specified thinking level. - Enhanced the settings service to support migration of phase models to include thinking levels, improving compatibility with new configurations. - Added comprehensive tests for thinking level integration and migration logic, ensuring robust functionality across the application. This update significantly improves the SDK's configurability and performance by allowing for more nuanced control over reasoning capabilities.
This commit is contained in:
@@ -554,4 +554,203 @@ describe('sdk-options.ts', () => {
|
||||
expect(options.abortController).toBe(abortController);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getThinkingTokenBudget (from @automaker/types)', () => {
|
||||
it('should return undefined for "none" thinking level', async () => {
|
||||
const { getThinkingTokenBudget } = await import('@automaker/types');
|
||||
expect(getThinkingTokenBudget('none')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should return undefined for undefined thinking level', async () => {
|
||||
const { getThinkingTokenBudget } = await import('@automaker/types');
|
||||
expect(getThinkingTokenBudget(undefined)).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should return 1024 for "low" thinking level', async () => {
|
||||
const { getThinkingTokenBudget } = await import('@automaker/types');
|
||||
expect(getThinkingTokenBudget('low')).toBe(1024);
|
||||
});
|
||||
|
||||
it('should return 10000 for "medium" thinking level', async () => {
|
||||
const { getThinkingTokenBudget } = await import('@automaker/types');
|
||||
expect(getThinkingTokenBudget('medium')).toBe(10000);
|
||||
});
|
||||
|
||||
it('should return 16000 for "high" thinking level', async () => {
|
||||
const { getThinkingTokenBudget } = await import('@automaker/types');
|
||||
expect(getThinkingTokenBudget('high')).toBe(16000);
|
||||
});
|
||||
|
||||
it('should return 32000 for "ultrathink" thinking level', async () => {
|
||||
const { getThinkingTokenBudget } = await import('@automaker/types');
|
||||
expect(getThinkingTokenBudget('ultrathink')).toBe(32000);
|
||||
});
|
||||
});
|
||||
|
||||
describe('THINKING_TOKEN_BUDGET constant', () => {
|
||||
it('should have correct values for all thinking levels', async () => {
|
||||
const { THINKING_TOKEN_BUDGET } = await import('@automaker/types');
|
||||
|
||||
expect(THINKING_TOKEN_BUDGET.none).toBeUndefined();
|
||||
expect(THINKING_TOKEN_BUDGET.low).toBe(1024);
|
||||
expect(THINKING_TOKEN_BUDGET.medium).toBe(10000);
|
||||
expect(THINKING_TOKEN_BUDGET.high).toBe(16000);
|
||||
expect(THINKING_TOKEN_BUDGET.ultrathink).toBe(32000);
|
||||
});
|
||||
|
||||
it('should have minimum of 1024 for enabled thinking levels', async () => {
|
||||
const { THINKING_TOKEN_BUDGET } = await import('@automaker/types');
|
||||
|
||||
// Per Claude SDK docs: minimum is 1024 tokens
|
||||
expect(THINKING_TOKEN_BUDGET.low).toBeGreaterThanOrEqual(1024);
|
||||
expect(THINKING_TOKEN_BUDGET.medium).toBeGreaterThanOrEqual(1024);
|
||||
expect(THINKING_TOKEN_BUDGET.high).toBeGreaterThanOrEqual(1024);
|
||||
expect(THINKING_TOKEN_BUDGET.ultrathink).toBeGreaterThanOrEqual(1024);
|
||||
});
|
||||
|
||||
it('should have ultrathink at or below 32000 to avoid timeouts', async () => {
|
||||
const { THINKING_TOKEN_BUDGET } = await import('@automaker/types');
|
||||
|
||||
// Per Claude SDK docs: above 32000 risks timeouts
|
||||
expect(THINKING_TOKEN_BUDGET.ultrathink).toBeLessThanOrEqual(32000);
|
||||
});
|
||||
});
|
||||
|
||||
describe('thinking level integration with SDK options', () => {
|
||||
describe('createSpecGenerationOptions with thinkingLevel', () => {
|
||||
it('should not include maxThinkingTokens when thinkingLevel is undefined', async () => {
|
||||
const { createSpecGenerationOptions } = await import('@/lib/sdk-options.js');
|
||||
|
||||
const options = createSpecGenerationOptions({ cwd: '/test/path' });
|
||||
|
||||
expect(options.maxThinkingTokens).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should not include maxThinkingTokens when thinkingLevel is "none"', async () => {
|
||||
const { createSpecGenerationOptions } = await import('@/lib/sdk-options.js');
|
||||
|
||||
const options = createSpecGenerationOptions({
|
||||
cwd: '/test/path',
|
||||
thinkingLevel: 'none',
|
||||
});
|
||||
|
||||
expect(options.maxThinkingTokens).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should include maxThinkingTokens for "low" thinkingLevel', async () => {
|
||||
const { createSpecGenerationOptions } = await import('@/lib/sdk-options.js');
|
||||
|
||||
const options = createSpecGenerationOptions({
|
||||
cwd: '/test/path',
|
||||
thinkingLevel: 'low',
|
||||
});
|
||||
|
||||
expect(options.maxThinkingTokens).toBe(1024);
|
||||
});
|
||||
|
||||
it('should include maxThinkingTokens for "high" thinkingLevel', async () => {
|
||||
const { createSpecGenerationOptions } = await import('@/lib/sdk-options.js');
|
||||
|
||||
const options = createSpecGenerationOptions({
|
||||
cwd: '/test/path',
|
||||
thinkingLevel: 'high',
|
||||
});
|
||||
|
||||
expect(options.maxThinkingTokens).toBe(16000);
|
||||
});
|
||||
|
||||
it('should include maxThinkingTokens for "ultrathink" thinkingLevel', async () => {
|
||||
const { createSpecGenerationOptions } = await import('@/lib/sdk-options.js');
|
||||
|
||||
const options = createSpecGenerationOptions({
|
||||
cwd: '/test/path',
|
||||
thinkingLevel: 'ultrathink',
|
||||
});
|
||||
|
||||
expect(options.maxThinkingTokens).toBe(32000);
|
||||
});
|
||||
});
|
||||
|
||||
describe('createAutoModeOptions with thinkingLevel', () => {
|
||||
it('should not include maxThinkingTokens when thinkingLevel is undefined', async () => {
|
||||
const { createAutoModeOptions } = await import('@/lib/sdk-options.js');
|
||||
|
||||
const options = createAutoModeOptions({ cwd: '/test/path' });
|
||||
|
||||
expect(options.maxThinkingTokens).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should include maxThinkingTokens for "medium" thinkingLevel', async () => {
|
||||
const { createAutoModeOptions } = await import('@/lib/sdk-options.js');
|
||||
|
||||
const options = createAutoModeOptions({
|
||||
cwd: '/test/path',
|
||||
thinkingLevel: 'medium',
|
||||
});
|
||||
|
||||
expect(options.maxThinkingTokens).toBe(10000);
|
||||
});
|
||||
|
||||
it('should include maxThinkingTokens for "ultrathink" thinkingLevel', async () => {
|
||||
const { createAutoModeOptions } = await import('@/lib/sdk-options.js');
|
||||
|
||||
const options = createAutoModeOptions({
|
||||
cwd: '/test/path',
|
||||
thinkingLevel: 'ultrathink',
|
||||
});
|
||||
|
||||
expect(options.maxThinkingTokens).toBe(32000);
|
||||
});
|
||||
});
|
||||
|
||||
describe('createChatOptions with thinkingLevel', () => {
|
||||
it('should include maxThinkingTokens for enabled thinkingLevel', async () => {
|
||||
const { createChatOptions } = await import('@/lib/sdk-options.js');
|
||||
|
||||
const options = createChatOptions({
|
||||
cwd: '/test/path',
|
||||
thinkingLevel: 'high',
|
||||
});
|
||||
|
||||
expect(options.maxThinkingTokens).toBe(16000);
|
||||
});
|
||||
});
|
||||
|
||||
describe('createSuggestionsOptions with thinkingLevel', () => {
|
||||
it('should include maxThinkingTokens for enabled thinkingLevel', async () => {
|
||||
const { createSuggestionsOptions } = await import('@/lib/sdk-options.js');
|
||||
|
||||
const options = createSuggestionsOptions({
|
||||
cwd: '/test/path',
|
||||
thinkingLevel: 'low',
|
||||
});
|
||||
|
||||
expect(options.maxThinkingTokens).toBe(1024);
|
||||
});
|
||||
});
|
||||
|
||||
describe('createCustomOptions with thinkingLevel', () => {
|
||||
it('should include maxThinkingTokens for enabled thinkingLevel', async () => {
|
||||
const { createCustomOptions } = await import('@/lib/sdk-options.js');
|
||||
|
||||
const options = createCustomOptions({
|
||||
cwd: '/test/path',
|
||||
thinkingLevel: 'medium',
|
||||
});
|
||||
|
||||
expect(options.maxThinkingTokens).toBe(10000);
|
||||
});
|
||||
|
||||
it('should not include maxThinkingTokens when thinkingLevel is "none"', async () => {
|
||||
const { createCustomOptions } = await import('@/lib/sdk-options.js');
|
||||
|
||||
const options = createCustomOptions({
|
||||
cwd: '/test/path',
|
||||
thinkingLevel: 'none',
|
||||
});
|
||||
|
||||
expect(options.maxThinkingTokens).toBeUndefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user