The open source coding agent.
TypeScript
core: fix model selection in title generation to use user's model instead of assistant's
Dax Raad71a7ad1a4ebb
diff --git a/packages/opencode/src/session/summary.ts b/packages/opencode/src/session/summary.tsindex 83519307a32..2bd1b0da601 100644--- a/packages/opencode/src/session/summary.ts+++ b/packages/opencode/src/session/summary.ts@@ -74,11 +74,6 @@ export namespace SessionSummary {}await Session.updateMessage(userMsg)- const assistantMsg = messages.find((m) => m.info.role === "assistant")!.info as MessageV2.Assistant- const small =- (await Provider.getSmallModel(assistantMsg.providerID)) ??- (await Provider.getModel(assistantMsg.providerID, assistantMsg.modelID))-const textPart = msgWithParts.parts.find((p) => p.type === "text" && !p.synthetic) as MessageV2.TextPartif (textPart && !userMsg.summary?.title) {const agent = await Agent.get("title")@@ -86,7 +81,10 @@ export namespace SessionSummary {agent,user: userMsg,tools: {},- model: agent.model ? await Provider.getModel(agent.model.providerID, agent.model.modelID) : small,+ model: agent.model+ ? await Provider.getModel(agent.model.providerID, agent.model.modelID)+ : ((await Provider.getSmallModel(userMsg.model.providerID)) ??+ (await Provider.getModel(userMsg.model.providerID, userMsg.model.modelID))),small: true,messages: [{@@ -109,49 +107,6 @@ export namespace SessionSummary {userMsg.summary.title = resultawait Session.updateMessage(userMsg)}-- if (- messages.some(- (m) =>- m.info.role === "assistant" && m.parts.some((p) => p.type === "step-finish" && p.reason !== "tool-calls"),- )- ) {- if (diffs.length > 0) {- for (const msg of messages) {- for (const part of msg.parts) {- if (part.type === "tool" && part.state.status === "completed") {- part.state.output = "[TOOL OUTPUT PRUNED]"- }- }- }- const summaryAgent = await Agent.get("summary")- const stream = await LLM.stream({- agent: summaryAgent,- user: userMsg,- tools: {},- model: summaryAgent.model- ? await Provider.getModel(summaryAgent.model.providerID, summaryAgent.model.modelID)- : small,- small: true,- messages: [- ...MessageV2.toModelMessage(messages),- {- role: "user" as const,- content: `Summarize the above conversation according to your system prompts.`,- },- ],- abort: new AbortController().signal,- sessionID: userMsg.sessionID,- system: [],- retries: 3,- })- const result = await stream.text- if (result) {- userMsg.summary.body = result- }- }- await Session.updateMessage(userMsg)- }}export const diff = fn(