Improve prompt for sequential calling, show markdown where appropriate
This commit is contained in:
parent
447277015b
commit
a3a26056ff
2 changed files with 39 additions and 35 deletions
|
|
@ -73,35 +73,32 @@ def create_agent(
|
||||||
deps_type=ResearchDeps,
|
deps_type=ResearchDeps,
|
||||||
instructions="""You are a research co-pilot powered by haiku.rag.
|
instructions="""You are a research co-pilot powered by haiku.rag.
|
||||||
|
|
||||||
You work step-by-step with the user to conduct deep research on complex questions.
|
|
||||||
|
|
||||||
Your workflow:
|
Your workflow:
|
||||||
1. When user asks a question, propose a research plan (exactly 3 sub-questions)
|
1. When user asks a question, IMMEDIATELY call propose_research_plan with the question
|
||||||
2. Wait for user approval before proceeding to the search phase
|
2. Wait for user approval before proceeding
|
||||||
3. Once approved, AUTOMATICALLY process ALL sub-questions IN ORDER (0, 1, 2, etc.) WITHOUT pausing:
|
3. Once approved, process questions ONE AT A TIME:
|
||||||
- For each sub-question:
|
- Call search_question(question_id=0) and WAIT for it to complete
|
||||||
* Announce what you're searching for
|
- Then call extract_insights_from_results(question_id=0) and WAIT for it to complete
|
||||||
* Execute search_question for that question ID
|
- Then call search_question(question_id=1) and WAIT for it to complete
|
||||||
* IMMEDIATELY extract insights using extract_insights_from_results with the SAME question ID
|
- Then call extract_insights_from_results(question_id=1) and WAIT for it to complete
|
||||||
- Continue automatically to the next question until all are complete
|
- Then call search_question(question_id=2) and WAIT for it to complete
|
||||||
4. After all questions are searched, evaluate overall confidence in your findings
|
- Then call extract_insights_from_results(question_id=2) and WAIT for it to complete
|
||||||
5. Ask user if confident enough or should search more
|
4. After all questions are processed, call evaluate_research_confidence
|
||||||
6. Synthesize final report with complete citations
|
5. Ask user if they want to finalize or continue researching
|
||||||
|
6. When user approves, call synthesize_final_report
|
||||||
|
|
||||||
CRITICAL RULES:
|
CRITICAL RULES:
|
||||||
- ALWAYS call search_question BEFORE extract_insights_from_results for each question
|
- Call ONE tool at a time - wait for each tool to return before calling the next
|
||||||
- Process questions in sequence: search Q0 → extract Q0 → search Q1 → extract Q1, etc.
|
- NEVER call extract_insights_from_results until search_question has completed and returned results
|
||||||
- NEVER skip ahead to extract insights for a question you haven't searched yet
|
- DO NOT explain what you're about to do - just call the tool
|
||||||
- In the search phase, DO NOT pause between questions - process all questions automatically
|
- DO NOT say "I'll search for..." or "Let me search..." - just call search_question
|
||||||
|
- The state updates will show the user what's happening - you don't need to narrate
|
||||||
|
- Process all 3 questions automatically without asking for approval between them
|
||||||
|
|
||||||
Document Viewing:
|
Document Viewing:
|
||||||
- Users can request to view the full content of any cited document
|
- When user asks to "show document X", call get_full_document with the document_uri
|
||||||
- When a user asks to "show document X" or "view source Y", use the get_full_document tool
|
|
||||||
- Document URIs are tracked automatically as you search
|
|
||||||
- The final report includes structured citations linking back to source documents
|
|
||||||
|
|
||||||
Be transparent: always announce what you're searching for, but don't wait for approval during the search phase.
|
Remember: Call tools ONE AT A TIME in sequence. Each tool must complete before calling the next.
|
||||||
Show search scores, explain your reasoning, cite your sources, and involve the user in decisions about confidence and next steps.
|
|
||||||
""",
|
""",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
|
import { Markdown } from "@copilotkit/react-ui";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
interface SourceRef {
|
interface SourceRef {
|
||||||
|
|
@ -413,7 +414,7 @@ export default function StateDisplay({ state }: StateDisplayProps) {
|
||||||
color: "#4a5568",
|
color: "#4a5568",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{item.question}
|
<Markdown content={item.question} />
|
||||||
</div>
|
</div>
|
||||||
{item.search_results && (
|
{item.search_results && (
|
||||||
<div
|
<div
|
||||||
|
|
@ -522,7 +523,7 @@ export default function StateDisplay({ state }: StateDisplayProps) {
|
||||||
lineHeight: "1.4",
|
lineHeight: "1.4",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{result.chunk}...
|
<Markdown content={`${result.chunk}...`} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|
@ -622,7 +623,7 @@ export default function StateDisplay({ state }: StateDisplayProps) {
|
||||||
marginBottom: "0.5rem",
|
marginBottom: "0.5rem",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{insight.summary}
|
<Markdown content={insight.summary} />
|
||||||
</div>
|
</div>
|
||||||
{insight.source_refs && insight.source_refs.length > 0 && (
|
{insight.source_refs && insight.source_refs.length > 0 && (
|
||||||
<div
|
<div
|
||||||
|
|
@ -712,15 +713,15 @@ export default function StateDisplay({ state }: StateDisplayProps) {
|
||||||
>
|
>
|
||||||
Executive Summary
|
Executive Summary
|
||||||
</h4>
|
</h4>
|
||||||
<p
|
<div
|
||||||
style={{
|
style={{
|
||||||
fontSize: "0.875rem",
|
fontSize: "0.875rem",
|
||||||
color: "#4a5568",
|
color: "#4a5568",
|
||||||
lineHeight: "1.6",
|
lineHeight: "1.6",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{state.final_report.summary}
|
<Markdown content={state.final_report.summary} />
|
||||||
</p>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div style={{ marginBottom: "1.5rem" }}>
|
<div style={{ marginBottom: "1.5rem" }}>
|
||||||
<h4
|
<h4
|
||||||
|
|
@ -741,9 +742,12 @@ export default function StateDisplay({ state }: StateDisplayProps) {
|
||||||
lineHeight: "1.6",
|
lineHeight: "1.6",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{state.final_report.findings.map((finding) => (
|
{state.final_report.findings.map((finding, idx) => (
|
||||||
<li key={finding} style={{ marginBottom: "0.5rem" }}>
|
<li
|
||||||
{finding}
|
key={`finding-${idx}-${finding.substring(0, 30)}`}
|
||||||
|
style={{ marginBottom: "0.5rem" }}
|
||||||
|
>
|
||||||
|
<Markdown content={finding} />
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
@ -767,9 +771,12 @@ export default function StateDisplay({ state }: StateDisplayProps) {
|
||||||
lineHeight: "1.6",
|
lineHeight: "1.6",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{state.final_report.conclusions.map((conclusion) => (
|
{state.final_report.conclusions.map((conclusion, idx) => (
|
||||||
<li key={conclusion} style={{ marginBottom: "0.5rem" }}>
|
<li
|
||||||
{conclusion}
|
key={`conclusion-${idx}-${conclusion.substring(0, 30)}`}
|
||||||
|
style={{ marginBottom: "0.5rem" }}
|
||||||
|
>
|
||||||
|
<Markdown content={conclusion} />
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue