FunctionManager reload can execute stale bytecode after same-size source edits
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
Issueでは utils/function_manager.py が特定され、reload_functions() の後に古い結果が表示される再現手順が示されています。ローダーを読み、説明されている再現手順を実行して失敗を確認してください。期待される結果は、リロードと新しく作成されたマネージャーが現在のソースを実行し、既存のソースエンコーディング、関数のフィルタリング、リロード時の削除動作も引き続き正常に機能することです。
索引モデルが issue の本文から書いたものです。
説明
FunctionManager.reload_functions() can continue executing a tool's old source after the file has been edited. The dynamic loader accepts a timestamp-based .pyc when the source has the same integer-second mtime and byte length. Two same-length saves within one second can therefore survive an explicit reload.
Reproduced against main a2ea4a263cebe9a7abd01ee3b5b0bf95698ed328 on Windows with Python 3.12.13:
import os
import tempfile
from pathlib import Path
from utils.function_manager import FunctionManager
with tempfile.TemporaryDirectory() as directory:
tool = Path(directory) / "tool.py"
tool.write_text("def value(): return 1\n", encoding="utf-8")
os.utime(tool, (1700000000, 1700000000))
manager = FunctionManager(directory)
assert manager.call_function("value") == 1
tool.write_text("def value(): return 2\n", encoding="utf-8")
os.utime(tool, (1700000000, 1700000000))
manager.reload_functions()
assert manager.call_function("value") == 2 # fails: still returns 1
The fixed timestamp makes the cache collision deterministic; ordinary same-second edits can have the same effect. Creating a new manager also accepts a stale existing bytecode cache.
A focused fix is to execute compiled current source in the module namespace already prepared by module_from_spec, rather than reading the timestamp-based bytecode cache. Three tests against the real module give 2 failed, 1 passed on main and 3 passed with this change; the control checks source encoding, function filtering, and removing a tool on reload. No model/provider calls are involved.
This concerns source freshness, independently of the dataclass/module-registration issue #681 and closed PR #682. Searches for FunctionManager, reload, and bytecode found no matching report or PR. Prepared with Codex assistance; the reproduction and tests were run locally.
- 主要言語
- Python
- スター
- 34.6k
- フォーク
- 4.3k
- 平均マージ
- 9時間 21分
- マージ済み PR(30日)
- 1
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
OpenBMB/ChatDev のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
CodeReviewModification never shows the programmer the six review regulations, so fixes are made blind to the checklist they are re-reviewed against対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 1/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
-
FunctionManager silently drops tool modules containing dataclasses with postponed annotations対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
OpenBMB/ChatDev の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
-
Validate finite output clamping limits in StepPredictor.prepare_clamping_params to prevent silent NaN/Inf propagation対応中かも @muskan-creates352 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
mllam/neural-lam#848 ·
メンテナーはふだん 2 日以内に返信
-
infra
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
fab-geocommuns/RNB-coeur#1166 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
deepspeedai/DeepSpeed#8951 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
aws/context-ontology-accelerator#343 ·
メンテナーはふだん 1 日以内に返信