WS-4 M1/M4:内核行为同步与 Skills 化 - #2
Merged
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR continues WS-4 Stage 4 work by aligning backend “kernel” behavior with the new non-trading analysis flow, introducing an internal Skills registry (with health endpoints) as the abstraction layer over dataflows, and removing intraday trading / leaderboard / order-execution related code paths.
Changes:
- Introduces
SkillRegistry/RoutedSkillProviderand routes existing LangChain tools through the Skills layer, plus adds/api/skills/healthand uses the existing/ws/skills-health. - Adds structured report generation (1–5 rating mapping), grounded evidence snapshots, previous-decision reflection injection, and JSON checkpoint resume for long runs.
- Removes intraday scheduler/executor, Futu trading wrappers, snapshots/leaderboard routes & models, and updates prompts/schemas to enforce “recommendations only”.
Reviewed changes
Copilot reviewed 63 out of 64 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| web/backend/tests/test_scheduler_recovery.py | Removed intraday scheduler recovery test script. |
| web/backend/services/user_intraday_scheduler.py | Removed multi-user intraday scheduler manager. |
| web/backend/services/user_config_cache.py | Drops intraday/Futu/trading-executor fields from cached config dict. |
| web/backend/services/task_executor.py | Removes trading-executor + Futu config propagation from scheduled task execution. |
| web/backend/services/snapshot_scheduler.py | Removed daily account snapshot scheduler service. |
| web/backend/services/skills/registry.py | Adds Skills registry defining 6 internal skills and provider routing. |
| web/backend/services/skills/base.py | Adds skill provider contracts + RoutedSkillProvider health/execute behavior. |
| web/backend/services/skills/init.py | Exposes get_skill_registry() API. |
| web/backend/services/prompt_loader.py | Renames default prompt to analysis agent; keeps intraday alias for compatibility. |
| web/backend/services/intraday_scheduler.py | Removed per-user intraday scheduler implementation. |
| web/backend/services/futu_async_wrapper.py | Removed async wrappers for Futu trading API functions. |
| web/backend/schemas.py | Removes trading executor / intraday access / leaderboard fields from API schemas; updates default agent type. |
| web/backend/routes/user_management_routes.py | Removes intraday-access field & related admin endpoint wiring. |
| web/backend/routes/user_leaderboard_routes.py | Removes user leaderboard toggle API. |
| web/backend/routes/user_config_routes.py | Removes trading executor + Futu config fields from user config endpoints. |
| web/backend/routes/skills_routes.py | Adds /api/skills/health route guarded by active-user auth. |
| web/backend/routes/scheduled_task_routes.py | Removes trading executor + Futu config from scheduled task creation. |
| web/backend/routes/public_leaderboard_routes.py | Removes public leaderboard APIs (snapshots/positions/decisions). |
| web/backend/routes/prompt_routes.py | Uses generated variable documentation instead of reading intraday workflow file; import cleanup. |
| web/backend/routes/leaderboard_routes.py | Removes analysis leaderboard endpoint. |
| web/backend/routes/analysis_routes.py | Removes trading-executor config propagation; removes execution report rendering; clarifies “recommendations only”. |
| web/backend/routes/account_snapshot_routes.py | Removes account snapshot APIs. |
| web/backend/routes/init.py | Adds skills_routes to routes package exports. |
| web/backend/models.py | Removes intraday/leaderboard/trading-executor models/fields; updates prompt template agent_type comment. |
| web/backend/migrations/add_llm_providers_models.py | Updates default OpenAI provider metadata and default models list. |
| web/backend/migrations/005_update_tool_descriptions_english.py | Removes trading tool description for place_futu_order. |
| web/backend/migrations/004_update_tool_descriptions_chinese.py | Removes trading tool description for place_futu_order. |
| web/backend/migrations/003_init_default_prompts.py | Initializes default prompt templates using new analysis agent type and prompt function. |
| web/backend/database.py | Updates model import list used for table registration (removes intraday-related models). |
| web/backend/auth_routes.py | Removes require_intraday_access dependency. |
| web/backend/app.py | Removes intraday/leaderboard/snapshot startup logic and route wiring; adds skills router; updates app description. |
| web/backend/analysis_task.py | Adds provider-aware API key resolution, checkpoint resume/save, safe path joins, grounded evidence, stage logs, structured report build, and previous-decision reflection injection. |
| tradingagents/utils/structured_outputs.py | Adds structured report helpers (rating mapping, evidence snapshot, previous decision reflection). |
| tradingagents/utils/security.py | Adds safe_join / safe_path_component to harden filesystem artifact paths. |
| tradingagents/utils/checkpoints.py | Adds JSON checkpoint persistence helpers. |
| tradingagents/utils/init.py | Adds utils package marker. |
| tradingagents/graph/trading_graph.py | Removes trading executor node; wires provider API keys into LLM constructors; adds safe logging path; configures conditional logic with config values. |
| tradingagents/graph/setup.py | Removes trading executor workflow edges; keeps recommendation-only flow. |
| tradingagents/graph/propagation.py | Extends initial state with structured report fields + previous decision reflection. |
| tradingagents/graph/conditional_logic.py | Removes conditional logic for trading executor tool loops. |
| tradingagents/default_config.py | Adds TRADINGAGENTS_* env support and provider API key fields; updates default base URL and model defaults. |
| tradingagents/dataflows/interface.py | Adds baostock as a vendor option and extends method mappings / fallback order. |
| tradingagents/agents/utils/tool_registry.py | Restricts tool registry to read-only tools (removes Futu trading tooling registration). |
| tradingagents/agents/utils/technical_indicators_tools.py | Routes technical indicator tool through Skills registry. |
| tradingagents/agents/utils/news_data_tools.py | Routes news tools through Skills registry (but see review comments re: insider transactions routing). |
| tradingagents/agents/utils/fundamental_data_tools.py | Routes fundamentals tools through Skills registry. |
| tradingagents/agents/utils/core_stock_tools.py | Routes OHLCV data tool through Skills registry (but see review comments re: date window contract). |
| tradingagents/agents/utils/agent_states.py | Adds structured report / reflection / evidence fields; removes execution report field. |
| tradingagents/agents/trader/trading_executor.py | Removes trading execution agent implementation. |
| tradingagents/agents/trader/trader.py | Adds previous decision reflection injection and structured output requirements; reinforces “no orders”. |
| tradingagents/agents/trader/intraday_trader_workflow.txt | Removes intraday trading workflow document. |
| tradingagents/agents/trader/intraday_trader_default_prompt.txt | Removes default intraday trading prompt file. |
| tradingagents/agents/managers/risk_manager.py | Adds structured report build + reflection; injects previous decision reflection (but see review comment re: fundamentals sourcing bug). |
| tradingagents/agents/managers/research_manager.py | Adds structured output requirements and reflection block propagation. |
| tradingagents/agents/analysts/social_media_analyst.py | Adds grounded evidence snapshot generation (but see review comment re: overwriting evidence). |
| scripts/init_llm_config.py | Updates default provider/model configuration data used for DB init. |
| .gitignore | Ignores local env files more broadly; keeps .env.example. |
| .env.local | Removes committed local env file (secrets). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -15,6 +16,7 @@ def risk_manager_node(state) -> dict: | |||
| fundamentals_report = state["news_report"] | |||
Comment on lines
+60
to
+65
| "grounded_evidence": evidence_snapshot( | ||
| ticker=ticker, | ||
| as_of=current_date, | ||
| report=report, | ||
| sources=["get_news", "social-sentiment"], | ||
| ) if report else state.get("grounded_evidence", []), |
Comment on lines
+121
to
+125
| actions={ | ||
| "sentiment": lambda ticker, start_date, end_date, **_: _route_to_vendor( | ||
| "get_news", ticker, start_date, end_date | ||
| ), | ||
| }, |
Comment on lines
+101
to
+106
| actions={ | ||
| "company": lambda ticker, start_date, end_date, **_: _route_to_vendor( | ||
| "get_news", ticker, start_date, end_date | ||
| ), | ||
| "global": lambda curr_date=None, look_back_days=7, limit=5, **_: _route_to_vendor("get_global_news", curr_date or datetime.now(timezone.utc).date().isoformat(), look_back_days, limit), | ||
| }, |
| str: A report of insider transaction data | ||
| """ | ||
| return route_to_vendor("get_insider_transactions", ticker, curr_date) | ||
| return get_skill_registry().execute("news", "company", ticker=ticker, start_date=curr_date, end_date=curr_date) |
| "historical", | ||
| symbol=symbol, | ||
| curr_date=end_date, | ||
| look_back_days=max(1, (datetime.strptime(end_date, "%Y-%m-%d").date() - datetime.strptime(start_date, "%Y-%m-%d").date()).days), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
WS-4 Stage 4 第二段:M1 内核行为同步 + M4 Skills 化。基于
ws-4-stage4-m0分支继续,和 M0 PR 解耦,便于独立 review。M1 内核同步
grounded_evidence。STRUCTURED_OUTPUT;最终final_state.structured_report统一生成五级评级、5 个分项、证据、阶段日志、反思。structured_outputs.py将 BUY/HOLD/SELL/strong buy/sell 映射为 1-5 评级,并贯穿综合与分项。previous_decision_reflection,并保存在最终reflection。TRADINGAGENTS_*环境变量:新增TRADINGAGENTS_LLM_PROVIDER、TRADINGAGENTS_DEEP_LLM、TRADINGAGENTS_QUICK_LLM、TRADINGAGENTS_OPENAI_BASE_URL、provider API key 自动探测;兼容原 env。M4 Skills 化
SkillProvider/RoutedSkillProvider抽象与SkillRegistry。market-data、technical-indicators、fundamentals、news、social-sentiment、market-detection。GET /api/skills/health和/ws/skills-health健康推送。非目标 / 约束
验证
python -m compileall -q web/backend tradingagentsfastapi影响,未作为本地验证项。Refs WS-4