تحقیقات عمیق با کلید API Openai


نویسنده (ها): دانیل خاریتونف

در ابتدا منتشر شده در به سمت هوش مصنوعیبشر

TL ؛ دکتر اگر به قابلیت های تحقیق عمیق نیاز دارید اما نمی خواهید برای OpenAi برای برنامه Pro Pro Prop خود ، 199 دلار در هر ماه بپردازید ، یک دستیار تحقیقاتی با پرداخت هزینه (و احتمالاً بهتر) می توانید با استفاده از API OpenAi ساخته شوید. نکته اصلی در اینجا کار کردن در مورد محدودیت های مدل های تحقیقاتی عمیق ، سازماندهی گردش کار در حلقه بهبود و درج ابزارهای سفارشی است که از بررسی واقعیت پشتیبانی می کنند. بسته بندی همه اینها در پایتون ، تحقیقات عمیق بسیار تصفیه شده را با قیمت حدود 2 تا 5 دلار در هر گزارش ارائه می دهد.

کد نمونه و یک مثال Quickstart در GitHub استبشر

معرفی

هیچ پنهانی نیست که تحقیقات عمیق (DR) دنیای خراش و تجزیه و تحلیل وب را با طوفان در نظر گرفته است. مدل های تحقیقاتی عمیق می توانند مراحل تحقیق خود را برنامه ریزی کنند ، صدها سایت را خراشیده و اقدامات خود را تصحیح کنند-که به طور قابل توجهی عملکرد آنها را نسبت به استدلال منظم بهبود می بخشد LLMS با دسترسی به وب

متأسفانه ، این توانایی های چشمگیر رایگان نیست.

به عنوان مثال ، از ژوئیه 2025، Chatgpt Limits Plus ، Team ، Enterprise و EDU فقط 25 نمایشگاه تحقیق عمیق در هر ماه ، در حالی که کاربران PRO 125 (به علاوه 125 نمایشگاه اضافی “سبک”) دریافت می کنند. کاربران برنامه رایگان هیچ راهی برای درخواست تحقیقات عمیق ندارند ، اگرچه OpenAi اظهار داشت که پنج نمایش داده “سبک” هنوز در دسترس آنها هستند.

این محدودیت ها با توجه به اینکه تحقیقات عمیق از طریق نشانه ها با سرعت پیچ و تاب می سوزد ، به خوبی درک می شود-این محتوای بسیاری از وب سایت ها را طی می کند و بارها و بارها مراحل استدلال خود را دوباره ارزیابی می کند. علاوه بر این ، تعداد LLM ارائه دهندگان ارائه دهنده قابلیت های تحقیق عمیق محدود هستند ، بنابراین آزمایشگاه های مرزی هنوز هم می توانند حق بیمه را بپردازند.

اما آیا راهی برای جلوگیری از مدل اشتراک انعطاف پذیر و پرداخت آن در هنگام رفتن وجود دارد؟ پاسخ “بله” است ، اما این نیاز به کمی اسکریپت دارد.

قسمت 1. اصول.

خوشبختانه ، مدل های تحقیقاتی عمیق از OpenAI از طریق API نیز در دسترس هستند و این امر دسترسی به DR را در قالب پرداخت به عنوان شما در خارج از ردیف اشتراک های Chatgpt بسیار آسان می کند. از ژوئیه 2025 ، وجود دارد دو مدل DR موجود است-O3-Deep-Research ، و O4-Mini-Dipeep-Desearchبشر مدل های بیشتری باید به زودی ارائه شوند.

اگر یک کلید API OpenAi معتبر دارید ، ساده ترین راه برای انجام تحقیقات عمیق یک تماس واحد به پاسخ API است:

system_message = """
You are a professional researcher preparing a structured, data-driven report on behalf of a global health economics team. Your task is to analyze the health question the user poses
Be analytical, avoid generalities, and ensure that each section supports data-backed reasoning that could inform healthcare policy or financial modeling.
"""

user_query = "Research impact of semaglutide on global healthcare systems."

response = client.responses.create(
model="o3-deep-research",
input=[
{
"role": "developer",
"content": [
{
"type": "input_text",
"text": system_message,
}
]
},
{
"role": "user",
"content": [
{
"type": "input_text",
"text": user_query,
}
]
}
],
reasoning={
"summary": "auto"
},
tools=[
{
"type": "web_search_preview"
},
{
"type": "code_interpreter",
"container": {
"type": "auto",
"file_ids": []
}
}
]
)

منبع: مقدمه Openai برای API تحقیقات عمیق

چندین نکته در مورد قطعه فوق وجود دارد.

اول ، مدل تحقیق عمیق باید یک جستجوی وب پیکربندی شده باشد و بدون آن کار نخواهد کرد. ابزار دیگری که توسط OpenAI پیشنهاد شده است ، یک مترجم کد ماسهبازی است ، اگرچه در تجربه من به ندرت (در صورت وجود) توسط مدل استفاده می شود ، احتمالاً به این دلیل که محاسبات آماری اغلب به عنوان بخشی از تحقیقات عمیق مورد نیاز نیست. گزینه ای برای استفاده از سرور MCP نیز در دسترس است ، اما فقط به دو عملکرد “جستجوی” و “واکشی” محدود می شود – که با امضاهای ابزار اکثر سرورهای MCP عمومی مطابقت ندارد.

همچنین ، اگر مثال بالا را اجرا کنید ، تجربه شما نسبتاً ضد آب و هوایی خواهد بود. بسته به پرس و جو ، دو تا ده دقیقه صبر خواهید کرد و سپس چند صفحه متن دریافت می کنید. قطعاً به عنوان نمونه ای از تجربه خوب کاربر توصیه نمی شود.

قسمت 2. عوامل ، کسی؟

یکی از روندهای اخیر این است که هر ویژگی هوش مصنوعی را به یک برنامه “عامل” بپیوندید تا امور بهتر و پاسخگو باشد.

Openai مطمئناً از این رویکرد غریبه نیست و نسخه کمی جلا تر از کد فوق را می توان در کتاب آشپزی آنها یافت آشنایی با عوامل API تحقیقاتی عمیقبشر

پیشرفت های کلیدی در نسخه عامل آنها از برنامه تحقیقاتی عمیق ، یک پردازنده رویداد ASYNC برای چاپ نتایج تحقیقات متوسط ​​و مراحل اولیه توضیح سریع است:

تحقیقات عمیق با کلید API Openaiتحقیقات عمیق با کلید API Openai
منبع: کتاب آشپزی نمایندگان تحقیقات عمیق Openai

با این حال ، در حالی که یک روش ASYNC برای اجرای API تحقیقات عمیق و پاسخ های جریان به کاربر قطعاً گامی به جلو است ، روشی که OpenAI از چارچوب نمایندگان خود در تحقیقات عمیق استفاده می کند ، به خصوص بصیرت نیست. بازرسی از پرس و جو کاربر و بازنویسی سریع یک فرایند استاندارد در یک رابط چتپپ است که به طور معمول نمایش های کاربر را با مدل های ارزان تر اجرا می کند ، اما ارزش محدودی را برای نمایش داده های تحقیقاتی عمیق واقع بینانه می بخشد که تمایل به خود دارند و به مهندسی سریع نیاز ندارند.

به عبارت دیگر ، اگر می خواهیم برای تحقیقات عمیق یک گردش کار عامل ایجاد کنیم ، باید در مورد تحویل های تحقیق تکرار کنیم و نه در سریع.

قسمت 3. ما واقعاً از یک مأمور تحقیقاتی عمیق به چه چیزی احتیاج داریم؟

بنابراین اجازه دهید ما از آنجا شروع کنیم که Openai از کار خارج شده و یک عامل تحقیقاتی را طراحی کنید که می تواند واقعاً مفید باشد.

در اینجا لیستی از ویژگی هایی که من شخصاً قانع کننده می دانم وجود دارد:

  • به طور خودکار نتایج تحقیق را بهبود بخشیدبشر ما می دانیم که نمایش داده شدگان پیچیده ممکن است اطلاعات متناقض را بدست آورند ، بنابراین ممکن است ما نیاز به حفر بیشتر داشته باشیم.
  • به روزرسانی های زمان واقعی را ارائه دهیدبشر این به معنای طراحی یک پردازنده رویداد خوب Async برای آگاهی از کاربران از مراحلی است که مدل انجام می دهد.
  • از ابزارهای مربوطه استفاده کنیدبشر جستجوهای وب عالی هستند ، اما ممکن است روشهای بهتری برای پرس و جو و تأیید تحقیقات شما وجود داشته باشد.
  • در مراحل کار کنید. اگر چندین مرحله پردازش مورد نیاز باشد ، ما می خواهیم بتوانیم آنها را به طور مستقل برای اشکال زدایی اجرا کنیم و از سوزاندن اعتبار در خطوط لوله ناکامی جلوگیری کنیم.
  • هزینه ها را پیگیری کنیدبشر ما می خواهیم آمار در مورد چقدر هزینه های تحقیق عمیق خود را خرج می کنیم.

