Fix conversation history duplication and optimize file embedding
This major refactoring addresses critical bugs in conversation history management and significantly improves token efficiency through intelligent file embedding: **Key Improvements:** • Fixed conversation history duplication bug by centralizing reconstruction in server.py • Added intelligent file filtering to prevent re-embedding files already in conversation history • Centralized file processing logic in BaseTool._prepare_file_content_for_prompt() • Enhanced log monitoring with better categorization and file embedding visibility • Updated comprehensive test suite to verify new architecture and edge cases **Architecture Changes:** • Removed duplicate conversation history reconstruction from tools/base.py • Conversation history now handled exclusively by server.py:reconstruct_thread_context • All tools now use centralized file processing with automatic deduplication • Improved token efficiency by embedding unique files only once per conversation **Performance Benefits:** • Reduced token usage through smart file filtering • Eliminated redundant file embeddings in continued conversations • Better observability with detailed debug logging for file operations 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -73,6 +73,14 @@ def monitor_mcp_activity():
|
||||
print(f"[{datetime.now().strftime('%H:%M:%S')}] ❌ {line}")
|
||||
elif "WARNING" in line:
|
||||
print(f"[{datetime.now().strftime('%H:%M:%S')}] ⚠️ {line}")
|
||||
elif "DEBUG" in line:
|
||||
# Highlight file embedding debug logs
|
||||
if "📄" in line or "📁" in line:
|
||||
print(f"[{datetime.now().strftime('%H:%M:%S')}] 📂 FILE: {line}")
|
||||
else:
|
||||
print(f"[{datetime.now().strftime('%H:%M:%S')}] 🔍 {line}")
|
||||
elif "INFO" in line and ("Gemini API" in line or "Tool" in line or "Conversation" in line):
|
||||
print(f"[{datetime.now().strftime('%H:%M:%S')}] ℹ️ {line}")
|
||||
elif "Gemini API" in line and ("Sending" in line or "Received" in line):
|
||||
print(f"[{datetime.now().strftime('%H:%M:%S')}] API: {line}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user