feat: add model and data source settings UI#57
Conversation
warren618
left a comment
There was a problem hiding this comment.
Thanks for the PR. The feature direction is useful and aligned with making local Web UI setup easier, but I do not think we should merge it as-is because these endpoints can modify agent/.env, credentials, and the running API process.
Requested changes:
- Make
GET /settings/*side-effect free. It currently calls_ensure_agent_env_file()and can createagent/.envfrom.env.examplejust by reading settings. - Treat documented placeholder LLM keys from
.env.exampleas unconfigured, similar to the new Tushare placeholder handling. Examples includesk-or-v1-your-key-here,sk-xxx,xxx, andgsk_xxx. - Avoid exposing absolute
env_pathfrom unauthenticated settings reads. Prefer removing it or returning a project-relative path only. - Harden settings writes. These endpoints modify credentials/runtime env, while the server defaults to
0.0.0.0andAPI_AUTH_KEYmay be unset in dev mode. Settings writes should be local-only or otherwise protected even when no API key is configured. - Move provider default metadata out of
agent/api_server.pyinto a JSON/YAML config so provider additions remain data-driven. - Add user-facing docs for the Settings page and rerun verification: targeted settings API tests, frontend build, and one real agent/backtest smoke or E2E check.
Please keep the PR open. I think this is worth merging after the above changes.
|
Thanks for the detailed review. I pushed an update in
Verification rerun:
|
warren618
left a comment
There was a problem hiding this comment.
Thanks for the update and for pushing this feature forward 🙂
I re-checked the latest PR head. The earlier blockers have now been addressed, including the settings read/write safety boundary and the Vite dev proxy path for the Settings page.
Maintainer follow-up commits added:
a3a7d4cguards settings reads behind local/auth, so masked credential hints are no longer exposed to remote unauthenticated clients.33b7b45proxies/settings/llmand/settings/data-sourcescorrectly in Vite dev mode without breaking the/settingsfrontend route.
Verified with:
pytest agent/tests/test_settings_api.py -qpython -m py_compile agent/api_server.pyimport api_servernpm run build- Real local E2E against
http://127.0.0.1:5899/settingswith the API running on127.0.0.1:8899
The agent/src/providers/llm_providers.json location is okay from maintainer side because it is provider metadata and keeps the provider list data-driven.
Approved. Thanks again 🙌
…l 注入 + runner 源门兼容 b0e014d(并行 commit)已吸收本特性的 caller 三件(factor_assets.admitted_factor_versions / ExecutionParams cell 字段 / _resolve_admitted_factors 返回 (factors, extras, refuse)), 当时 HEAD 缺生成器侧 → signal_engine_from_spec 传 extras= 即 TypeError。本 commit 补齐恢复原子: - multi_factor_signal_engine_src(+extras): _EXTRAS 烘进引擎, _panel 末段经 src.factors.local_panel.resolve_extra 注入(与研究面同一条 PIT 路; 失败 raise fail-closed); 字段名 _FACTOR_ID_RE 白名单。无 extras 烘空元组, 默认路径零行为变化。 - runner 源门兼容(并行线 in-tree): _COMPUTES/FACTORS 顶层非常量赋值违反 _validate_signal_engine_source → __COMPUTES_LIST__/权重对 generate 体内绑定 + FACTOR_IDS 常量。 - selftest 12→13(extras 烘焙/注入路径/白名单/空元组)。 端到端实测(真 registry+真 lake): academic_lowpb@1@smallcap 解析 → extras=['pb'] → 引擎过 runner 源门(含/不含 extras)→ _panel 注入真实 pb(000718.SZ .82 / 600793.SH 3.49)。 A2 pipeline 48 checks / strategy_spec 15 / factor_assets 14 全绿。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Summary
Why
Users currently need to edit
agent/.envmanually to switch LLM models or configure market data credentials. This PR exposes those common local settings in the Web UI while keeping secrets masked in API responses.No local runtime-directory migration is included in this PR.
Changes
GET/PUT /settings/llmfor project-local LLM settings persisted toagent/.env.GET/PUT /settings/data-sourcesfor Tushare token settings and BaoStock status reporting./settingsroute and sidebar entry.maxas an allowed reasoning-effort option.your-tushare-tokenas an unconfigured Tushare placeholder.agent/tests/test_settings_api.pycoverage for secret masking, env persistence, and placeholder handling.Test Plan
pytest --ignore=agent/tests/e2e_backtest --tb=short -q)Manual/targeted checks run on Windows:
python -S -m py_compile agent\api_server.py agent\backtest\loaders\tushare.py agent\tests\test_settings_api.pyE:\测试\vibe_trading\.venv\Scripts\python.exe -m pytest agent\tests\test_settings_api.py -q->4 passednpm ci --cache E:\测试\vibe_trading_pr_settings\.npm-cachenpm run build-> passed, with the existing Vite large-chunk warningpytest --ignore=agent/tests/e2e_backtest --tb=short -qon Windows reached669 passed, 1 skipped, with 3 existing Windows path assertion failures inagent/tests/test_loop_helpers.py::TestNormalizeToolRunDirwhere/tmp/...is normalized toE:\tmp\....Checklist
src/agent/,src/session/,src/providers/) without prior discussionCONTRIBUTING.mdguidelinesRelated issue
Closes #58