Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

FunctionManager reload can execute stale bytecode after same-size source edits

Đang mở Phù hợp với người mới
#688 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@jadelike-wine đang làm issue này rồi.

Từ ngày 18/10/2026.

  • #689 của @jadelike-wine — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
74/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
backend

Hướng nghiên cứu

Issue xác định utils/function_manager.py và cung cấp một cách tái hiện cho thấy kết quả cũ sau reload_functions(). Đọc loader và chạy cách tái hiện đã mô tả để xác nhận lỗi; kết quả mong đợi là các lần reload và những manager mới được tạo sẽ thực thi mã nguồn hiện tại, đồng thời việc mã hóa nguồn, lọc hàm và hành vi xóa khi reload hiện có vẫn tiếp tục hoạt động.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Python
Star
34.6k
Fork
4.3k
Merge trung bình
9 giờ 21 phút
Pull request đã merge (30 ngày)
1

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

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của OpenBMB/ChatDev

Tất cả issue của OpenBMB/ChatDev

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.