diff options
| author | Dax Raad <[email protected]> | 2025-10-29 14:28:43 -0400 |
|---|---|---|
| committer | Dax Raad <[email protected]> | 2025-10-29 14:28:43 -0400 |
| commit | 5553efea5ed175841836fa995cd794593aa484ee (patch) | |
| tree | 6c1d893fa69c16820c2b1a93b21272a7a12e3f32 | |
| parent | 0ff73ed8a6cfa2beb6ce436a921cb98f836677c3 (diff) | |
| download | opencode-5553efea5ed175841836fa995cd794593aa484ee.tar.gz opencode-5553efea5ed175841836fa995cd794593aa484ee.zip | |
only generate user message summary if no diffs
| -rw-r--r-- | packages/opencode/src/session/summary.ts | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/packages/opencode/src/session/summary.ts b/packages/opencode/src/session/summary.ts index 744465dcf..115fbe452 100644 --- a/packages/opencode/src/session/summary.ts +++ b/packages/opencode/src/session/summary.ts @@ -98,23 +98,29 @@ export namespace SessionSummary { m.parts.some((p) => p.type === "step-finish" && p.reason !== "tool-calls"), ) ) { - const result = await generateText({ - model: small.language, - maxOutputTokens: 100, - messages: [ - { - role: "user", - content: ` + let summary = messages + .findLast((m) => m.info.role === "assistant") + ?.parts.findLast((p) => p.type === "text")?.text + if (!summary || diffs.length > 0) { + const result = await generateText({ + model: small.language, + maxOutputTokens: 100, + messages: [ + { + role: "user", + content: ` Summarize the following conversation into 2 sentences MAX explaining what the assistant did and why. Do not explain the user's input. Do not speak in the third person about the assistant. <conversation> ${JSON.stringify(MessageV2.toModelMessage(messages))} </conversation> `, - }, - ], - }) - userMsg.summary.body = result.text - log.info("body", { body: result.text }) + }, + ], + }) + summary = result.text + } + userMsg.summary.body = summary + log.info("body", { body: summary }) await Session.updateMessage(userMsg) } } |
