Simplify structured output for research agents

This commit is contained in:
Yiorgis Gozadinos 2025-09-17 18:31:55 +03:00
parent 714c6c627e
commit a807f3ea36
No known key found for this signature in database
6 changed files with 13 additions and 12 deletions

View file

@ -122,12 +122,7 @@ class HaikuRAGApp:
self.console.print(f"{finding}")
self.console.print()
# Themes
if report.themes:
self.console.print("[bold cyan]Key Themes:[/bold cyan]")
for theme, explanation in report.themes.items():
self.console.print(f"• [bold]{theme}[/bold]: {explanation}")
self.console.print()
# (Themes section removed)
# Conclusions
if report.conclusions:
@ -261,7 +256,7 @@ class HaikuRAGApp:
elif transport == "sse":
await server.run_sse_async()
else:
await server.run_http_async("streamable-http")
await server.run_http_async(transport="streamable-http")
except KeyboardInterrupt:
pass
finally:

View file

@ -49,6 +49,9 @@ class QuestionAnswerAgent:
limit: int = 3,
) -> list[SearchResult]:
"""Search the knowledge base for relevant documents."""
# Remove quotes from queries as this requires positional indexing in lancedb
query = query.replace('"', "")
search_results = await ctx.deps.client.search(query, limit=limit)
expanded_results = await ctx.deps.client.expand_context(search_results)

View file

@ -11,7 +11,9 @@ class EvaluationResult(BaseModel):
description="Main insights extracted from the research so far"
)
new_questions: list[str] = Field(
description="New sub-questions to add to the research (max 3)", max_length=3
description="New sub-questions to add to the research (max 3)",
max_length=3,
default=[],
)
confidence_score: float = Field(
description="Confidence level in the completeness of research (0-1)",

View file

@ -42,6 +42,7 @@ class SearchSpecialistAgent(BaseResearchAgent[SearchAnswer]):
) -> str:
"""Search the KB and return a concise context pack."""
# Remove quotes from queries as this requires positional indexing in lancedb
# XXX: Investigate how to do that with lancedb
query = query.replace('"', "")
search_results = await ctx.deps.client.search(query, limit=limit)
expanded = await ctx.deps.client.expand_context(search_results)

View file

@ -12,11 +12,12 @@ class ResearchReport(BaseModel):
main_findings: list[str] = Field(
description="Primary research findings with supporting evidence"
)
themes: dict[str, str] = Field(description="Major themes and their explanations")
conclusions: list[str] = Field(description="Evidence-based conclusions")
limitations: list[str] = Field(description="Limitations of the current research")
limitations: list[str] = Field(
description="Limitations of the current research", default=[]
)
recommendations: list[str] = Field(
description="Actionable recommendations based on findings"
description="Actionable recommendations based on findings", default=[]
)
sources_summary: str = Field(
description="Summary of sources used and their reliability"

View file

@ -172,7 +172,6 @@ class TestResearchOrchestrator:
assert report.title
assert report.executive_summary
assert isinstance(report.main_findings, list)
assert isinstance(report.themes, dict)
assert isinstance(report.conclusions, list)
assert isinstance(report.limitations, list)
assert isinstance(report.recommendations, list)