Skip to content

fix: initialize srcs path before get_codes in incremental mode#2012

Open
octo-patch wants to merge 1 commit into
FoundationAgents:mainfrom
octo-patch:fix/issue-2007-incremental-write-code-srcs-path
Open

fix: initialize srcs path before get_codes in incremental mode#2012
octo-patch wants to merge 1 commit into
FoundationAgents:mainfrom
octo-patch:fix/issue-2007-incremental-write-code-srcs-path

Conversation

@octo-patch
Copy link
Copy Markdown

Fixes #2007

Problem

In incremental mode (config.inc = True), WriteCode.run() calls get_codes() which internally accesses project_repo.srcs. The srcs property raises ValueError: Call with_srcs first. when _srcs_path has not been initialized on the ProjectRepo object.

This occurs when the project's source directory does not yet exist at the start of incremental development — ProjectRepo.__init__ calls code_files_exists(), which returns early without calling with_src_path() if the source directory is absent. The Engineer._think() fallback that calls with_src_path() covers most cases, but there are scenarios (e.g., fresh incremental projects or WriteCode used outside the Engineer role) where _srcs_path can remain None when WriteCode.run() is called.

Solution

Add a defensive guard in WriteCode.run() that initializes _srcs_path via get_project_srcs_path() when src_relative_path is None, before calling get_codes() in the incremental branch. This mirrors the existing initialization in Engineer._think() and QaEngineer._think().

Testing

The fix is a targeted guard that only fires when _srcs_path is not already set, so it does not affect the normal code path. The existing test suite (test_write_refined_code, test_get_codes) continues to cover incremental mode behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant