From 6e621ea34daccfe9f51532cd5bc5869380122b5b Mon Sep 17 00:00:00 2001 From: Yiorgis Gozadinos Date: Mon, 15 Dec 2025 13:22:51 +0200 Subject: [PATCH] Provide full report on deep ask, modify prompt to not just summarize --- haiku_rag_slim/haiku/rag/app.py | 42 +++++++++++++------ .../haiku/rag/graph/research/prompts.py | 12 ++++-- 2 files changed, 38 insertions(+), 16 deletions(-) diff --git a/haiku_rag_slim/haiku/rag/app.py b/haiku_rag_slim/haiku/rag/app.py index c04cdbdf..7f216fd0 100644 --- a/haiku_rag_slim/haiku/rag/app.py +++ b/haiku_rag_slim/haiku/rag/app.py @@ -329,6 +329,8 @@ class HaikuRAGApp: try: citations = [] if deep: + from haiku.rag.graph.research.models import ResearchReport + graph = build_research_graph(config=self.config) context = ResearchContext(original_question=question) state = ResearchState.from_config( @@ -345,24 +347,40 @@ class HaikuRAGApp: result_dict = await renderer.render( stream_graph(graph, state, deps) ) - answer = ( - result_dict.get("executive_summary", "") + report = ( + ResearchReport.model_validate(result_dict) if result_dict - else "" + else None ) else: - result = await graph.run(state=state, deps=deps) - answer = result.executive_summary + report = await graph.run(state=state, deps=deps) + + self.console.print(f"[bold blue]Question:[/bold blue] {question}") + self.console.print() + if report: + self.console.print("[bold green]Answer:[/bold green]") + self.console.print(Markdown(report.executive_summary)) + if report.main_findings: + self.console.print() + self.console.print("[bold cyan]Key Findings:[/bold cyan]") + for finding in report.main_findings: + self.console.print(f"• {finding}") + if report.sources_summary: + self.console.print() + self.console.print("[bold cyan]Sources:[/bold cyan]") + self.console.print(report.sources_summary) + else: + self.console.print("[yellow]No answer generated.[/yellow]") else: answer, citations = await self.client.ask(question, filter=filter) - self.console.print(f"[bold blue]Question:[/bold blue] {question}") - self.console.print() - self.console.print("[bold green]Answer:[/bold green]") - self.console.print(Markdown(answer)) - if cite and citations: - for renderable in format_citations_rich(citations): - self.console.print(renderable) + self.console.print(f"[bold blue]Question:[/bold blue] {question}") + self.console.print() + self.console.print("[bold green]Answer:[/bold green]") + self.console.print(Markdown(answer)) + if cite and citations: + for renderable in format_citations_rich(citations): + self.console.print(renderable) except Exception as e: self.console.print(f"[red]Error: {e}[/red]") diff --git a/haiku_rag_slim/haiku/rag/graph/research/prompts.py b/haiku_rag_slim/haiku/rag/graph/research/prompts.py index d3b8aec4..f91a3bbf 100644 --- a/haiku_rag_slim/haiku/rag/graph/research/prompts.py +++ b/haiku_rag_slim/haiku/rag/graph/research/prompts.py @@ -20,17 +20,20 @@ Output fields: Be strict: only mark sufficient when key aspects are addressed with reliable evidence.""" SYNTHESIS_AGENT_PROMPT = """You are a synthesis specialist producing the final -research report. +research report that directly answers the original question. Goals: -1. Synthesize all gathered information into a coherent narrative. +1. Directly answer the research question using gathered evidence. 2. Present findings clearly and concisely. 3. Draw evidence-based conclusions and recommendations. 4. State limitations and uncertainties transparently. Report guidelines (map to output fields): - title: concise (5-12 words), informative. -- executive_summary: 3-5 sentences summarizing the overall answer. +- executive_summary: 3-5 sentences that DIRECTLY ANSWER the original question. + Write the actual answer, not a description of what the report contains. + BAD: "This report examines the topic and presents findings..." + GOOD: "The system requires configuration X and supports features Y and Z..." - main_findings: list of plain strings, 4-8 one-sentence bullets reflecting evidence. - conclusions: list of plain strings, 2-4 bullets following logically from findings. - recommendations: list of plain strings, 2-5 actionable bullets tied to findings. @@ -42,7 +45,8 @@ All list fields must contain plain strings only, not objects. Style: - Base all content solely on the collected evidence. - Be professional, objective, and specific. -- Avoid meta commentary and refrain from speculation beyond the evidence.""" +- NEVER use meta-commentary like "This report covers..." or "The findings show...". + Instead, state the actual information directly.""" PRESEARCH_AGENT_PROMPT = """You are a rapid research surveyor.