chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 12:39:17 +08:00
commit 4ed4e9ff99
1368 changed files with 334957 additions and 0 deletions
@@ -0,0 +1,23 @@
from pydantic import BaseModel
from agents import Agent
# A subagent focused on analyzing a company's fundamentals.
FINANCIALS_PROMPT = (
"You are a financial analyst focused on company fundamentals such as revenue, "
"profit, margins and growth trajectory. Given a collection of web (and optional file) "
"search results about a company, write a concise analysis of its recent financial "
"performance. Pull out key metrics or quotes. Keep it under 2 paragraphs."
)
class AnalysisSummary(BaseModel):
summary: str
"""Short text summary for this aspect of the analysis."""
financials_agent = Agent(
name="FundamentalsAnalystAgent",
instructions=FINANCIALS_PROMPT,
output_type=AnalysisSummary,
)
@@ -0,0 +1,35 @@
from pydantic import BaseModel
from agents import Agent
# Generate a plan of searches to ground the financial analysis.
# For a given financial question or company, we want to search for
# recent news, official filings, analyst commentary, and other
# relevant background.
PROMPT = (
"You are a financial research planner. Given a request for financial analysis, "
"produce a set of web searches to gather the context needed. Aim for recent "
"headlines, earnings calls or 10K snippets, analyst commentary, and industry background. "
"Output between 5 and 15 search terms to query for."
)
class FinancialSearchItem(BaseModel):
reason: str
"""Your reasoning for why this search is relevant."""
query: str
"""The search term to feed into a web (or file) search."""
class FinancialSearchPlan(BaseModel):
searches: list[FinancialSearchItem]
"""A list of searches to perform."""
planner_agent = Agent(
name="FinancialPlannerAgent",
instructions=PROMPT,
model="o3-mini",
output_type=FinancialSearchPlan,
)
@@ -0,0 +1,22 @@
from pydantic import BaseModel
from agents import Agent
# A subagent specializing in identifying risk factors or concerns.
RISK_PROMPT = (
"You are a risk analyst looking for potential red flags in a company's outlook. "
"Given background research, produce a short analysis of risks such as competitive threats, "
"regulatory issues, supply chain problems, or slowing growth. Keep it under 2 paragraphs."
)
class AnalysisSummary(BaseModel):
summary: str
"""Short text summary for this aspect of the analysis."""
risk_agent = Agent(
name="RiskAnalystAgent",
instructions=RISK_PROMPT,
output_type=AnalysisSummary,
)
@@ -0,0 +1,27 @@
from pydantic import BaseModel
from agents import Agent, ModelSettings, WebSearchTool
# Given a search term, use web search to pull back a brief summary.
# Summaries should be concise but capture the main financial points.
INSTRUCTIONS = (
"You are a research assistant specializing in financial topics. "
"Given a search term, use web search to retrieve uptodate context and "
"produce a short summary of at most 300 words. Focus on key numbers, events, "
"or quotes that will be useful to a financial analyst."
)
class FinancialSearchSummary(BaseModel):
summary: str
"""A concise summary of the search findings."""
search_agent = Agent(
name="FinancialSearchAgent",
model="gpt-5.6-sol",
instructions=INSTRUCTIONS,
tools=[WebSearchTool()],
model_settings=ModelSettings(response_include=["web_search_call.action.sources"]),
output_type=FinancialSearchSummary,
)
@@ -0,0 +1,48 @@
from typing import Literal
from pydantic import BaseModel
from agents import Agent
# Agent to sanitycheck a synthesized report for consistency and recall.
# This can be used to flag potential gaps or obvious mistakes.
VERIFIER_PROMPT = (
"You are a meticulous evidence auditor. You will receive an original request, an explicit "
"research cutoff date, a financial report, and structured web research evidence with source "
"URLs. Judge the report only against that supplied evidence; do not reject or approve claims "
"based on your own memory. Check that material numeric and time-sensitive claims are supported "
"by the evidence, that citations use supplied URLs, that the report is internally consistent, "
"and that uncertainty is appropriately caveated. Treat information published on or before the "
"research cutoff as potentially available. Mark unsupported claims separately from claims that "
"the evidence directly contradicts."
)
class VerificationIssue(BaseModel):
claim: str
"""The report claim that needs attention."""
category: Literal["unsupported", "contradicted", "stale_or_unreleased", "other"]
"""The evidence problem associated with the claim."""
explanation: str
"""Why the evidence does not support the claim."""
source_urls: list[str]
"""Relevant supplied source URLs, if any."""
class VerificationResult(BaseModel):
verified: bool
"""Whether the report is coherent and supported by the supplied evidence."""
issues: list[VerificationIssue]
"""Evidence-based issues that must be corrected before publication."""
verifier_agent = Agent(
name="VerificationAgent",
instructions=VERIFIER_PROMPT,
model="gpt-5.6-sol",
output_type=VerificationResult,
)
@@ -0,0 +1,42 @@
from pydantic import BaseModel
from agents import Agent
# Writer agent brings together the raw search results and optionally calls out
# to subanalyst tools for specialized commentary, then returns a cohesive markdown report.
WRITER_PROMPT = (
"You are a senior financial analyst. You will be provided with the original query and "
"a set of raw search summaries. Your task is to synthesize these into a longform markdown "
"report (at least several paragraphs) including a short executive summary and followup "
"questions. If needed, you can call the available analysis tools (e.g. fundamentals_analysis, "
"risk_analysis) to get short specialist writeups to incorporate. Every material numeric or "
"time-sensitive claim must include an inline Markdown citation using a URL supplied in the "
"research evidence. Never invent or alter a source URL."
)
REVISION_PROMPT = (
f"{WRITER_PROMPT} You are revising an existing report after evidence verification. Address "
"every verification issue, remove claims that cannot be supported, preserve valid analysis, "
"and return a complete replacement report rather than a patch or commentary."
)
class FinancialReportData(BaseModel):
short_summary: str
"""A short 23 sentence executive summary."""
markdown_report: str
"""The full markdown report."""
follow_up_questions: list[str]
"""Suggested followup questions for further research."""
# Note: We will attach handoffs to specialist analyst agents at runtime in the manager.
# This shows how an agent can use handoffs to delegate to specialized subagents.
writer_agent = Agent(
name="FinancialWriterAgent",
instructions=WRITER_PROMPT,
model="gpt-5.6-sol",
output_type=FinancialReportData,
)