diff --git a/python/valuecell/server/services/conversation_service.py b/python/valuecell/server/services/conversation_service.py index 0d51c69dd..0d18544a3 100644 --- a/python/valuecell/server/services/conversation_service.py +++ b/python/valuecell/server/services/conversation_service.py @@ -24,6 +24,14 @@ ) from valuecell.utils import resolve_db_path +# Agent names used by strategy creation flows; conversations from these agents +# should be excluded from the general conversation list returned to clients. +# Keep this set small and focused; extend if new strategy agents are added. +STRATEGY_AGENT_NAMES = { + "PromptBasedStrategyAgent", + "GridStrategyAgent", +} + class ConversationService: """Service for managing conversation operations.""" @@ -51,6 +59,20 @@ async def get_conversation_list( user_id=user_id ) + # Exclude conversations initiated by strategy agents from general listing. + # We match by known names and a conservative substring check to future-proof. + conversations = [ + conv + for conv in conversations + if not ( + (conv.agent_name or "") in STRATEGY_AGENT_NAMES + or ( + (conv.agent_name or "") + and "StrategyAgent" in (conv.agent_name or "") + ) + ) + ] + # Apply pagination total = len(conversations)