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

FunctionManager silently drops tool modules containing dataclasses with postponed annotations

Aperta
#681 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

@inchang-ing ci sta già lavorando.

Dal 29/9/2026.

  • #682 di @inchang-ing — aperta

Valutazione

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

Direzione di ricerca

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.

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

Descrizione

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.

Lingua principale
Python
Stelle
34.5k
Fork
4.3k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

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.