Skip to content

Commit 71fc801

Browse files
authored
feat: remove auto model selection option (#1548)
* feat: remove auto model selection option * set the default model if undefined
1 parent c030c75 commit 71fc801

File tree

4 files changed

+35
-5
lines changed

4 files changed

+35
-5
lines changed

chat-client/src/client/texts/modelSelection.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ export const modelSelection: ChatItemFormItem = {
2323
type: 'select',
2424
id: 'model-selection',
2525
options: modelOptions,
26-
placeholder: 'Auto',
26+
mandatory: true,
27+
hideMandatoryIcon: true,
2728
border: false,
2829
autoWidth: true,
2930
}
@@ -32,5 +33,5 @@ export const getModelSelectionChatItem = (modelId: string): ChatItem => ({
3233
type: ChatItemType.DIRECTIVE,
3334
contentHorizontalAlignment: 'center',
3435
fullWidth: true,
35-
body: `Switched model to ${modelId === '' ? 'Auto' : modelRecord[modelId as BedrockModel].label}`,
36+
body: `Switched model to ${modelRecord[modelId as BedrockModel].label}`,
3637
})

server/aws-lsp-codewhisperer/src/language-server/agenticChat/agenticChatController.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2479,6 +2479,32 @@ ${' '.repeat(8)}}
24792479
})
24802480
})
24812481
})
2482+
2483+
describe('onPromptInputOptionChange', () => {
2484+
it('should set model ID from prompt input options', () => {
2485+
const mockTabId = 'tab-1'
2486+
const modelId = 'CLAUDE_3_7_SONNET_20250219_V1_0'
2487+
const setModelIdStub = sinon.stub(ChatDatabase.prototype, 'setModelId')
2488+
2489+
// Create a session
2490+
chatController.onTabAdd({ tabId: mockTabId })
2491+
2492+
// Call onPromptInputOptionChange with model selection
2493+
chatController.onPromptInputOptionChange({
2494+
tabId: mockTabId,
2495+
optionsValues: { 'model-selection': modelId },
2496+
})
2497+
2498+
// Verify the session has the model ID set
2499+
const session = chatSessionManagementService.getSession(mockTabId).data
2500+
assert.strictEqual(session!.modelId, modelId)
2501+
2502+
// Verify the model ID was saved to the database
2503+
sinon.assert.called(setModelIdStub)
2504+
2505+
setModelIdStub.restore()
2506+
})
2507+
})
24822508
})
24832509

24842510
// The body may include text-based progress updates from tool invocations.

server/aws-lsp-codewhisperer/src/language-server/agenticChat/agenticChatController.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ import {
119119
outputLimitExceedsPartialMsg,
120120
responseTimeoutMs,
121121
responseTimeoutPartialMsg,
122+
defaultModelId,
122123
} from './constants'
123124
import { URI } from 'vscode-uri'
124125
import { AgenticChatError, customerFacingErrorCodes, isRequestAbortedError, unactionableErrorCodes } from './errors'
@@ -2233,7 +2234,9 @@ export class AgenticChatController implements ChatHandlers {
22332234
onTabAdd(params: TabAddParams) {
22342235
this.#telemetryController.activeTabId = params.tabId
22352236

2236-
const modelId = this.#chatHistoryDb.getModelId()
2237+
// Since model selection is mandatory, the only time modelId is not set is when the chat history is empty.
2238+
// In that case, we use the default modelId.
2239+
const modelId = this.#chatHistoryDb.getModelId() ?? defaultModelId
22372240
this.#features.chat.chatOptionsUpdate({ modelId: modelId, tabId: params.tabId })
22382241

22392242
const sessionResult = this.#chatSessionManagementService.createSession(params.tabId)
@@ -2630,8 +2633,7 @@ export class AgenticChatController implements ChatHandlers {
26302633
}
26312634

26322635
session.pairProgrammingMode = params.optionsValues['pair-programmer-mode'] === 'true'
2633-
session.modelId =
2634-
params.optionsValues['model-selection'] === 'auto' ? undefined : params.optionsValues['model-selection']
2636+
session.modelId = params.optionsValues['model-selection']
26352637

26362638
this.#chatHistoryDb.setModelId(session.modelId)
26372639
}

server/aws-lsp-codewhisperer/src/language-server/agenticChat/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ export const outputLimitExceedsPartialMsg = 'output exceeds maximum character li
55
export const responseTimeoutMs = 170_000
66
export const responseTimeoutPartialMsg = 'Response processing timed out after'
77
export const clientTimeoutMs = 180_000
8+
export const defaultModelId = 'CLAUDE_3_7_SONNET_20250219_V1_0' // TODO: this can't be imported from chat-client, so we hardcode it here

0 commit comments

Comments
 (0)