Skip to content

Building AI agents, atomically

Improve comments

KennyVaneetveldeea694e79dfe2
diff --git a/examples/memory_demo.py b/examples/memory_demo.py
index bb48aa8..0238012 100644
--- a/examples/memory_demo.py
+++ b/examples/memory_demo.py
@@ -16,7 +16,7 @@ memory = AgentMemory(max_messages=5)
console.print("[bold magenta]AgentMemory Test Cases[/bold magenta]", justify="center")
console.print()
-# Test Case 1
+# Test Case 1: Adding regular messages and displaying the current history
content = Text()
memory.add_message("user", "Hello, how are you?")
memory.add_message("assistant", "I'm doing well, thank you for asking!")
@@ -27,7 +27,7 @@ for msg in memory.get_history():
content.append(f"- {msg.role}: {msg.content}\n", style=f"{'green' if msg.role == 'user' else 'blue'}")
print_panel("1. Adding regular messages", content)
-# Test Case 2
+# Test Case 2: Adding a message with a tool call and displaying the last message
content = Text()
tool_message = {
"id": "weather_1",
@@ -42,7 +42,7 @@ content.append(f"- {last_msg.role}: {last_msg.content}\n", style="blue")
content.append(f" Tool call: {last_msg.tool_calls}\n", style="yellow")
print_panel("2. Adding a message with a tool call", content)
-# Test Case 3
+# Test Case 3: Adding a tool response and displaying the last message
content = Text()
memory.add_message("tool", "The weather in New York is sunny with a high of 75°F.", tool_id="weather_1")
content.append(f"Total messages: {memory.get_message_count()}\n\n")
@@ -52,7 +52,7 @@ content.append(f"- {last_msg.role}: {last_msg.content}\n", style="yellow")
content.append(f" Tool call ID: {last_msg.tool_call_id}\n", style="yellow")
print_panel("3. Adding a tool response", content)
-# Test Case 4
+# Test Case 4: Testing overflow management by adding more messages than the maximum allowed
content = Text()
memory.add_message("user", "Thanks for the weather info!")
content.append(f"Total messages: {memory.get_message_count()}\n\n")
@@ -61,7 +61,7 @@ for msg in memory.get_history():
content.append(f"- {msg.role}: {msg.content}\n", style=f"{'green' if msg.role == 'user' else 'blue' if msg.role == 'assistant' else 'yellow'}")
print_panel("4. Testing overflow management", content)
-# Test Case 5
+# Test Case 5: Testing dump and load functionality
content = Text()
dumped_data = memory.dump()
content.append("Dumped data:\n")
@@ -75,7 +75,7 @@ for msg in new_memory.get_history():
content.append(f"\nTotal messages in loaded memory: {new_memory.get_message_count()}")
print_panel("5. Testing dump and load", content)
-# Test Case 6
+# Test Case 6: Testing copy functionality
content = Text()
copied_memory = memory.copy()
content.append(f"Original memory message count: {memory.get_message_count()}\n")
@@ -86,7 +86,7 @@ content.append(f"Original memory message count: {memory.get_message_count()}\n")
content.append(f"Copied memory message count: {copied_memory.get_message_count()}")
print_panel("6. Testing copy", content)
-# Test Case 7
+# Test Case 7: Testing loading a larger buffer than max_messages
content = Text()
large_buffer = [
{"role": "user", "content": f"Message {i}"} for i in range(10)
@@ -99,7 +99,7 @@ for msg in large_memory.get_history():
content.append(f"- {msg.role}: {msg.content}\n", style="green")
print_panel("7. Testing loading a larger buffer than max_messages", content)
-# Test Case 8
+# Test Case 8: Testing adding messages with different content types
content = Text()
mixed_memory = AgentMemory(max_messages=10)
mixed_memory.add_message("user", "Hello")