mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-10-07 02:58:15 +00:00
* fix: include initial ask in condense summarization (#8293) --------- Co-authored-by: Matt Rubens <mrubens@users.noreply.github.com>
This commit is contained in:
parent
d3d0967fc3
commit
2f1b94f430
2 changed files with 28 additions and 2 deletions
|
|
@ -283,6 +283,32 @@ describe("summarizeConversation", () => {
|
|||
const mockCallArgs = (maybeRemoveImageBlocks as Mock).mock.calls[0][0] as any[]
|
||||
expect(mockCallArgs[mockCallArgs.length - 1]).toEqual(expectedFinalMessage)
|
||||
})
|
||||
it("should include the original first user message in summarization input", async () => {
|
||||
const messages: ApiMessage[] = [
|
||||
{ role: "user", content: "Initial ask", ts: 1 },
|
||||
{ role: "assistant", content: "Ack", ts: 2 },
|
||||
{ role: "user", content: "Follow-up", ts: 3 },
|
||||
{ role: "assistant", content: "Response", ts: 4 },
|
||||
{ role: "user", content: "More", ts: 5 },
|
||||
{ role: "assistant", content: "Later", ts: 6 },
|
||||
{ role: "user", content: "Newest", ts: 7 },
|
||||
]
|
||||
|
||||
await summarizeConversation(messages, mockApiHandler, defaultSystemPrompt, taskId, DEFAULT_PREV_CONTEXT_TOKENS)
|
||||
|
||||
const mockCallArgs = (maybeRemoveImageBlocks as Mock).mock.calls[0][0] as any[]
|
||||
|
||||
// Expect the original first user message to be present in the messages sent to the summarizer
|
||||
const hasInitialAsk = mockCallArgs.some(
|
||||
(m) =>
|
||||
m.role === "user" &&
|
||||
(typeof m.content === "string"
|
||||
? m.content === "Initial ask"
|
||||
: Array.isArray(m.content) &&
|
||||
m.content.some((b: any) => b.type === "text" && b.text === "Initial ask")),
|
||||
)
|
||||
expect(hasInitialAsk).toBe(true)
|
||||
})
|
||||
|
||||
it("should calculate newContextTokens correctly with systemPrompt", async () => {
|
||||
const messages: ApiMessage[] = [
|
||||
|
|
|
|||
|
|
@ -103,8 +103,8 @@ export async function summarizeConversation(
|
|||
|
||||
// Always preserve the first message (which may contain slash command content)
|
||||
const firstMessage = messages[0]
|
||||
// Get messages to summarize, excluding the first message and last N messages
|
||||
const messagesToSummarize = getMessagesSinceLastSummary(messages.slice(1, -N_MESSAGES_TO_KEEP))
|
||||
// Get messages to summarize, including the first message and excluding the last N messages
|
||||
const messagesToSummarize = getMessagesSinceLastSummary(messages.slice(0, -N_MESSAGES_TO_KEEP))
|
||||
|
||||
if (messagesToSummarize.length <= 1) {
|
||||
const error =
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue