Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta Adatta ai principianti
#688 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@jadelike-wine ci sta già lavorando.

Dal 18/10/2026.

  • #689 di @jadelike-wine — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
74/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

L’issue identifica utils/function_manager.py e fornisce una riproduzione che mostra risultati obsoleti dopo reload_functions(). Leggi il loader ed esegui la riproduzione descritta per confermare il malfunzionamento; il risultato atteso è che i reload e i manager appena creati eseguano il codice sorgente corrente, mentre la codifica esistente del codice sorgente, il filtraggio delle funzioni e il comportamento di rimozione durante il reload continuino a funzionare.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Python
Stelle
34.6k
Fork
4.3k
Merge medio
9h 21m
PR unite (30g)
1

Preparare l'ambiente

  • Include un Dockerfile o un file Docker Compose
  • Nessun modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di OpenBMB/ChatDev

Tutte le issue di OpenBMB/ChatDev

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.