Skip to content

Commit b45c4f5

Browse files
fix: create PR tool checks out onto custom branch (#470)
1 parent 34990c8 commit b45c4f5

File tree

1 file changed

+4
-0
lines changed
  • src/codegen/extensions/langchain

1 file changed

+4
-0
lines changed

src/codegen/extensions/langchain/tools.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Langchain tools for workspace operations."""
22

33
import json
4+
import uuid
45
from typing import ClassVar, Literal, Optional
56

67
from langchain.tools import BaseTool
@@ -355,6 +356,9 @@ def __init__(self, codebase: Codebase) -> None:
355356
super().__init__(codebase=codebase)
356357

357358
def _run(self, title: str, body: str) -> str:
359+
if self.codebase._op.git_cli.active_branch.name == self.codebase._op.default_branch:
360+
# If the current checked out branch is the default branch, checkout onto a new branch
361+
self.codebase.checkout(branch=f"{uuid.uuid4()}", create_if_missing=True)
358362
pr = self.codebase.create_pr(title=title, body=body)
359363
return pr.html_url
360364

0 commit comments

Comments
 (0)