Make answered question handling the responsibility of the search agent

This commit is contained in:
Yiorgis Gozadinos 2025-09-19 10:29:59 +03:00
parent ccaae7cca1
commit 9c128c1d36
No known key found for this signature in database
2 changed files with 4 additions and 20 deletions

View file

@ -165,7 +165,7 @@ class ResearchOrchestrator(BaseResearchAgent[ResearchPlan]):
break
# Use current sub-questions for this iteration
questions_to_search = context.sub_questions
questions_to_search = context.sub_questions[:]
# Search phase - answer all questions in this iteration
self._log(
@ -175,17 +175,8 @@ class ResearchOrchestrator(BaseResearchAgent[ResearchPlan]):
self._log(f" {i}. {q}")
# Run searches for all questions and remove answered ones
answered_questions = []
for search_question in questions_to_search:
try:
await self.search_agent.run(search_question, deps=deps)
except Exception as e: # pragma: no cover - defensive
self._log(
f"\n [red]×[/red] Omitting failed question: {search_question} ({e})"
)
finally:
answered_questions.append(search_question)
await self.search_agent.run(search_question, deps=deps)
if self._console and context.qa_responses:
# Show the last QA response (which should be for this question)
latest_qa = context.qa_responses[-1]
@ -197,11 +188,6 @@ class ResearchOrchestrator(BaseResearchAgent[ResearchPlan]):
self._log(f"\n [green]✓[/green] {search_question}")
self._log(f" {answer_preview}")
# Remove answered questions from the list
for question in answered_questions:
if question in context.sub_questions:
context.sub_questions.remove(question)
# Analysis and Evaluation phase
self._log(
"\n[bold cyan]📊 Analyzing and evaluating research progress...[/bold cyan]"

View file

@ -22,10 +22,8 @@ class SearchSpecialistAgent(BaseResearchAgent[SearchAnswer]):
the QA response with the last search results as sources.
"""
result = await super().run(prompt, deps, **kwargs)
if result.output:
deps.context.add_qa_response(result.output)
deps.context.add_qa_response(result.output)
deps.context.sub_questions.remove(prompt)
return result
def get_system_prompt(self) -> str: