Files
supabase/apps/studio/lib/ai/model.test.ts
Saxon FletcherandCursor 9b17ce8f2c chore(studio): default assistant to GPT-5.6 Luna (#49749)
## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

## What kind of change does this PR introduce?

Feature / chore: hide assistant model selection in the UI and default
chats to GPT-5.6 Luna.

## What is the current behavior?

The assistant composer exposes a model picker. Paid orgs default to
`gpt-5.3-codex`; everyone else defaults to `gpt-5.4-nano`.

## What is the new behavior?

- The model picker is hidden in the assistant composer and Explorer
home.
- Chats default to `gpt-5.6-luna` with `reasoningEffort: medium`.
- Model selection plumbing is kept (registry, entitlements, `setModel`,
generate-v4 request body) so a requested model can still be honored when
provided.
- Other completion endpoints still use `gpt-5.4-nano`.

## Additional context

Model selector UI can be re-enabled by passing `selectedModel` /
`onSelectModel` to `AssistantChatForm`.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Added support for the GPT-5.6 Luna model with medium reasoning
capability.
  * Made GPT-5.6 Luna the default assistant model.
* **Improvements**
* Simplified assistant chat by removing model selection from the primary
chat experience.
  * Updated model fallback behavior to use the standard assistant model.
* Chat forms can now optionally display model selection when configured.
* **Tests**
* Updated model coverage and assistant chat tests for the new defaults
and behavior.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-02 10:24:37 +10:00

100 lines
3.1 KiB
TypeScript

import { openai } from '@ai-sdk/openai'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import * as bedrockModule from './bedrock'
import { getModel } from './model'
import { DEFAULT_COMPLETION_MODEL, openaiModelEntry } from './model.utils'
vi.mock('@ai-sdk/openai', () => ({
openai: vi.fn(() => 'openai-model'),
}))
vi.mock('./bedrock', async () => ({
...(await vi.importActual('./bedrock')),
createRoutedBedrock: vi.fn(() => async (_modelId: string) => 'bedrock-model'),
checkAwsCredentials: vi.fn(),
}))
describe('getModel', () => {
const originalEnv = { ...process.env }
beforeEach(() => {
vi.resetAllMocks()
})
afterEach(() => {
process.env = { ...originalEnv }
})
it('returns bedrock model without systemProviderOptions', async () => {
vi.mocked(bedrockModule.checkAwsCredentials).mockResolvedValue(true)
vi.stubEnv('AWS_BEDROCK_ROLE_ARN', 'test')
const { modelParams, error, systemProviderOptions } = await getModel({
provider: 'bedrock',
routingKey: 'test',
})
expect(modelParams?.model).toEqual('bedrock-model')
expect(systemProviderOptions).toBeUndefined()
expect(error).toBeUndefined()
})
it('returns error when bedrock credentials are not available', async () => {
vi.mocked(bedrockModule.checkAwsCredentials).mockResolvedValue(false)
const { error } = await getModel({ provider: 'bedrock', routingKey: 'test' })
expect(error).toBeDefined()
})
it('returns openai model with default model', async () => {
vi.stubEnv('OPENAI_API_KEY', 'test-key')
const { modelParams, systemProviderOptions } = await getModel({
provider: 'openai',
modelEntry: openaiModelEntry({ id: 'gpt-5.4-nano' }),
})
expect(modelParams?.model).toEqual('openai-model')
expect(openai).toHaveBeenCalledWith('gpt-5.4-nano')
expect(systemProviderOptions).toBeUndefined()
})
it('returns error when OPENAI_API_KEY is not available', async () => {
vi.stubEnv('OPENAI_API_KEY', '')
const { error } = await getModel({
provider: 'openai',
modelEntry: openaiModelEntry({ id: 'gpt-5.4-nano' }),
})
expect(error).toEqual(new Error('OPENAI_API_KEY not available'))
})
it('returns openai gpt-5.3-codex with reasoning effort', async () => {
vi.stubEnv('OPENAI_API_KEY', 'test-key')
const { modelParams, error } = await getModel({
provider: 'openai',
modelEntry: openaiModelEntry({ id: 'gpt-5.3-codex', reasoningEffort: 'low' }),
})
expect(error).toBeUndefined()
expect(modelParams?.model).toEqual('openai-model')
expect(openai).toHaveBeenCalledWith('gpt-5.3-codex')
expect(modelParams?.providerOptions?.openai?.reasoningEffort).toBe('low')
})
it('applies reasoningEffort from DEFAULT_COMPLETION_MODEL', async () => {
vi.stubEnv('OPENAI_API_KEY', 'test-key')
const { modelParams, error } = await getModel({
provider: 'openai',
modelEntry: DEFAULT_COMPLETION_MODEL,
})
expect(error).toBeUndefined()
expect(openai).toHaveBeenCalledWith('gpt-5.4-nano')
expect(modelParams?.providerOptions?.openai?.reasoningEffort).toBe('none')
})
})