با این لیست دلخواه ، می توانیم جلو برویم و شروع به ساخت کنیم.

قسمت 4. یادداشت های کد.

معماری
بگذارید از همان چارچوب OpenAi Agents مانند کتاب آشپزی استفاده کنیم ، اما گردش کار را اصلاح کنیم. همانطور که بحث شد ، ما می توانیم با خیال راحت مراحل سریع مهندسی را از بین ببریم و روی تکرار خودکار بر نتایج تمرکز کنیم:

منبع: نویسنده

در نمودار بالا ، نماینده تحقیقاتی مدل تحقیق عمیق را اجرا می کند ، و این گزارش اولیه توسط مأمور نقدبشر اگر سابق این تحقیق را کافی نداشته باشد ، می توان یک اجرای دیگر را درخواست کرد.

در گزارش نماینده تحقیق و نقد را تثبیت می کند و تحویل نهایی را ارائه می دهد. این سیستم به حداکثر دو تحقیق عمیق برای صرفه جویی در اعتبار محدود می شود ، و همچنین برای جلوگیری از بازی کاهش بازده در صورتی که موضوع تحقیق از جستجوی اضافی سود نمی برد.

کار با محدودیت های مدل تحقیق عمیق.
همانطور که قبلاً ذکر شد ، مدل های تحقیقاتی عمیق از Openai در حال حاضر در ابزار محدود هستند. این دو پیام برای نماینده تحقیق ما دارد:

(1) ما نمی توانیم از دستگیره به عنوان روش منحصر به فرد انتقال کنترل استفاده کنیم. این امر به این دلیل است که دستگیره در نمایندگان SDK به عنوان ‘اجرا می شوندtransfer_to“تماس های ابزار ، و مدل های تحقیقاتی عمیق از آنها پشتیبانی نمی کند. راه حل این است که کنترل را از نماینده تحقیقاتی به مأمور نقد از نظر برنامه ای (بدون تصمیم گیری LLM). اشکالی ندارد که کنترل را از طریق دستی در جهت مخالف عبور دهید زیرا عامل نقد می تواند از یک حالت استدلال منظم استفاده کند. بنابراین جریان کنترل ما ترکیبی می شود.

(2) به همین دلیل ، ما نمی توانیم از MCP و ابزارهای سفارشی در نماینده تحقیقاتی و دوباره باید این توابع را به عامل نقد (که از یک مدل استدلال منظم استفاده می کند). دومی همچنین مسئول تغییر مجدد این کار است نماینده تحقیقاتی در صورت یافتن نتایج تحقیق فاقد.

پردازش رویداد.
برای رهگیری جستجوهای وب ، خلاصه های استدلال ، جستجوی MCP و تماس های ابزار ، باید یک تجزیه کننده را برای رویدادهای خام پیاده سازی کنیم. علاوه بر این ، برای ارائه تخمین هزینه نهایی ، باید استفاده از نشانه ها را جمع کنیم.

لوله کشی
انتقال بین عوامل یک نقطه طبیعی برای ضبط خروجی ها ارائه می دهد و مرحله بعدی را به طور جداگانه شروع می کند (در صورت تمایل). این امر به مهندسی سریع و مدیریت خرابی کمک می کند ، جایی که ما مراحل نقد یا گزارش را بدون نمایش داده های دوباره اجرا می کنیم نماینده تحقیقاتیبشر

قسمت 5. اجرای.

در اینجا ما برخی از نکات برجسته اجرای برنامه واقعی را نشان می دهیم. کارخانه نماینده ما سه نوع عامل را برمی گرداند: تحقیقبا انتقاد وت گزارش:

 return Agent(
name="ResearchAgent",
instructions=research_instructions,
model=MODEL_RESEARCH,
model_settings=ResearchAgents._create_base_model_settings(),
tools=[
WebSearchTool(),
CodeInterpreterTool(tool_config=CodeInterpreter(
type="code_interpreter",
container={"type": "auto", "file_ids": []}
)),
],
handoffs=[]
)
...
return Agent(
name="CritiqueAgent",
instructions=critique_instructions,
model=MODEL_CRITIQUE,
model_settings=ResearchAgents._create_base_model_settings(),
tools=[
WebSearchTool(),
verify_url
],
handoffs=handoffs
)
...
return Agent(
name="FinalReportAgent",
instructions=final_report_instructions,
model=MODEL_FINAL_REPORT,
model_settings=ResearchAgents._create_base_model_settings(),
tools=[
CodeInterpreterTool(tool_config=CodeInterpreter(
type="code_interpreter",
container={"type": "auto", "file_ids": []}
)),
WebSearchTool()
]
)

