Skip to content

feat: track, retry, and surface missing data - #107

Open
zhanghang02 wants to merge 2 commits into
simonlin1212:mainfrom
zhanghang02:codex/missing-data-retry-v2
Open

zhanghang02 wants to merge 2 commits into
simonlin1212:mainfrom
zhanghang02:codex/missing-data-retry-v2

Conversation

@zhanghang02

Copy link
Copy Markdown
Contributor

Rebased on current upstream main (v0.5.16) and split into reviewable commits.

  • Record failed/partial tool calls by ticker/date/stage, persist tasks, retry exact calls, cache successful outputs, and consume them on fresh analysis.
  • Surface missing-data status in the report viewer with retry and fresh reanalysis controls.
  • Add explicit incomplete-data warnings to Markdown and PDF exports.

Validation: .venv/bin/pytest -q tests/test_missing_data_tasks.py tests/test_report_viewer_pdf_gate.py tests/test_pdf_export.py (19 passed).

Unrelated local working-tree changes were intentionally left untouched.

@simonlin1212

Copy link
Copy Markdown
Owner

rebase 到 v0.5.16 并拆成两个 commit 这版好评审多了,谢谢。方向不变(#58 已关掉指到这里)。我本地全量跑了一遍:387 passed / 1 failed,合并前三件事:

1. 一个现有测试被改坏了。 tests/test_sentiment_data_tools.py::test_graph_tool_node_matches_analyst_tools 用正则 "social": ToolNode\(\s*\[(.*?)\]\s*\) 扫源码,你在列表后面加了 , wrap_tool_call=... 之后它匹配不到了:

AssertionError: 找不到 social 的 ToolNode 定义

把那个正则放宽成允许列表后跟可选的 wrap_tool_call=… 即可(这个测试的目的是校验 social 节点的工具集合,与你的改动不冲突)。

2. ToolNode(wrap_tool_call=…) 要 langgraph ≥ 1.0。 我在 langgraph 0.6.11 上实测 ToolNode.__init__ 没有这个参数,而 pyproject.toml 只要求 langgraph>=0.4.8——装着老版本的用户升级项目后会在建图时直接 TypeError,整个项目不可用。请把 pin 抬到你实际验证过的版本(建议 langgraph>=1.0),并在 CHANGELOG 里注明这是依赖要求的变化。

3. 测试里的 sys.modules.setdefault 假模块有污染风险。 test_missing_data_tasks.py 在模块顶层给 langchain_core / langchain_core.messages / tradingagents.dataflows.utils 装 stub,只要这个文件先于真模块被导入(pytest 收集顺序变化、或者单独跑它之后再跑别的),后面所有用真 langchain_core 的测试都会拿到假的。这次全量恰好没触发,但它是埋着的。请改成 monkeypatch.setitem(sys.modules, …)test_report_viewer_pdf_gate.py 里你已经是这么做的),或者干脆直接 import 真模块——完整依赖装好后这两个 stub 并不需要。

两个不阻塞的小点,顺手看看:make_tool_call_recorder 每次工具调用都 _load_index() 从磁盘读一遍 JSON(7 个 ToolNode × 每次调用),量大时会慢,可以按 ticker/date 缓存一份;_FAILURE_PATTERNS^Error\b 会把以 "Error" 开头的正常文本(比如某条新闻标题)误判成失败,加个长度或结构判断更稳。

改好 @ 我,这次不会再让你等。

@zhanghang02
zhanghang02 force-pushed the codex/missing-data-retry-v2 branch from 20bc144 to ac4de23 Compare September 8, 2026 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants