fix: deduplicate identical messages in autonomous mode by tracking last_printed_result in run_autonomous_mode

This commit is contained in:
2025-11-09 03:12:27 +00:00
parent b1bfab5479
commit 8f70f93869
3 changed files with 25 additions and 3 deletions
+6 -2
View File
@@ -27,6 +27,7 @@ def sanitize_for_json(obj):
def run_autonomous_mode(assistant, task):
assistant.autonomous_mode = True
assistant.autonomous_iterations = 0
last_printed_result = None
logger.debug("=== AUTONOMOUS MODE START ===")
logger.debug(f"Task: {task}")
from rp.core.knowledge_context import inject_knowledge_context
@@ -60,14 +61,17 @@ def run_autonomous_mode(assistant, task):
logger.debug(f"Task completion check: {is_complete}")
if is_complete:
result = process_response_autonomous(assistant, response)
print(f"\n{Colors.GREEN}r:{Colors.RESET} {result}\n")
if result != last_printed_result:
print(f"\n{Colors.GREEN}r:{Colors.RESET} {result}\n")
last_printed_result = result
logger.debug(f"=== AUTONOMOUS MODE COMPLETE ===")
logger.debug(f"Total iterations: {assistant.autonomous_iterations}")
logger.debug(f"Final message count: {len(assistant.messages)}")
break
result = process_response_autonomous(assistant, response)
if result:
if result and result != last_printed_result:
print(f"\n{Colors.GREEN}r:{Colors.RESET} {result}\n")
last_printed_result = result
time.sleep(0.5)
except KeyboardInterrupt:
logger.debug("Autonomous mode interrupted by user")