diff --git a/python/valuecell/agents/research_agent/core.py b/python/valuecell/agents/research_agent/core.py index f645c8f6c..e6bdaf68c 100644 --- a/python/valuecell/agents/research_agent/core.py +++ b/python/valuecell/agents/research_agent/core.py @@ -6,6 +6,7 @@ from edgar import set_identity from loguru import logger +import valuecell.utils.model as model_utils_mod from valuecell.agents.research_agent.knowledge import knowledge from valuecell.agents.research_agent.prompts import ( KNOWLEDGE_AGENT_EXPECTED_OUTPUT, @@ -21,7 +22,6 @@ from valuecell.core.agent.responses import streaming from valuecell.core.types import BaseAgent, StreamResponse from valuecell.utils.env import agent_debug_mode_enabled -from valuecell.utils.model import get_model class ResearchAgent(BaseAgent): @@ -34,7 +34,7 @@ def __init__(self, **kwargs): web_search, ] self.knowledge_research_agent = Agent( - model=get_model("RESEARCH_AGENT_MODEL_ID"), + model=model_utils_mod.get_model_for_agent("research_agent"), instructions=[KNOWLEDGE_AGENT_INSTRUCTION], expected_output=KNOWLEDGE_AGENT_EXPECTED_OUTPUT, tools=tools, diff --git a/python/valuecell/agents/research_agent/prompts.py b/python/valuecell/agents/research_agent/prompts.py index 17dd8b405..ce4d41275 100644 --- a/python/valuecell/agents/research_agent/prompts.py +++ b/python/valuecell/agents/research_agent/prompts.py @@ -16,6 +16,7 @@ - fetch_event_sec_filings(ticker_or_cik, forms, start_date?, end_date?, limit?): Use this for event-driven filings like 8-K and ownership forms (3/4/5). Use date ranges and limits to control scope. - fetch_ashare_filings(stock_code, report_types, year?, quarter?, limit?): Use this for Chinese A-share company filings (annual reports, semi-annual reports, quarterly reports). CRITICAL: report_types parameter MUST be in English only - use "annual", "semi-annual", or "quarterly". Never use Chinese terms like "年报", "半年报", or "季报". The function will reject Chinese parameters with an error. - Knowledge base search: Use the agent's internal knowledge index to find summaries, historical context, analyst commentary, and previously ingested documents. +- web_search(query): Use this for recency-sensitive information (press releases, IR pages, exchange notices), or when filings/KB lack specifics. Prefer primary sources (IR/SEC/exchanges) and reputable outlets. Encode time ranges and site filters directly in the query string (e.g., "site:investor.apple.com", "after:2025-01-01"). Always cite the exact URL(s). @@ -32,6 +33,7 @@ 4. Routing by query type: see to decide filings-first vs KB-first. 5. A-share: follow for parameter language and stock code formats. 6. On tool failure/no results: return any partial findings you have, state the fact succinctly (e.g., "no filings returned for this window"), and propose concrete next steps (adjust window, verify ticker/CIK, increase limit). +7. Web search (query-only): If recent events or missing context require it, use web_search with a precise query. Encode time ranges and site filters within the query itself (e.g., `site:investor.apple.com`, `after:2025-01-01`, or terms like "past 90 days"). Focus on top-quality official sources and include exact URLs in citations. @@ -58,6 +60,14 @@ 3. Output style: What level of detail and technical depth is appropriate for this query? + +- Reply in the user's language by default. If the user writes in Chinese, respond in Chinese; if in English, respond in English. +- If the user explicitly specifies a reply language (e.g., "答复请用英文" / "please answer in Chinese"), follow that preference. +- Do not translate API parameters or formal names that must remain in English (e.g., A-share `report_types` must be "annual", "semi-annual", "quarterly"). It's fine to explain them in the user's language. +- Preserve numeric accuracy and unit semantics. Adapt formatting and punctuation to the user's locale when it improves readability, but do not change the underlying values. +- Keep URLs and document titles as they are; you may add brief translated descriptors if helpful. + + Example: A-share filing query (user asks "茅台2024年年报的营收是多少?"): Tool plan: User mentioned "年报" (annual report) in Chinese, so translate to "annual" before calling fetch_ashare_filings('600519', 'annual', year=2024). @@ -141,6 +151,11 @@ - Zero fabrication: if a value is unknown or not found, say so briefly and propose how to obtain it. Do not guess numbers or invent citations. - Strict relevance: remove tangential background; keep the response tightly scoped to the user’s ask. - If a blocking ambiguity exists, ask one concise clarifying question first; otherwise proceed with a reasonable default and state the assumption. + +Language and localization: +- Reply in the user's language by default (e.g., Chinese input → Chinese output). Respect any explicit language preference in the prompt. +- Keep technical parameters that must remain English as English (e.g., A-share `report_types` values), but explain their meaning in the user's language when helpful. +- Preserve numeric fidelity; adapt units and punctuation to the locale only if unambiguous. diff --git a/python/valuecell/agents/utils/context.py b/python/valuecell/agents/utils/context.py index e0411f0f2..3ccde45ac 100644 --- a/python/valuecell/agents/utils/context.py +++ b/python/valuecell/agents/utils/context.py @@ -31,7 +31,9 @@ def _build_lang_ctx_from_dep( "When composing your answer, consider the user's language and timezone:" ) if user_lang: - parts.append(f"- Preferred language: {user_lang}") + parts.append( + f"- Preferred language: {user_lang}. Choose user's query language if different." + ) else: parts.append( "- Preferred language: not set. Infer the user's language from their query and respond in that language."