Skip to content

Commit 1e816ed

Browse files
authored
feat: summarize when tokenlimit exceeded or threshold reached(#3227)
1 parent 98541d9 commit 1e816ed

File tree

11 files changed

+1090
-603
lines changed

11 files changed

+1090
-603
lines changed

camel/agents/_utils.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,44 @@
2525
logger = logging.getLogger(__name__)
2626

2727

28+
def build_default_summary_prompt(conversation_text: str) -> str:
29+
r"""Create the default prompt used for conversation summarization.
30+
31+
Args:
32+
conversation_text (str): The conversation to be summarized.
33+
34+
Returns:
35+
str: A formatted prompt instructing the model to produce a structured
36+
markdown summary.
37+
"""
38+
template = textwrap.dedent(
39+
"""\
40+
Summarize the conversation below.
41+
Produce markdown that strictly follows this outline and numbering:
42+
43+
Summary:
44+
1. **Primary Request and Intent**:
45+
2. **Key Concepts**:
46+
3. **Errors and Fixes**:
47+
4. **Problem Solving**:
48+
5. **Pending Tasks**:
49+
6. **Current Work**:
50+
7. **Optional Next Step**:
51+
52+
Requirements:
53+
- Use bullet lists under each section (`- item`). If a section has no
54+
information, output `- None noted`.
55+
- Keep the ordering, headings, and formatting as written above.
56+
- Focus on concrete actions, findings, and decisions.
57+
- Do not invent details that are not supported by the conversation.
58+
59+
Conversation:
60+
{conversation_text}
61+
"""
62+
)
63+
return template.format(conversation_text=conversation_text)
64+
65+
2866
def generate_tool_prompt(tool_schema_list: List[Dict[str, Any]]) -> str:
2967
r"""Generates a tool prompt based on the provided tool schema list.
3068

0 commit comments

Comments
 (0)