fix(coding): preserve runtime model and failure contracts
This commit is contained in:
@@ -339,11 +339,24 @@ export class CodingConversationService {
|
||||
}
|
||||
|
||||
async setModel(conversationId: string, model: ProductModelRef): Promise<ConversationModelState> {
|
||||
const { project } = await this.projects.findActiveConversation(conversationId);
|
||||
const { project, conversation } = await this.projects.findActiveConversation(conversationId);
|
||||
let selected: ProductModelRef;
|
||||
try {
|
||||
selected = await this.runtime.validateModel(model);
|
||||
} catch (error) { runtimeError(error); }
|
||||
if (conversation.modelResolution === 'resolved' && conversation.model) {
|
||||
await this.ensurePrepared(conversationId);
|
||||
let state: ConversationModelState;
|
||||
try {
|
||||
state = await this.runtime.setModel({
|
||||
conversationId,
|
||||
accountId: selected.accountId,
|
||||
modelId: selected.modelId,
|
||||
});
|
||||
} catch (error) { runtimeError(error); }
|
||||
await persist(() => this.projects.conversationStore(project.path).setModelState(conversationId, state));
|
||||
return state;
|
||||
}
|
||||
const state: ConversationModelState = {
|
||||
model: selected,
|
||||
modelResolution: 'resolved',
|
||||
@@ -364,7 +377,7 @@ export class CodingConversationService {
|
||||
const { project } = await this.projects.findActiveConversation(conversationId);
|
||||
try {
|
||||
const state = await this.runtime.setThinking({ conversationId, thinkingLevel });
|
||||
await this.projects.conversationStore(project.path).setModelState(conversationId, state);
|
||||
await persist(() => this.projects.conversationStore(project.path).setModelState(conversationId, state));
|
||||
return state;
|
||||
} catch (error) { runtimeError(error); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user