diff --git a/apps/open-swe/src/graphs/shared/initialize-sandbox.ts b/apps/open-swe/src/graphs/shared/initialize-sandbox.ts index fc6f1bdf..132b44d6 100644 --- a/apps/open-swe/src/graphs/shared/initialize-sandbox.ts +++ b/apps/open-swe/src/graphs/shared/initialize-sandbox.ts @@ -275,6 +275,16 @@ export async function initializeSandbox( "error", "Failed to clone repository. Please check your repo URL and permissions.", ); + const errorFields = { + ...(cloneRepoRes instanceof Error + ? { + name: cloneRepoRes.name, + message: cloneRepoRes.message, + stack: cloneRepoRes.stack, + } + : cloneRepoRes), + }; + logger.error("Cloning repository failed", errorFields); throw new Error("Failed to clone repository."); } const newBranchName = diff --git a/apps/open-swe/src/utils/github/git.ts b/apps/open-swe/src/utils/github/git.ts index 5e6e5c7a..9ca1e9b7 100644 --- a/apps/open-swe/src/utils/github/git.ts +++ b/apps/open-swe/src/utils/github/git.ts @@ -5,6 +5,7 @@ import { TIMEOUT_SEC } from "@open-swe/shared/constants"; import { getSandboxErrorFields } from "../sandbox-error-fields.js"; import { getRepoAbsolutePath } from "@open-swe/shared/git"; import { ExecuteResponse } from "@daytonaio/sdk/src/types/ExecuteResponse.js"; +import { withRetry } from "../retry.js"; const logger = createLogger(LogLevel.INFO, "GitHub-Git"); @@ -102,12 +103,32 @@ export async function checkoutBranchAndCommit( await sandbox.git.commit(absoluteRepoDir, "Apply patch", userName, userEmail); // Push the changes using the git API so it handles authentication for us. - await sandbox.git.push( - absoluteRepoDir, - "git", - options.githubInstallationToken, + const pushRes = await withRetry( + async () => { + return await sandbox.git.push( + absoluteRepoDir, + "git", + options.githubInstallationToken, + ); + }, + { retries: 3, delay: 0 }, ); + if (pushRes instanceof Error) { + const errorFields = { + ...(pushRes instanceof Error + ? { + name: pushRes.name, + message: pushRes.message, + stack: pushRes.stack, + cause: pushRes.cause, + } + : pushRes), + }; + logger.error("Failed to push changes", errorFields); + throw new Error("Failed to push changes"); + } + logger.info("Successfully checked out & committed changes.", { commitAuthor: userName, });