New prompts/defaults for sliding_window and all compaction (#9444)
* new prompts for sliding window and all compaction + defaults to corresponding prompt * regenerate api spec --------- Co-authored-by: Amy Guan <amy@letta.com>
This commit is contained in:
@@ -30108,10 +30108,16 @@
|
||||
"description": "Optional model settings used to override defaults for the summarizer model."
|
||||
},
|
||||
"prompt": {
|
||||
"type": "string",
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"title": "Prompt",
|
||||
"description": "The prompt to use for summarization.",
|
||||
"default": "The following messages are being evicted from your context window. Write a detailed summary that captures what happened in these messages.\n\nThis summary will appear BEFORE the remaining recent messages in context, providing background for what comes after. Include:\n\n1. **What happened**: The conversations, tasks, and exchanges that took place. What did the user ask for? What did you do? How did things progress?\n\n2. **High level goals**: If there is an existing summary in the transcript, make sure to take it into consideration to continue tracking the higher level goals and long-term progress. Make sure to not lose track of higher level goals or the ongoing task.\n\n3. **Important details**: Specific names, data, configurations, or facts that were discussed. Don't omit details that might be referenced later.\n\n4. **Lookup hints**: For any detailed content (long lists, extensive data, specific conversations) that couldn't fit in the summary, note the topic and key terms that could be used to find it in message history later.\n\nWrite in first person as a factual record of what occurred. Be thorough and detailed - the goal is to preserve enough context that the recent messages make sense and important information isn't lost.\n\nKeep your summary under 250 words. Only output the summary."
|
||||
"description": "The prompt to use for summarization. If None, uses mode-specific default."
|
||||
},
|
||||
"prompt_acknowledgement": {
|
||||
"type": "boolean",
|
||||
@@ -30228,10 +30234,16 @@
|
||||
"description": "Optional model settings used to override defaults for the summarizer model."
|
||||
},
|
||||
"prompt": {
|
||||
"type": "string",
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"title": "Prompt",
|
||||
"description": "The prompt to use for summarization.",
|
||||
"default": "The following messages are being evicted from your context window. Write a detailed summary that captures what happened in these messages.\n\nThis summary will appear BEFORE the remaining recent messages in context, providing background for what comes after. Include:\n\n1. **What happened**: The conversations, tasks, and exchanges that took place. What did the user ask for? What did you do? How did things progress?\n\n2. **High level goals**: If there is an existing summary in the transcript, make sure to take it into consideration to continue tracking the higher level goals and long-term progress. Make sure to not lose track of higher level goals or the ongoing task.\n\n3. **Important details**: Specific names, data, configurations, or facts that were discussed. Don't omit details that might be referenced later.\n\n4. **Lookup hints**: For any detailed content (long lists, extensive data, specific conversations) that couldn't fit in the summary, note the topic and key terms that could be used to find it in message history later.\n\nWrite in first person as a factual record of what occurred. Be thorough and detailed - the goal is to preserve enough context that the recent messages make sense and important information isn't lost.\n\nKeep your summary under 250 words. Only output the summary."
|
||||
"description": "The prompt to use for summarization. If None, uses mode-specific default."
|
||||
},
|
||||
"prompt_acknowledgement": {
|
||||
"type": "boolean",
|
||||
|
||||
@@ -1,3 +1,43 @@
|
||||
ALL_WORD_LIMIT = 500
|
||||
SLIDING_WORD_LIMIT = 300
|
||||
|
||||
ALL_PROMPT = f"""Your task is to create a detailed summary of the conversation so far, paying close attention to the user's explicit requests and your previous actions.
|
||||
This summary should be thorough in capturing technical details, code patterns, and architectural decisions that would be essential for continuing development work without losing context. Your summary should include the following sections:
|
||||
|
||||
1.**High level goals**: What is the high level goal and ongoing task? Capture the user's explicit requests and intent in detail. If there is an existing summary in the transcript, make sure to take it into consideration to continue tracking the higher level goals and long-term progress.
|
||||
|
||||
2. **What happened**: The conversations, tasks, and exchanges that took place. What did the user ask for? What did you do? How did things progress? If there is a previous summary being evicted, please extract a concise version of the critical info from it.
|
||||
|
||||
3. **Important details**: Enumerate specific files and code sections examined, modified, or created with a summary of why this file read or edit is important. Include specific names, data, configurations, or facts that were discussed. Don't omit details that might be referenced later.
|
||||
|
||||
4. **Errors and fixes**: List all errors that you ran into, and how you fixed them. Pay special attention to specific user feedback that you received and record verbatim if useful.
|
||||
|
||||
5. **Current state**:Describe in detail precisely what is currently being worked on, paying special attention to the most recent messages from both user and assistant. Include file names and code snippets where applicable.
|
||||
|
||||
6.**Optional Next Step**: List the next step that you will take that is related to the most recent work you were doing. IMPORTANT: ensure that this step is DIRECTLY in line with the user's most recent explicit requests and the most current task. If your last task was concluded, then only list next steps if they are explicitly in line with the users request. If there is a next step, include direct quotes from the most recent conversation showing exactly what task you were working on and where you left off.
|
||||
|
||||
7. **Lookup hints**: For any detailed content (long lists, extensive data, specific conversations) that couldn't fit in the summary, note the topic and key terms that could be used to find it in message history later.
|
||||
|
||||
Write in first person as a factual record of what occurred. Be concise but thorough - the goal is to preserve enough context that the recent messages make sense and important information isn't lost to prevent duplicate work or repeated mistakes.
|
||||
|
||||
Keep your summary under {ALL_WORD_LIMIT} words. Only output the summary."""
|
||||
|
||||
SLIDING_PROMPT = f"""The following messages are being evicted from the BEGINNING of your context window. Write a detailed summary that captures what happened in these messages to appear BEFORE the remaining recent messages in context, providing background for what comes after. Include the following sections:
|
||||
|
||||
1.**High level goals**: What is the high level goal and ongoing task? Capture the user's explicit requests and intent in detail. If there is an existing summary in the transcript, make sure to take it into consideration to continue tracking the higher level goals and long-term progress.
|
||||
|
||||
2. **What happened**: The conversations, tasks, and exchanges that took place. What did the user ask for? What did you do? How did things progress? If there is a previous summary being evicted, please extract a concise version of the critical info from it.
|
||||
|
||||
3. **Important details**: Enumerate specific files and code sections examined, modified, or created with a summary of why this file read or edit is important. Include specific names, data, configurations, or facts that were discussed. Don't omit details that might be referenced later.
|
||||
|
||||
4. **Errors and fixes**: List all errors that you ran into, and how you fixed them. Pay special attention to specific user feedback that you received and record verbatim if useful.
|
||||
|
||||
5. **Lookup hints**: For any detailed content (long lists, extensive data, specific conversations) that couldn't fit in the summary, note the topic and key terms that could be used to find it in message history later.
|
||||
|
||||
Write in first person as a factual record of what occurred. Be thorough and detailed - the goal is to preserve enough context that the recent messages make sense and important information isn't lost to prevent duplicate work or repeated mistakes.
|
||||
|
||||
Keep your summary under {SLIDING_WORD_LIMIT} words. Only output the summary."""
|
||||
|
||||
ANTHROPIC_SUMMARY_PROMPT = """You have been working on the task described above but have not yet completed it. Write a continuation summary that will allow you (or another instance of yourself) to resume work efficiently in a future context window where the conversation history will be replaced with this summary. Your summary should be structured, concise, and actionable. Include:
|
||||
|
||||
1. Task Overview
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from typing import Literal
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
from pydantic import BaseModel, Field, model_validator
|
||||
|
||||
from letta.prompts.summarizer_prompt import ANTHROPIC_SUMMARY_PROMPT, SHORTER_SUMMARY_PROMPT
|
||||
from letta.prompts.summarizer_prompt import ALL_PROMPT, SLIDING_PROMPT
|
||||
from letta.schemas.model import ModelSettingsUnion
|
||||
from letta.settings import summarizer_settings
|
||||
|
||||
@@ -28,7 +28,7 @@ class CompactionSettings(BaseModel):
|
||||
description="Optional model settings used to override defaults for the summarizer model.",
|
||||
)
|
||||
|
||||
prompt: str = Field(default=SHORTER_SUMMARY_PROMPT, description="The prompt to use for summarization.")
|
||||
prompt: str | None = Field(default=None, description="The prompt to use for summarization. If None, uses mode-specific default.")
|
||||
prompt_acknowledgement: bool = Field(
|
||||
default=False, description="Whether to include an acknowledgement post-prompt (helps prevent non-summary outputs)."
|
||||
)
|
||||
@@ -41,3 +41,13 @@ class CompactionSettings(BaseModel):
|
||||
default_factory=lambda: summarizer_settings.partial_evict_summarizer_percentage,
|
||||
description="The percentage of the context window to keep post-summarization (only used in sliding window mode).",
|
||||
)
|
||||
|
||||
@model_validator(mode="after")
|
||||
def set_mode_specific_prompt(self):
|
||||
"""Set mode-specific default prompt if none provided."""
|
||||
if self.prompt is None:
|
||||
if self.mode == "all":
|
||||
self.prompt = ALL_PROMPT
|
||||
else: # sliding_window
|
||||
self.prompt = SLIDING_PROMPT
|
||||
return self
|
||||
|
||||
Reference in New Issue
Block a user