همانطور که می بینیم ، فقط عامل منتقدان از یک دستمال معمولی استفاده می کند (می تواند تصمیم به بازگشت کنترل به نماینده تحقیق یا عامل گزارش بگیرد).

ما همچنین مجهز به مأمور نقد با یک ابزار سفارشی و سرور MCP:

 async def create_critique_agent_with_mcp(research_agent=None) -> tuple[Agent, MCPServerSse]:
"""Create critique agent with connected MCP server. Returns (agent, mcp_server) tuple."""

# Create and connect DeepWiki MCP server with robust timeout settings
deepwiki_server = MCPServerSse(
params={
"url": "https://mcp.deepwiki.com/sse",
"timeout": 30, # Connection timeout: 30 seconds
"sse_read_timeout": 600, # SSE read timeout: 10 minutes
},
client_session_timeout_seconds=60.0, # ClientSession read timeout: 60 seconds
cache_tools_list=True,
name="DeepWiki"
)

# Connect the server
await deepwiki_server.connect()

# Create base agent
agent = ResearchAgents.create_critique_agent(research_agent)

# Add MCP server to agent with strict schema configuration and timeout settings
agent.mcp_servers = [deepwiki_server]
agent.mcp_config = {
"convert_schemas_to_strict": True,
"timeout": 30, # Tool call timeout in seconds
"request_timeout": 60 # Request timeout in seconds
}

return agent, deepwiki_server
...

def verify_url(url: str) -> Dict[str, Any]:
"""
Verify if a URL or HTTP/HTTPS API endpoint exists and is accessible.

Args:
url: The URL to verify (must be properly formatted with http:// or https://)

Returns:
Dictionary containing verification results with status code, success flag, and details
"

""
if not url or not isinstance(url, str):
return {
"success": False,
"status_code": None,
"error": "Invalid URL provided - must be a non-empty string",
"accessible": False,
"response_time_ms": None
}

این ابزارها نشانگر بارهای کاری است که من به آنها اهمیت می دهم و احتمالاً باید در برنامه های شما تغییر کند. برای موارد استفاده من ، من از Deepwiki برای پاسخ به سؤال در مورد مخازن GitHub استفاده می کنم (از طریق سرور عمومی DeepWiki MCP). علاوه بر این ، من می خواهم بتوانم تشخیص دهم که نقاط پایانی API و وب سایت های ارجاع شده توسط تحقیقات عمیق کاربردی هستند ، بنابراین من از یک استفاده می کنم verify_url () عملکرد به عنوان تابعی که می تواند کدهای HTTP را از URL های مورد نظر برگرداند.

همچنین ممکن است به توضیح توضیح دهد که چگونه می توانیم هزینه های استفاده در برنامه را تخمین بزنیم. ما می توانیم این عملکرد را در گزارش نماینده با آموزش آن برای به دست آوردن قیمت در صفحه وب OpenAI ، و سپس از مفسر کد برای تکثیر آنها با آمار توکن که در پردازنده رویداد جمع می کنیم استفاده کنید:

"""
IMPORTANT: The critique analysis includes detailed token usage statistics at the end showing multiple models (e.g., o4-mini-deep-research, o4-mini) with their respective token counts. You MUST:

1. Extract ALL model names and their token usage from the token usage statistics
2. Use web search to get pricing from https://platform.openai.com/docs/pricing for each model
3. Use code interpreter to calculate costs for ALL models found in the statistics
4. Create a comprehensive cost breakdown table showing each model, token types, and costs
5. Include a "Performance Metrics and Cost Analysis" section with detailed cost calculations
"""

با این وجود شایان ذکر است که این روش تخمین هزینه فقط تقریبی است و نباید در تولید استفاده شود. یک کاستی در اینجا ، پرش از نماینده گزارش در محاسبات هزینه انجام شده توسط نماینده گزارش است و دلیل دیگر نوسانات در منابع قیمت است که مدل می تواند پیدا کند. در برنامه تولید من ، تخمین هزینه را در یک خط لوله مستقل اجرا می کنم.

قسمت 6. تنظیمات و حالت های خرابی OpenAI.

پیکربندی برای برنامه تحقیقاتی عمیق ما بیشتر شامل اضافه کردن یک ابزار سفارشی (یا یک سرور MCP) برای تأیید نتایج تحقیق که در موارد استفاده شما مهم است.

علاوه بر این ، قسمتهای مربوطه مأمور نقد در Research_agents.py باید اصلاح شود تا ابزارهای سفارشی موجود را منعکس کند. این بخش دوم (در تئوری) اختیاری است زیرا عوامل می توانند دستورالعمل ابزار را از DocStrings به طور خودکار استخراج کنند. با این حال ، ما دریافتیم که اعلان های صریح هنوز هم بهتر کار می کنند ، به خصوص هنگام اجبار مدل برای استفاده از MCP.

"""
IMPORTANT: You MUST use the verify_url tool to test every API endpoint mentioned in the research report. This is critical for validating source accessibility and API claims.

