Skip to content

Commit 80dd10d

Browse files
authored
Revert "chore: prompt cache up to the third-to-last message in the conversati…" (RooCodeInc#2883)
This reverts commit 359f77c.
1 parent 109f0ec commit 80dd10d

File tree

3 files changed

+3
-14
lines changed

3 files changed

+3
-14
lines changed

.changeset/ten-wasps-compete.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/api/providers/anthropic.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,14 @@ export class AnthropicHandler implements ApiHandler {
3434
case "claude-3-opus-20240229":
3535
case "claude-3-haiku-20240307": {
3636
/*
37-
The latest message will be the new user message, one before will be the assistant message from a previous request, and the user message before that will be a previously cached user message. So we need to mark the latest user message as ephemeral to cache it for the next request, and mark the second and the third to last user message as ephemeral to let the server know the last message to retrieve from the cache for the current request..
37+
The latest message will be the new user message, one before will be the assistant message from a previous request, and the user message before that will be a previously cached user message. So we need to mark the latest user message as ephemeral to cache it for the next request, and mark the second to last user message as ephemeral to let the server know the last message to retrieve from the cache for the current request..
3838
*/
3939
const userMsgIndices = messages.reduce(
4040
(acc, msg, index) => (msg.role === "user" ? [...acc, index] : acc),
4141
[] as number[],
4242
)
4343
const lastUserMsgIndex = userMsgIndices[userMsgIndices.length - 1] ?? -1
4444
const secondLastMsgUserIndex = userMsgIndices[userMsgIndices.length - 2] ?? -1
45-
const thirdLastMsgUserIndex = userMsgIndices[userMsgIndices.length - 3] ?? -1
4645
stream = await this.client.messages.create(
4746
{
4847
model: modelId,
@@ -59,11 +58,7 @@ export class AnthropicHandler implements ApiHandler {
5958
},
6059
], // setting cache breakpoint for system prompt so new tasks can reuse it
6160
messages: messages.map((message, index) => {
62-
if (
63-
index === lastUserMsgIndex ||
64-
index === secondLastMsgUserIndex ||
65-
index === thirdLastMsgUserIndex
66-
) {
61+
if (index === lastUserMsgIndex || index === secondLastMsgUserIndex) {
6762
return {
6863
...message,
6964
content:

src/api/providers/bedrock.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ export class AwsBedrockHandler implements ApiHandler {
4747
const userMsgIndices = messages.reduce((acc, msg, index) => (msg.role === "user" ? [...acc, index] : acc), [] as number[])
4848
const lastUserMsgIndex = userMsgIndices[userMsgIndices.length - 1] ?? -1
4949
const secondLastMsgUserIndex = userMsgIndices[userMsgIndices.length - 2] ?? -1
50-
const thirdLastMsgUserIndex = userMsgIndices[userMsgIndices.length - 3] ?? -1
5150

5251
// Create anthropic client, using sessions created or renewed after this handler's
5352
// initialization, and allowing for session renewal if necessary as well
@@ -68,7 +67,7 @@ export class AwsBedrockHandler implements ApiHandler {
6867
},
6968
],
7069
messages: messages.map((message, index) => {
71-
if (index === lastUserMsgIndex || index === secondLastMsgUserIndex || index === thirdLastMsgUserIndex) {
70+
if (index === lastUserMsgIndex || index === secondLastMsgUserIndex) {
7271
return {
7372
...message,
7473
content:

0 commit comments

Comments
 (0)