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,
|
||||
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:
|
||||
1. When user asks a question, propose a research plan (exactly 3 sub-questions)
|
||||
2. Wait for user approval before proceeding to the search phase
|
||||
3. Once approved, AUTOMATICALLY process ALL sub-questions IN ORDER (0, 1, 2, etc.) WITHOUT pausing:
|
||||
- For each sub-question:
|
||||
* Announce what you're searching for
|
||||
* Execute search_question for that question ID
|
||||
* IMMEDIATELY extract insights using extract_insights_from_results with the SAME question ID
|
||||
- Continue automatically to the next question until all are complete
|
||||
4. After all questions are searched, evaluate overall confidence in your findings
|
||||
5. Ask user if confident enough or should search more
|
||||
6. Synthesize final report with complete citations
|
||||
1. When user asks a question, IMMEDIATELY call propose_research_plan with the question
|
||||
2. Wait for user approval before proceeding
|
||||
3. Once approved, process questions ONE AT A TIME:
|
||||
- Call search_question(question_id=0) and WAIT for it to complete
|
||||
- Then call extract_insights_from_results(question_id=0) and WAIT for it to complete
|
||||
- Then call search_question(question_id=1) and WAIT for it to complete
|
||||
- Then call extract_insights_from_results(question_id=1) and WAIT for it to complete
|
||||
- Then call search_question(question_id=2) and WAIT for it to complete
|
||||
- Then call extract_insights_from_results(question_id=2) and WAIT for it to complete
|
||||
4. After all questions are processed, call evaluate_research_confidence
|
||||
5. Ask user if they want to finalize or continue researching
|
||||
6. When user approves, call synthesize_final_report
|
||||
|
||||
CRITICAL RULES:
|
||||
- ALWAYS call search_question BEFORE extract_insights_from_results for each question
|
||||
- Process questions in sequence: search Q0 → extract Q0 → search Q1 → extract Q1, etc.
|
||||
- NEVER skip ahead to extract insights for a question you haven't searched yet
|
||||
- In the search phase, DO NOT pause between questions - process all questions automatically
|
||||
- Call ONE tool at a time - wait for each tool to return before calling the next
|
||||
- NEVER call extract_insights_from_results until search_question has completed and returned results
|
||||
- DO NOT explain what you're about to do - just call the tool
|
||||
- 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:
|
||||
- Users can request to view the full content of any cited document
|
||||
- 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
|
||||
- When user asks to "show document X", call get_full_document with the document_uri
|
||||
|
||||
Be transparent: always announce what you're searching for, but don't wait for approval during the search phase.
|
||||
Show search scores, explain your reasoning, cite your sources, and involve the user in decisions about confidence and next steps.
|
||||
Remember: Call tools ONE AT A TIME in sequence. Each tool must complete before calling the next.
|
||||
""",
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
"use client";
|
||||
|
||||
import { Markdown } from "@copilotkit/react-ui";
|
||||
import { useState } from "react";
|
||||
|
||||
interface SourceRef {
|
||||
|
|
@ -413,7 +414,7 @@ export default function StateDisplay({ state }: StateDisplayProps) {
|
|||
color: "#4a5568",
|
||||
}}
|
||||
>
|
||||
{item.question}
|
||||
<Markdown content={item.question} />
|
||||
</div>
|
||||
{item.search_results && (
|
||||
<div
|
||||
|
|
@ -522,7 +523,7 @@ export default function StateDisplay({ state }: StateDisplayProps) {
|
|||
lineHeight: "1.4",
|
||||
}}
|
||||
>
|
||||
{result.chunk}...
|
||||
<Markdown content={`${result.chunk}...`} />
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
|
|
@ -622,7 +623,7 @@ export default function StateDisplay({ state }: StateDisplayProps) {
|
|||
marginBottom: "0.5rem",
|
||||
}}
|
||||
>
|
||||
{insight.summary}
|
||||
<Markdown content={insight.summary} />
|
||||
</div>
|
||||
{insight.source_refs && insight.source_refs.length > 0 && (
|
||||
<div
|
||||
|
|
@ -712,15 +713,15 @@ export default function StateDisplay({ state }: StateDisplayProps) {
|
|||
>
|
||||
Executive Summary
|
||||
</h4>
|
||||
<p
|
||||
<div
|
||||
style={{
|
||||
fontSize: "0.875rem",
|
||||
color: "#4a5568",
|
||||
lineHeight: "1.6",
|
||||
}}
|
||||
>
|
||||
{state.final_report.summary}
|
||||
</p>
|
||||
<Markdown content={state.final_report.summary} />
|
||||
</div>
|
||||
</div>
|
||||
<div style={{ marginBottom: "1.5rem" }}>
|
||||
<h4
|
||||
|
|
@ -741,9 +742,12 @@ export default function StateDisplay({ state }: StateDisplayProps) {
|
|||
lineHeight: "1.6",
|
||||
}}
|
||||
>
|
||||
{state.final_report.findings.map((finding) => (
|
||||
<li key={finding} style={{ marginBottom: "0.5rem" }}>
|
||||
{finding}
|
||||
{state.final_report.findings.map((finding, idx) => (
|
||||
<li
|
||||
key={`finding-${idx}-${finding.substring(0, 30)}`}
|
||||
style={{ marginBottom: "0.5rem" }}
|
||||
>
|
||||
<Markdown content={finding} />
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
|
|
@ -767,9 +771,12 @@ export default function StateDisplay({ state }: StateDisplayProps) {
|
|||
lineHeight: "1.6",
|
||||
}}
|
||||
>
|
||||
{state.final_report.conclusions.map((conclusion) => (
|
||||
<li key={conclusion} style={{ marginBottom: "0.5rem" }}>
|
||||
{conclusion}
|
||||
{state.final_report.conclusions.map((conclusion, idx) => (
|
||||
<li
|
||||
key={`conclusion-${idx}-${conclusion.substring(0, 30)}`}
|
||||
style={{ marginBottom: "0.5rem" }}
|
||||
>
|
||||
<Markdown content={conclusion} />
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
|
|
|
|||
Loading…
Reference in a new issue