CRITICAL: For ANY GitHub repository mentioned in the research (even just the name like "facebook/react" or URLs like "https://github.com/user/repo"), you MUST immediately use the DeepWiki MCP tools to gather additional information:
1. First use ask_question to get basic information about the repository
2. Use ask_question again for specific technical details relevant to the research topic
3. If MCP tools timeout or fail, note this in your critique and continue with other verification methods

Tool Usage Guidelines:
- Use web search tool to verify claims when necessary

- Use DeepWiki MCP tools to ask in-depth questions about GitHub repositories mentioned in the research report.
MANDATORY: If the research mentions ANY of these patterns, use MCP tools immediately:
- Repository names like "openai/openai-python", "facebook/react", "microsoft/typescript"
- GitHub URLs like "https://github.com/user/repo"
- Any reference to "GitHub repository" or "repo" or "source code"

Examples of DeepWiki MCP use:
- ask_question(repoName="openai/openai-python", question="What is this repository about?")
- ask_question(repoName="openai/openai-python", question="How does authentication work?")
- ask_question(repoName="vercel/next.js", question="What are the main API components?")
- ask_question(repoName="tensorflow/tensorflow", question="How to implement custom models?")

- Use verify_url tool to check select API endpoints to verify if they actually exist
Examples of when to use verify_url:
- Testing API endpoint: verify_url("https://api.openai.com/v1/models")
- Checking API documentation: verify_url("https://docs.example.com/api")
"""


انتخاب پیش فرض مدل ها در config.py:

MODEL_RESEARCH = "o4-mini-deep-research"
MODEL_CRITIQUE = "o3-pro"
MODEL_FINAL_REPORT = "o4-mini"

برای تغییر تعادل بین کیفیت و هزینه نتیجه نهایی ، مدل تحقیق را می توان به “O3-Deep-Research” تغییر داد و مدل نقد را می توان به “O3”-یا یک مدل استدلال مشابه تبدیل کرد. گزارش نهایی معمولاً درست است که با یک مدل غیر فصلی تهیه شود.

موفقیت برای پرس و جوهای تحقیقاتی عمیق ما به توانایی تکمیل درخواست های مدل OpenAI بستگی دارد. بسته به سطح خدمات برای کلید API شما ، نقطه پایانی OpenAI ممکن است در زمان اوج کم و بیش شلوغ باشد. اگر درخواست از بین رفته است ، ممکن است پیامی مانند این را ببینید:

ERROR:openai.agents:Error streaming response: An error occurred while processing your request. You can retry your request, or contact us through our help center at help.openai.com if the error persists. Please include the request ID req_8c8c09a17f9544755961ba9a624ee920 in your message.
Error: Workflow execution failed: An error occurred while processing your request. You can retry your request, or contact us through our help center at help.openai.com if the error persists. Please include the request ID req_8c8c09a17f9544755961ba9a624ee920 in your message.

اگر این اتفاق برای شما رخ می دهد ، وحشت نکنید و فقط چند دقیقه بعد پرس و جو را اجرا کنید. اگر برنامه شما به طور خودکار راه اندازی می شود ، می توانید کد بازگشت را نیز بررسی کنید تا ببینید کدام قسمت به پایان نرسیده است:

 python main.py -q "query" -cvri
case $? in
0) echo "Success!" ;;
1) echo "Invalid arguments" ;;
2) echo "Research agent failed" ;;
3) echo "Critique agent failed" ;;
4) echo "Final report agent failed" ;;
5) echo "General error" ;;
esac

فراموش نکنید که این برنامه می تواند در مراحل اجرا شود ، بنابراین (به عنوان مثال) اگر گزارش نهایی از بین برود ، هنوز هم می توانید از نتایج حاصل از تحقیق و نقد استفاده مجدد کنید.

قسمت 7 از نمونه ها استفاده کنید.

بگذارید ابتدا مثالی از نحوه عملکرد کامل برنامه را نشان دهیم:

$ export QUERY="Compare agent handoffs in Goog ADK, LangChain, and OpenAI Agents"
$ python agentic_research.py -q "$(echo $QUERY)" -cvri

🔍 Agentic Research Tool
========================================
ℹ️ 🔄 Iterative Research-Critique Workflow (Hybrid)
--------------------
Using hybrid approach: programmatic research→critique, OpenAI critique→research
ℹ️ Starting iterative workflow: Compare and contrast agent handoff mechanisms in Google ADK, LangChain, and OpenAI agents

🔍 Beginning research...

🔍 Research streaming events:

🔄 Handoff to: ResearchAgent
💭 [REASONING] ✓
💭 [REASONING SUMMARY]
**Exploring agent handoff mechanisms**

The user's query is about comparing agent handoff mechanisms in Google ADK, LangChain, and OpenAI agents for a structured research report. I need to consider what "agent handoff" means, likely in the context of conversational AI. I'm unsure about "Google ADK," but it might stand for "Google Agent Development Kit." Perhaps this relates to "Conversational Actions" or "Dialogflow." The report will need to logically assess how tasks are handed off between different AI agents, including data and maybe some charts.
**Investigating agent handoff mechanisms**

LangChain is a Python framework that allows for chaining language model calls, and it seems to involve something related to "Agents in LangChain." When it comes to OpenAI agents, this might refer to GPT-4's built-in features. Now, I see the user's question about comparing agent handoff mechanisms, which likely involves how control is transferred between agents in these frameworks. I should look up "Google ADK agent handoff mechanism" for more information.
🔍 [Web search] Google ADK agent handoff mechanism
💭 [REASONING] ✓
💭 [REASONING SUMMARY]
**Exploring multi-agent systems**
...
...

همانطور که می بینیم ، در مرحله اول (تحقیق) ، برنامه در درجه اول مشغول اجرای چرخه طولانی جستجوهای وب است و به دنبال آن خلاصه های استدلال است. بسته به پیچیدگی ، این ممکن است از دو تا ده دقیقه طول بکشد.

پس از آن ، ما باید شاهد لگد زدن به مرحله نقد باشیم:

...
...
💭 [REASONING SUMMARY]
**Organizing GitHub Repositories**

I’m thinking about breaking out specific names like "facebook/react" and "openai/openai-python" into a neat list of GitHub repositories. I'll include entries such as google/adk-python, google/adk-samples, langchain-ai/langchain, openai/openai-agents-python, and openai/openai-agents-js. I might mention "openai/agents-runbook" since it's relevant, even if it's not a framework. My final plan involves structuring sections and potentially comparing elements in a table for clarity. This way, I can enhance understanding and organization!
**Structuring GitHub Repositories**

I’m considering using a small table for presenting information, but I think it might get cluttered with citations. Instead, I could use a bullet list to outline details like mechanism types and invocation styles. For instance, I'

ll describe how ADK, LangGraph, and OpenAI Agents function.

Then, I’ll provide a bulleted list of GitHub repositories—including google/adk-python and openai/openai-agents-python. I initially thought about including hyperlinks, but plain text names seem more fitting based on the instructions. So, I’ll settle on a straightforward list format.

💭 Generated 19,200 reasoning tokens
🎯 Total tokens: 1,870,200 (1,848,060 input, 22,140 output, 1,343,972 cached)
Raw research events saved to results/raw_events_research.json

✅ Initial research completed
Results saved to results/research_results.txt and results/research_results.json

📝 Starting critique with handoff capability and MCP tools...

📝 Critique streaming events:

🔄 Handoff to: CritiqueAgent
💭 [REASONING] ✓
l] verify_url(https://langchain-ai.lang.chat/langgraph/how-tos/agent-handoffs/)

🔧 [Tool] verify_url(https://openai.github.io/openai-agents-js/guides/handoffs)
💭 [REASONING] ✓
🔧 [Tool] verify_url(https://github.com/google/adk-python)
💭 [REASONING] ✓
💭 [REASONING SUMMARY]
**Investigating link issues**

Wait, I noticed that the GitHub link for adk-python gives a 404 error, but our tool indicates a status of 200. That’s a bit odd! It suggests the link may have been renamed or moved, even though the tool shows it accessible. The response time seems high too, but there's no final URL. It's strange, but I guess we can trust the tool's initial success. This also seems to apply to adk-samples.
💭 [REASONING] ✓
📚 [MCP] ask_question(Serafin-dev/google-adk: '
What is this repository about?')
💭 [REASONING] ✓
📚 [MCP] ask_question(google/adk-python: '
What is this repository about?')
💭 [REASONING] ✓
📚 [MCP] ask_question(google/adk-python: '
What handoff mechanisms are supported by its SDK?')
💭 [REASONING] ✓
📚 [MCP] ask_question(google/adk-samples: '
What is this repository about?')
💭 [REASONING] ✓

در مرحله نقد که در بالا نشان داده شده است ، باید علاوه بر جستجوهای وب ، چندین تماس ابزار و MCP را مشاهده کنیم. این مرحله همچنین ممکن است در نهایت انتقادات را به آن بازگرداند نماینده تحقیقاتی برای بینش بیشتر:

🔧 [Tool] transfer_to_researchagent({})

🔄 Handoff to: ResearchAgent
💭 [REASONING] ✓
💭 [REASONING SUMMARY]
**Reviewing research content**

It seems the user is looking for feedback on a research report, likely focused on evaluating accuracy and content. I need to review it closely for correctness and verify statements against sources like GitHub and Google Cloud. The content has many references, which raises questions about completeness and potential biases. I’ll pay special attention to the sections covering “agent handoff mechanisms” in various frameworks, breaking down the content and checking for factual accuracy and any gaps.
🔍 [Web search] Google ADK agent handoff transfer_to_agent LlmAgent sub_agents
💭 [REASONING] ✓ 💭 [REASONING] ✓ 💭 [REASONING] ✓ 🔍 [Web search] "transfer_to_agent"
💭 [REASONING] ✓ 🔍 [Web search] "FunctionCall(name='transfer_to_agent'"
💭 [REASONING] ✓ 🔍 [Web search] site:google.github.io ADK sub_agents transfer
💭 [REASONING] ✓ 💭 [REASONING] ✓ 💭 [REASONING] ✓ 💭 [REASONING] ✓
💭 [REASONING SUMMARY]
**Exploring Relevant Class Definitions**

I need to find something relevant to the user's request, and I’m leaning toward examining class definitions. It might help clarify or provide insights that align with what I'm looking for. I wonder if it could lead to a better understanding of the concepts involved. I'll take some time to delve into these definitions to see how they connect with the user's needs. Let's see where this takes me!

پس از مشورت بیشتر ، نماینده تحقیقاتی باید مستقیماً به گزارش نماینده:

While the report covers main patterns, it could discuss nuances, such as resuming or chaining agents. Mentioning how different agent types interact would add depth. The source quality appears solid, but referencing unofficial GitHub links can introduce bias. A structured critique would enhance clarity and completeness.

💭 Generated 17,152 reasoning tokens
🎯 Total tokens: 1,647,572 (1,628,046 input, 19,526 output, 1,371,630 cached)
Raw research_critique_iterative events saved to results/raw_events_iterative.json

✅ Iterative workflow completed

============================================================
FINAL OUTPUT:
============================================================
**Factual Accuracy:** The report’s descriptions of each framework’s handoff mechanism are generally on point, but there are a few minor inaccuracies or confusing bits. For Google ADK, it correctly notes that one can emit a `transfer_to_agent` function call to let a child agent take over (this is confirmed by Google’s ADK blog, which explains that calling a sub-agent fully “transfers…responsibility” to that agent and leaves the root “out of the loop” ([cloud.google.com](https://cloud.google.com/blog/products/ai-machine-learning/build-multi-agentic-systems-using-google-adk#:~:text=This%20limitation%20stems%20from%20how,in%20these%20scenarios))). It also correctly describes wrapping an agent as an `AgentTool`, which the root can call like a function. The Google Cloud example even shows `flight_tool = agent_tool.AgentTool(agent=flight_agent)` and a root LLM agent invoking it ([cloud.google.com](https://cloud.google.com/blog/products/ai-machine-learning/build-multi-agentic-systems-using-google-adk#:~:text=from%20google.adk.agents%20import%20agent_tool%20,can%20use%20these%20tools)). However, the snippet in the report that reads ``FunctionCall(name='ImageGen',…)`` seems out of place (it likely should show calling the flight or booking agent’s tool instead). Also, the report relies on a user’s GitHub (`Serafin-dev/google-adk`) for details; it would be stronger to cite Google’s own ADK docs or code for verification.

سرانجام ، نماینده گزارش خروجی نهایی را گردآوری می کند و هزینه های منابع را محاسبه می کند:

Critique saved to results/critique_results.txt

============================================================
ℹ️ 📊 Final Report Mode
============================================================
ℹ️ Starting final report generation from previous workflow steps

📊 Generating comprehensive final report...
(Synthesizing research findings and critique into markdown format)

🔄 Handoff to: FinalReportAgent
💭 [REASONING] ✓ 🔍 [Web search] site:platform.openai.com/docs/pricing o4-mini-deep-research
💭 [REASONING] ✓ 💭 [REASONING] ✓ 💭 [REASONING] ✓ 🔍 [Web search] site:openai.com o4-mini pricing tokens
💭 [REASONING] ✓ 💭 [REASONING] ✓ 🔍 [Web search] o4-mini per million input tokens site:platform.openai.com
💭 [REASONING] ✓
[ (53 lines) code interprer] import pandas as pd ...
💭 [REASONING SUMMARY]
**Exploring pricing tiers**

## Performance Metrics and Cost Analysis

| Model | Token Type | Count | Rate (USD per 1M tokens) | Cost (USD) |
|--------------------------------|----------------------|-----------:|--------------------------:|---------------:|
| **o4-mini-deep-research** | Prompt (billable) | 484,888 | $2.00 ([ai-stats.phaseo.app](https://ai-stats.phaseo.app/prices/openai?utm_source=chatgpt.com)) | $0.9698 |
| | Reasoning | 19,200 | $2.00 ([ai-stats.phaseo.app](https://ai-stats.phaseo.app/prices/openai?utm_source=chatgpt.com)) | $0.0384 |
| | Cached (free) | 1,343,972 | $0.00 | $0.0000 |
| | Output | 22,140 | $8.00 ([ai-stats.phaseo.app](https://ai-stats.phaseo.app/prices/openai?utm_source=chatgpt.com)) | $0.1771 |
| | **Total** | 1,870,200 | | **$1.1853** |
| **o4-mini** | Prompt (billable) | 239,264 | $1.10 ([ai-stats.phaseo.app](https://ai-stats.phaseo.app/prices/openai?utm_source=chatgpt.com)) | $0.2632 |
| | Reasoning | 17,152 | $1.10 ([ai-stats.phaseo.app](https://ai-stats.phaseo.app/prices/openai?utm_source=chatgpt.com)) | $0.0189 |
| | Cached (free) | 1,371,630 | $0.00 | $0.0000 |
| | Output | 19,526 | $4.40 ([ai-stats.phaseo.app](https://ai-stats.phaseo.app/prices/openai?utm_source=chatgpt.com)) | $0.0859 |
| | **Total** | 1,647,572 | | **$0.3679** |
| **Subtotal (Research + Critique)** | | 3,517,772 | | **$1.5532** |
| **Estimated Final Report (o4-mini)**| Prompt | 2,000 | $1.10 ([ai-stats.phaseo.app](https://ai-stats.phaseo.app/prices/openai?utm_source=chatgpt.com)) | $0.0022 |
| | Output | 10,000 | $4.40 ([ai-stats.phaseo.app](https://ai-stats.phaseo.app/prices/openai?utm_source=chatgpt.com)) | $0.0440 |
| | **Stage Total** | 12,000 | | **$0.0462** |
| **Grand Total (All Stages)** | | 3,529,772 | | **$1.5994** |

در این مرحله ، ./results پوشه باید گزارش نهایی را در Markdown ، به علاوه نقد میانی و خروجی های تحقیق در متن داشته باشد. علاوه بر این ، رویدادهای خام برای هر عامل ذخیره می شوند در مورد مدل های موردی که انواع جدید رویداد را منتشر می کنند که هنوز برای آنها حساب نشده است.

پس از اتمام کار کامل ، نتایج متن متوسط ​​برای تحقیق و نقد نیز می تواند برای شروع مجدد مراحل بعدی در صورت عدم موفقیت یا نیاز به تنظیم سریع استفاده شود.

به عنوان مثال ، اجرای زیر مرحله نقد را شروع می کند که مرحله تحقیق از آن خارج شده است:

$ $ python agentic_research.py -q "$(echo $QUERY)" -cv

این است
تحقیقات عمیق مبارک!
این کد در GitHub موجود است، بنابراین احساس راحتی کنید که کلون کنید و ستاره را ستاره کنید!

منتشر شده از طریق به سمت هوش مصنوعی



منبع: https://towardsai.net/p/l/deep-research-with-openais-api-key