FunctionManager silently drops tool modules containing dataclasses with postponed annotations
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 72/100
Hướng nghiên cứu
Start with utils/function_manager.py and reproduce the temporary tool module containing postponed annotations and a dataclass. Run python reproduce.py --fetch --case chatdev-dataclass-tools --variant after from the linked bundle to inspect the seven regression and control tests. Done means increment is available and failed imports clean up or restore module state while existing filtering remains intact.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
The dynamic loader creates a module with module_from_spec() and executes it without inserting it into sys.modules. A tool file containing from __future__ import annotations and a dataclass then fails during class creation, because the dataclass decorator needs to resolve the defining module.
FunctionManager catches the import failure and omits the module's functions, so otherwise valid agent tools become unavailable.
Reproduction
import tempfile
from pathlib import Path
from utils.function_manager import FunctionManager
with tempfile.TemporaryDirectory() as directory:
path = Path(directory) / 'example.py'
path.write_text('''from __future__ import annotations
from dataclasses import dataclass
@dataclass
class Payload:
value: int
def increment(value: int) -> int:
return Payload(value).value + 1
''', encoding='utf-8')
manager = FunctionManager(Path(directory))
print(manager.has_function('increment')) # Actual: False; expected: True
print(manager.call_function('increment', 41)) # Expected: 42
Proposed change
Register the new module in sys.modules[module_name] before exec_module(). On an import failure, remove the partially initialized module or restore the previous entry, then re-raise into the existing loader error handling. This follows normal import semantics while preserving the current filtering of private and imported functions.
Validation
Source: utils/function_manager.py, current blob 50de030442ec72e8293482320cc37072367c86cd.
Before: 4 failed, 3 passed. After: 7 passed. The complete FunctionManager module was run against real temporary tool files, including postponed-annotation dataclasses, self-referential annotations, ordinary tools, imported/private function filtering, failed-import cleanup, and restoration after a failed reload.
Python 3.13.5, pytest 9.0.2, Linux. No provider calls or full workflow execution were run. Searches for FunctionManager issues and dataclass-related PRs found memory-store additions, not this dynamic-import failure.
Patch and tests
Source-pinned patch and seven regression/control tests. From the bundle root, run python reproduce.py --fetch --case chatdev-dataclass-tools --variant after. The runner verifies the source hash and patch application before executing the tests.
- Ngôn ngữ chính
- Python
- Star
- 34.5k
- Fork
- 4.3k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của OpenBMB/ChatDev
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 76/100
-
CodeReviewModification never shows the programmer the six review regulations, so fixes are made blind to the checklist they are re-reviewed againstCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
Tất cả issue của OpenBMB/ChatDev
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
task
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
danparshall/claude_researcher#87 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
datajoint/datajoint-python#1586 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
1D intercept of length 1 is accepted as `fix_params` in population GLM with more than 1 unitCó thể đã có người làm @dhvani7014 đã nhận hôm nay. Đang mởbug good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
flatironinstitute/nemos#642 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Broken links in the docsĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
uniswap-python/uniswap-python#487 ·