diff --git a/nova/core/memory.py b/nova/core/memory.py index d04d457..021a599 100644 --- a/nova/core/memory.py +++ b/nova/core/memory.py @@ -157,10 +157,10 @@ def analyze_message_importance( # Boost importance for longer messages (more detailed) word_count = len(message.content.split()) - if word_count > 50: - importance_score += 0.2 - elif word_count > 100: + if word_count > 100: importance_score += 0.4 + elif word_count > 50: + importance_score += 0.2 # Boost importance for messages with code or technical content if any( diff --git a/tests/unit/test_memory.py b/tests/unit/test_memory.py index b5508fe..79786e0 100644 --- a/tests/unit/test_memory.py +++ b/tests/unit/test_memory.py @@ -127,6 +127,26 @@ def test_analyze_message_importance_recent(self): ) assert score > 1.0 # Base score + recency boost + def test_analyze_message_importance_long_message(self): + """Longer messages should yield higher importance scores""" + medium_msg = Message( + role=MessageRole.USER, + content=" ".join(["word"] * 60), # 60 words + ) + long_msg = Message( + role=MessageRole.USER, + content=" ".join(["word"] * 120), # 120 words + ) + + medium_score = self.memory_manager.analyze_message_importance( + medium_msg, self.conversation + ) + long_score = self.memory_manager.analyze_message_importance( + long_msg, self.conversation + ) + + assert long_score > medium_score + def test_optimize_conversation_context(self): """Test context optimization""" result = self.memory_manager.optimize_conversation_context(self.conversation)