@@ -5,7 +5,6 @@ import { describe, expect, it, jest, beforeEach } from "@jest/globals"
55import { TelemetryService } from "@roo-code/telemetry"
66
77import { ApiHandler } from "../../../api"
8- import { AwsBedrockHandler } from "../../../api/providers"
98import { ApiMessage } from "../../task-persistence/apiMessages"
109import { maybeRemoveImageBlocks } from "../../../api/transform/image-cleaning"
1110import { summarizeConversation , getMessagesSinceLastSummary , N_MESSAGES_TO_KEEP } from "../index"
@@ -26,20 +25,14 @@ const taskId = "test-task-id"
2625const DEFAULT_PREV_CONTEXT_TOKENS = 1000
2726
2827describe ( "getMessagesSinceLastSummary" , ( ) => {
29- let mockApiHandler : ApiHandler
30-
31- beforeEach ( ( ) => {
32- mockApiHandler = { } as unknown as ApiHandler
33- } )
34-
3528 it ( "should return all messages when there is no summary" , ( ) => {
3629 const messages : ApiMessage [ ] = [
3730 { role : "user" , content : "Hello" , ts : 1 } ,
3831 { role : "assistant" , content : "Hi there" , ts : 2 } ,
3932 { role : "user" , content : "How are you?" , ts : 3 } ,
4033 ]
4134
42- const result = getMessagesSinceLastSummary ( messages , mockApiHandler )
35+ const result = getMessagesSinceLastSummary ( messages )
4336 expect ( result ) . toEqual ( messages )
4437 } )
4538
@@ -52,7 +45,7 @@ describe("getMessagesSinceLastSummary", () => {
5245 { role : "assistant" , content : "I'm good" , ts : 5 } ,
5346 ]
5447
55- const result = getMessagesSinceLastSummary ( messages , mockApiHandler )
48+ const result = getMessagesSinceLastSummary ( messages )
5649 expect ( result ) . toEqual ( [
5750 { role : "assistant" , content : "Summary of conversation" , ts : 3 , isSummary : true } ,
5851 { role : "user" , content : "How are you?" , ts : 4 } ,
@@ -69,63 +62,17 @@ describe("getMessagesSinceLastSummary", () => {
6962 { role : "user" , content : "What's new?" , ts : 5 } ,
7063 ]
7164
72- const result = getMessagesSinceLastSummary ( messages , mockApiHandler )
65+ const result = getMessagesSinceLastSummary ( messages )
7366 expect ( result ) . toEqual ( [
7467 { role : "assistant" , content : "Second summary" , ts : 4 , isSummary : true } ,
7568 { role : "user" , content : "What's new?" , ts : 5 } ,
7669 ] )
7770 } )
7871
7972 it ( "should handle empty messages array" , ( ) => {
80- const result = getMessagesSinceLastSummary ( [ ] , mockApiHandler )
73+ const result = getMessagesSinceLastSummary ( [ ] )
8174 expect ( result ) . toEqual ( [ ] )
8275 } )
83-
84- it ( "should prepend user message when using AwsBedrockHandler with summary as first message" , ( ) => {
85- const mockAwsBedrockHandler = new AwsBedrockHandler ( {
86- apiModelId : "anthropic.claude-3-5-sonnet-20241022-v2:0" ,
87- awsAccessKey : "test-key" ,
88- awsSecretKey : "test-secret" ,
89- awsRegion : "us-east-1" ,
90- } )
91-
92- const messages : ApiMessage [ ] = [
93- { role : "user" , content : "Hello" , ts : 1 } ,
94- { role : "assistant" , content : "Hi there" , ts : 2 } ,
95- { role : "assistant" , content : "Summary of conversation" , ts : 1000 , isSummary : true } ,
96- { role : "user" , content : "How are you?" , ts : 1001 } ,
97- { role : "assistant" , content : "I'm good" , ts : 1002 } ,
98- ]
99-
100- const result = getMessagesSinceLastSummary ( messages , mockAwsBedrockHandler )
101-
102- // Should prepend user message before the summary
103- expect ( result ) . toEqual ( [
104- { role : "user" , content : "Please continue from the following summary:" , ts : 999 } ,
105- { role : "assistant" , content : "Summary of conversation" , ts : 1000 , isSummary : true } ,
106- { role : "user" , content : "How are you?" , ts : 1001 } ,
107- { role : "assistant" , content : "I'm good" , ts : 1002 } ,
108- ] )
109- } )
110-
111- it ( "should not prepend user message when using non-AwsBedrockHandler" , ( ) => {
112- const messages : ApiMessage [ ] = [
113- { role : "user" , content : "Hello" , ts : 1 } ,
114- { role : "assistant" , content : "Hi there" , ts : 2 } ,
115- { role : "assistant" , content : "Summary of conversation" , ts : 1000 , isSummary : true } ,
116- { role : "user" , content : "How are you?" , ts : 1001 } ,
117- { role : "assistant" , content : "I'm good" , ts : 1002 } ,
118- ]
119-
120- const result = getMessagesSinceLastSummary ( messages , mockApiHandler )
121-
122- // Should not prepend user message for non-AwsBedrockHandler
123- expect ( result ) . toEqual ( [
124- { role : "assistant" , content : "Summary of conversation" , ts : 1000 , isSummary : true } ,
125- { role : "user" , content : "How are you?" , ts : 1001 } ,
126- { role : "assistant" , content : "I'm good" , ts : 1002 } ,
127- ] )
128- } )
12976} )
13077
13178describe ( "summarizeConversation" , ( ) => {
0 commit comments