-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Description
Feature hasn't been suggested before.
- I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
Is it possible to opt-out of the additional summarization calls that occur per message? I was hoping to see a configuration option skip these requests.
In this example, I send 2 requests to devstral, and opencode inserts an additional 3 requests for summary generation to haiku. (this is a screenshot of Helicone, which I'm using to monitor requests from opencode)
A summary is requested for every user message. And an additional summary request generates the session title, which is essentially a duplicate of the first message summary request.
I see the session summary in the TUI, but don't see any message summaries. So the message summaries don't seem to be adding any value for TUI users.
The message summaries are used in the web/desktop app, but I'm not using this app, and even if I did, I would prefer to downgrade the message summaries to just the first few words of each message in order to avoid the additional summarization requests.
summarizeMessage is the function that makes these requests. It populates userMsg.summary.title.
opencode/packages/opencode/src/session/summary.ts
Lines 64 to 111 in f53ebaf
| async function summarizeMessage(input: { messageID: string; messages: MessageV2.WithParts[] }) { | |
| const messages = input.messages.filter( | |
| (m) => m.info.id === input.messageID || (m.info.role === "assistant" && m.info.parentID === input.messageID), | |
| ) | |
| const msgWithParts = messages.find((m) => m.info.id === input.messageID)! | |
| const userMsg = msgWithParts.info as MessageV2.User | |
| const diffs = await computeDiff({ messages }) | |
| userMsg.summary = { | |
| ...userMsg.summary, | |
| diffs, | |
| } | |
| 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.TextPart | |
| if (textPart && !userMsg.summary?.title) { | |
| const agent = await Agent.get("title") | |
| const stream = await LLM.stream({ | |
| agent, | |
| user: userMsg, | |
| tools: {}, | |
| model: agent.model ? await Provider.getModel(agent.model.providerID, agent.model.modelID) : small, | |
| small: true, | |
| messages: [ | |
| { | |
| role: "user" as const, | |
| content: ` | |
| The following is the text to summarize: | |
| <text> | |
| ${textPart?.text ?? ""} | |
| </text> | |
| `, | |
| }, | |
| ], | |
| abort: new AbortController().signal, | |
| sessionID: userMsg.sessionID, | |
| system: [], | |
| retries: 3, | |
| }) | |
| const result = await stream.text | |
| log.info("title", { title: result }) | |
| userMsg.summary.title = result | |
| await Session.updateMessage(userMsg) | |
| } |