-
Notifications
You must be signed in to change notification settings - Fork 6
Open
0 / 10 of 1 issue completedOpen
0 / 10 of 1 issue completed
Copy link
Description
CodeRabbit
Add limits to context collection to prevent excessive prompt sizes
When collecting context blocks from conversation history, there's no limit on the number of blocks included. This could lead to excessively large prompts that exceed model token limits.
const contextBlocks = interactionsToScan
.flatMap((inter) =>
typeof inter.response === "string"
? this.parseMarkdownForCodeBlocks(inter.response)
: []
)
.filter((block) => block.code !== originalContent);
+
+ // Limit context to prevent excessive prompt sizes
+ const MAX_CONTEXT_BLOCKS = 5;
+ const limitedContextBlocks = contextBlocks.slice(-MAX_CONTEXT_BLOCKS);
+
- if (contextBlocks.length > 0) {
+ if (limitedContextBlocks.length > 0) {
contextPrompt = `\n\nFor context, here are other code blocks from the ${
mode.includes("conversation") ? "conversation" : "message"
- }:\n\n${contextBlocks
+ }:\n\n${limitedContextBlocks
.map((b) => `\`\`\`${b.lang || ""}\n${b.code}\n\`\`\``)
.join("\n\n")}`;
}why hardcode then...
guess imma have to add another setting
"ooohh yeah, i am going to give all the knobs it will be great" he said... 😢
Reactions are currently unavailable