Summary
prepare_workspace() unconditionally defaults remote="fork", causing git fetch fork to fail when called during initial implementation before any PR/fork has been created. The failure cascades into a ValueError and an infinite retry loop.
Observed Behavior
2026-07-17 13:16:46,681 - forge.workflow.nodes.implementation - ERROR - Unable to prepare implementation workspace for AISOS-2234: Cannot recreate workspace for AISOS-2234: missing branch_name, current_repo, fork_owner, or fork_repo in state
2026-07-17 13:16:46,684 - forge.workspace.git_ops - INFO - Syncing with fork/forge/aisos-2234 before implementing changes
2026-07-17 13:16:46,726 - forge.workflow.nodes.workspace_setup - WARNING - Workspace sync failed for AISOS-2234; recreating workspace from fork: Git command failed: git fetch fork
fatal: 'fork' does not appear to be a git repository
The workflow retries indefinitely, hitting the same error each time.
Root Cause
prepare_workspace() in src/forge/workflow/nodes/workspace_setup.py:62 has remote: str = "fork" as a default parameter. When the implementation node calls it during initial implementation (before any PR/fork has been created), fork_owner and fork_repo are empty strings in state.
The failure sequence:
prepare_workspace() finds the workspace path exists on disk (line 94), taking the "sync existing workspace" path
- Calls
git.pull_rebase(remote="fork") (line 103), which runs git fetch fork (git_ops.py:133)
- No
"fork" remote exists — add_fork_remote() was never called because there is no fork yet
git fetch fork fails → exception handler (line 104-117) falls through to _recreate_workspace_from_fork()
_recreate_workspace_from_fork() checks fork_owner/fork_repo (line 35) — both are empty strings
- Raises
ValueError: "Cannot recreate workspace... missing branch_name, current_repo, fork_owner, or fork_repo in state"
- Implementation node catches this, sets
last_error, workflow retries → infinite loop
Correct Pattern Already Exists
setup_workspace() (lines 253-268 in the same file) handles this correctly:
fork_owner = state.get("fork_owner", "")
fork_repo_name = state.get("fork_repo", "")
if fork_owner and fork_repo_name:
git.add_fork_remote(fork_owner, fork_repo_name)
# ... use fork remote
else:
git.create_branch(default_branch) # use origin
prepare_workspace() does not replicate this guard.
Proposed Fix
prepare_workspace() should:
- Check whether
fork_owner/fork_repo are populated in state
- When populated: call
add_fork_remote() to ensure the remote exists, then sync with "fork"
- When empty: sync with
"origin" instead of "fork"
This aligns prepare_workspace() with the pattern already established in setup_workspace().
Affected Files
src/forge/workflow/nodes/workspace_setup.py — prepare_workspace() (line 61)
src/forge/workspace/git_ops.py — pull_rebase() (line 121, default remote="fork")
Summary
prepare_workspace()unconditionally defaultsremote="fork", causinggit fetch forkto fail when called during initial implementation before any PR/fork has been created. The failure cascades into aValueErrorand an infinite retry loop.Observed Behavior
The workflow retries indefinitely, hitting the same error each time.
Root Cause
prepare_workspace()insrc/forge/workflow/nodes/workspace_setup.py:62hasremote: str = "fork"as a default parameter. When the implementation node calls it during initial implementation (before any PR/fork has been created),fork_ownerandfork_repoare empty strings in state.The failure sequence:
prepare_workspace()finds the workspace path exists on disk (line 94), taking the "sync existing workspace" pathgit.pull_rebase(remote="fork")(line 103), which runsgit fetch fork(git_ops.py:133)"fork"remote exists —add_fork_remote()was never called because there is no fork yetgit fetch forkfails → exception handler (line 104-117) falls through to_recreate_workspace_from_fork()_recreate_workspace_from_fork()checksfork_owner/fork_repo(line 35) — both are empty stringsValueError: "Cannot recreate workspace... missing branch_name, current_repo, fork_owner, or fork_repo in state"last_error, workflow retries → infinite loopCorrect Pattern Already Exists
setup_workspace()(lines 253-268 in the same file) handles this correctly:prepare_workspace()does not replicate this guard.Proposed Fix
prepare_workspace()should:fork_owner/fork_repoare populated in stateadd_fork_remote()to ensure the remote exists, then sync with"fork""origin"instead of"fork"This aligns
prepare_workspace()with the pattern already established insetup_workspace().Affected Files
src/forge/workflow/nodes/workspace_setup.py—prepare_workspace()(line 61)src/forge/workspace/git_ops.py—pull_rebase()(line 121, defaultremote="fork")