🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org
Python agentai-societiesartificial-intelligencecommunicative-aicooperative-aideep-learninglarge-language-modelsmulti-agent-systemsnatural-language-processing
fix: GithubToolkit: Accept "Reference already exists" error (#1898)
yihuang455437f415c7
diff --git a/camel/toolkits/github_toolkit.py b/camel/toolkits/github_toolkit.pyindex 77ea4705a..793f04746 100644--- a/camel/toolkits/github_toolkit.py+++ b/camel/toolkits/github_toolkit.py@@ -110,9 +110,20 @@ class GithubToolkit(BaseToolkit):successfully or not."""sb = self.repo.get_branch(self.repo.default_branch)- self.repo.create_git_ref(- ref=f"refs/heads/{branch_name}", sha=sb.commit.sha- )+ from github import GithubException+ try:+ self.repo.create_git_ref(+ ref=f"refs/heads/{branch_name}", sha=sb.commit.sha+ )+ except GithubException as e:+ if e.message == "Reference already exists":+ # agent might have pushed the branch separately.+ logger.warning(+ f"Branch {branch_name} already exists. "+ "Continuing with the existing branch."+ )+ else:+ raisefile = self.repo.get_contents(file_path)