MCPcopy Create free account
hub / github.com/openai/openai-agents-python / run

Method run

examples/research_bot/manager.py:21–50  ·  view source on GitHub ↗
(self, query: str)

Source from the content-addressed store, hash-verified

19 self.printer = Printer(self.console)
20
21 async def run(self, query: str) -> None:
22 trace_id = gen_trace_id()
23 with trace("Research trace", trace_id=trace_id):
24 self.printer.update_item(
25 "trace_id",
26 f"View trace: https://platform.openai.com/traces/trace?trace_id={trace_id}",
27 is_done=True,
28 hide_checkmark=True,
29 )
30
31 self.printer.update_item(
32 "starting",
33 "Starting research...",
34 is_done=True,
35 hide_checkmark=True,
36 )
37 search_plan = await self._plan_searches(query)
38 search_results = await self._perform_searches(search_plan)
39 report = await self._write_report(query, search_results)
40
41 final_report = f"Report summary\n\n{report.short_summary}"
42 self.printer.update_item("final_report", final_report, is_done=True)
43
44 self.printer.end()
45
46 print("\n\n=====REPORT=====\n\n")
47 print(f"Report: {report.markdown_report}")
48 print("\n\n=====FOLLOW UP QUESTIONS=====\n\n")
49 follow_up_questions = "\n".join(report.follow_up_questions)
50 print(f"Follow up questions: {follow_up_questions}")
51
52 async def _plan_searches(self, query: str) -> WebSearchPlan:
53 self.printer.update_item("planning", "Planning searches...")

Callers 4

_plan_searchesMethod · 0.45
_searchMethod · 0.45
mainFunction · 0.45
main.pyFile · 0.45

Calls 7

_plan_searchesMethod · 0.95
_perform_searchesMethod · 0.95
_write_reportMethod · 0.95
gen_trace_idFunction · 0.90
traceFunction · 0.90
update_itemMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected