Skip to content

armgit / camel

Public Imported from GitHub
0

🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org

enhance: PlanningWorktreeToolkit clears worktree state before remove … (#4024)

Wendong-Fan006371375c88
diff --git a/camel/toolkits/planning_worktree_toolkit.py b/camel/toolkits/planning_worktree_toolkit.py
index 47122cbda..e13e7761f 100644
--- a/camel/toolkits/planning_worktree_toolkit.py
+++ b/camel/toolkits/planning_worktree_toolkit.py
@@ -357,12 +357,21 @@ class PlanningWorktreeToolkit(BaseToolkit):
os.chdir(main_repo_path)
if branch_name:
- self._run_git(
+ branch_delete_result = self._run_git(
"branch",
"-d",
branch_name,
cwd=main_repo_path,
)
+ if branch_delete_result.returncode != 0:
+ return self._error_result(
+ branch_delete_result.stderr.strip()
+ or branch_delete_result.stdout.strip()
+ or f"Failed to delete branch '{branch_name}'.",
+ removed_worktree=str(worktree_path),
+ remaining_branch=branch_name,
+ working_directory=str(self.working_directory),
+ )
return {
"removed_worktree": str(worktree_path),