mirror of
https://github.com/aljazceru/opencode.git
synced 2026-01-02 15:35:01 +01:00
only generate user message summary if no diffs
This commit is contained in:
@@ -98,23 +98,29 @@ export namespace SessionSummary {
|
|||||||
m.parts.some((p) => p.type === "step-finish" && p.reason !== "tool-calls"),
|
m.parts.some((p) => p.type === "step-finish" && p.reason !== "tool-calls"),
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
const result = await generateText({
|
let summary = messages
|
||||||
model: small.language,
|
.findLast((m) => m.info.role === "assistant")
|
||||||
maxOutputTokens: 100,
|
?.parts.findLast((p) => p.type === "text")?.text
|
||||||
messages: [
|
if (!summary || diffs.length > 0) {
|
||||||
{
|
const result = await generateText({
|
||||||
role: "user",
|
model: small.language,
|
||||||
content: `
|
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.
|
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>
|
<conversation>
|
||||||
${JSON.stringify(MessageV2.toModelMessage(messages))}
|
${JSON.stringify(MessageV2.toModelMessage(messages))}
|
||||||
</conversation>
|
</conversation>
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
userMsg.summary.body = result.text
|
summary = result.text
|
||||||
log.info("body", { body: result.text })
|
}
|
||||||
|
userMsg.summary.body = summary
|
||||||
|
log.info("body", { body: summary })
|
||||||
await Session.updateMessage(userMsg)
|
await Session.updateMessage(userMsg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user