fix : blocks not appearing on front for planner agent

This commit is contained in:
martin legrand
2025-04-24 12:22:52 +02:00
parent 812af254b5
commit 82aecd0aae
5 changed files with 42 additions and 19 deletions
+12 -2
View File
@@ -317,6 +317,8 @@ class BrowserAgent(Agent):
while not complete and len(unvisited) > 0:
self.memory.clear()
print("Debug history:", self.search_history)
unvisited = self.select_unvisited(search_result)
answer, reasoning = await self.llm_decide(prompt, show_reasoning = False)
self.last_answer = answer
pretty_print(''*32, color="status")
@@ -339,6 +341,11 @@ class BrowserAgent(Agent):
links = self.parse_answer(answer)
link = self.select_link(links)
if link == self.current_page:
pretty_print(f"Already visited {link}. Search callback.", color="status")
prompt = self.make_newsearch_prompt(user_prompt, unvisited)
self.search_history.append(link)
continue
if Action.REQUEST_EXIT.value in answer:
self.status_message = "Exiting web browser..."
@@ -349,7 +356,6 @@ class BrowserAgent(Agent):
if (link == None and len(extracted_form) < 3) or Action.GO_BACK.value in answer or link in self.search_history:
pretty_print(f"Going back to results. Still {len(unvisited)}", color="status")
self.status_message = "Going back to search results..."
unvisited = self.select_unvisited(search_result)
prompt = self.make_newsearch_prompt(user_prompt, unvisited)
self.search_history.append(link)
self.current_page = link
@@ -357,8 +363,12 @@ class BrowserAgent(Agent):
animate_thinking(f"Navigating to {link}", color="status")
if speech_module: speech_module.speak(f"Navigating to {link}")
self.browser.go_to(link)
nav_ok = self.browser.go_to(link)
self.search_history.append(link)
if not nav_ok:
pretty_print(f"Failed to navigate to {link}.", color="failure")
prompt = self.make_newsearch_prompt(user_prompt, unvisited)
continue
self.current_page = link
page_text = self.browser.get_text()
self.navigable_links = self.browser.get_navigable()