chore: remove verbose prints and add agent/memory tool registration in assistant core

This commit is contained in:
2025-11-04 04:57:23 +00:00
parent 5d42e8d377
commit e815e2e2a3
16 changed files with 787 additions and 55 deletions
+1 -19
View File
@@ -14,12 +14,9 @@ def run_autonomous_mode(assistant, task):
logger.debug(f"=== AUTONOMOUS MODE START ===")
logger.debug(f"Task: {task}")
if assistant.verbose:
print_autonomous_header(task)
assistant.messages.append({
"role": "user",
"content": f"AUTONOMOUS TASK: {task}\n\nPlease work on this task step by step. Use tools as needed. When the task is fully complete, clearly state 'Task complete'."
"content": f"{task}"
})
try:
@@ -29,17 +26,11 @@ def run_autonomous_mode(assistant, task):
logger.debug(f"--- Autonomous iteration {assistant.autonomous_iterations} ---")
logger.debug(f"Messages before context management: {len(assistant.messages)}")
if assistant.verbose:
print(f"\n{Colors.BOLD}{Colors.MAGENTA}{'' * 3} Iteration {assistant.autonomous_iterations} {'' * 3}{Colors.RESET}\n")
from pr.core.context import manage_context_window
assistant.messages = manage_context_window(assistant.messages, assistant.verbose)
logger.debug(f"Messages after context management: {len(assistant.messages)}")
if assistant.verbose:
print(f"{Colors.GRAY}Calling API...{Colors.RESET}")
from pr.core.api import call_api
from pr.tools.base import get_tools_definition
response = call_api(
@@ -67,9 +58,6 @@ def run_autonomous_mode(assistant, task):
logger.debug(f"=== AUTONOMOUS MODE COMPLETE ===")
logger.debug(f"Total iterations: {assistant.autonomous_iterations}")
logger.debug(f"Final message count: {len(assistant.messages)}")
print(f"{Colors.BOLD}Total Iterations:{Colors.RESET} {assistant.autonomous_iterations}")
print(f"{Colors.BOLD}Messages in Context:{Colors.RESET} {len(assistant.messages)}\n")
break
result = process_response_autonomous(assistant, response)
@@ -97,16 +85,12 @@ def process_response_autonomous(assistant, response):
assistant.messages.append(message)
if 'tool_calls' in message and message['tool_calls']:
print(f"{Colors.BOLD}{Colors.CYAN}🔧 Executing {len(message['tool_calls'])} tool(s)...{Colors.RESET}\n")
tool_results = []
for tool_call in message['tool_calls']:
func_name = tool_call['function']['name']
arguments = json.loads(tool_call['function']['arguments'])
display_tool_call(func_name, arguments, "running")
result = execute_single_tool(assistant, func_name, arguments)
result = truncate_tool_result(result)
@@ -121,8 +105,6 @@ def process_response_autonomous(assistant, response):
for result in tool_results:
assistant.messages.append(result)
print(f"{Colors.GRAY}Processing tool results...{Colors.RESET}\n")
from pr.core.api import call_api
from pr.tools.base import get_tools_definition
follow_up = call_api(