from pydantic import BaseModel, Field from agents import Agent INSTRUCTIONS = ( "You evaluate whether web search summaries are sufficient to write a strong report on the user's " "original query. Judge coverage, relevance, and depth—not writing quality. " "If summaries are off-topic, empty, contradictory, or miss major aspects of the query, " "set proceed_to_report to false and explain what is missing or wrong in feedback_for_planner. " "If the material is good enough to synthesize a solid answer, set proceed_to_report to true. " "Be pragmatic: partial but relevant evidence can be enough; do not demand perfection." ) class ResearchEvaluation(BaseModel): proceed_to_report: bool = Field( description="True if search summaries are adequate to write the report; false to replan searches." ) rationale: str = Field(description="Brief justification for the decision.") feedback_for_planner: str = Field( description=( "If replanning: concrete gaps, bad angles, or suggested directions for new searches. " "If proceeding: may be empty or a short note." ), ) evaluator_agent = Agent( name="EvaluatorAgent", instructions=INSTRUCTIONS, model="gpt-4o-mini", output_type=ResearchEvaluation, )