ITADN

Incremental mode crashes with "ValueError: Call with_srcs first." in WriteCode

#2007Opendiagraph-de 创建于 2026-04-13
D
diagraph-decommented
**Bug description** MetaGPT crashes in incremental mode during the engineer/write-code phase with: ```text ValueError: Call with_srcs first. ``` This appears to happen because the incremental code path accesses `project_repo.srcs` before initializing the source path via `with_src_path(...)`. **Bug solved method** Not solved upstream yet. Possible root cause: In `metagpt/actions/write_code.py`, `WriteCode.run()` behaves differently for normal vs incremental mode. Non-incremental branch: ```python project_repo=self.repo.with_src_path(self.context.src_workspace) ``` Incremental branch: ```python project_repo=self.repo ``` Later, `get_codes()` calls: ```python src_file_repo = project_repo.srcs ``` But in `metagpt/utils/project_repo.py`, `project_repo.srcs` raises: ```python ValueError("Call with_srcs first.") ``` if `_srcs_path` was never initialized. So the incremental path seems to miss a required initialization step before using `project_repo.srcs`. **Environment information** - LLM type and model name: - Ollama - `thinkbook-coder:latest` (based on `qwen2.5-coder:7b`) - System version: - Windows 11 - Version `10.0.26100` - Python version: - Python `3.11.9` - MetaGPT version or branch: - MetaGPT `0.8.2` - packages version: - `metagpt 0.8.2` - local backend via Ollama - installed in a local Python 3.11 virtual environment - installation method: - `pip install metagpt` **Screenshots or logs** Relevant traceback: ```text Traceback (most recent call last): File ".../metagpt/utils/common.py", line 664, in wrapper return await func(self, *args, **kwargs) File ".../metagpt/roles/role.py", line 551, in run rsp = await self.react() File ".../metagpt/roles/role.py", line 520, in react rsp = await self._react() File ".../metagpt/roles/role.py", line 475, in _react rsp = await self._act() File ".../metagpt/roles/engineer.py", line 149, in _act return await self._act_write_code() File ".../metagpt/roles/engineer.py", line 156, in _act_write_code changed_files = await self._act_sp_with_cr(review=self.use_code_review) File ".../metagpt/roles/engineer.py", line 112, in _act_sp_with_cr coding_context = await todo.run() File ".../metagpt/actions/write_code.py", line 109, in run code_context = await self.get_codes( File ".../metagpt/actions/write_code.py", line 171, in get_codes src_file_repo = project_repo.srcs File ".../metagpt/utils/project_repo.py", line 128, in srcs raise ValueError("Call with_srcs first.") ValueError: Call with_srcs first. ``` Additional note: This does not appear to be an Ollama runtime issue. The local model continues working correctly; the crash occurs inside MetaGPT's incremental write-code flow.
3 条评论