FunctionManager silently drops tool modules containing dataclasses with postponed annotations
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 72/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Python
- Estrellas
- 34.5k
- Forks
- 4.3k
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Sin plantilla de pull request
- Sin guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de OpenBMB/ChatDev
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 76/100
-
CodeReviewModification never shows the programmer the six review regulations, so fixes are made blind to the checklist they are re-reviewed againstPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 1/5 1-3 horas Aptitud para principiantes 78/100
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
Todos los issues de OpenBMB/ChatDev
Issues similares
-
Broken links found in docsAbiertodocs pydanty:is-working
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
pydantic/pydantic-ai#10113 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
GreedyBear-Project/GreedyBear#1727 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
ARM-software/CMSIS-DSP#354 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
kiat/codeAssist#391 ·
-
needs triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
darnitdevorg/darnit#587 ·
Los mantenedores suelen responder en 1 día