@@ -12,7 +12,7 @@ import { PRData, PRProcessResult, OpenSWEStreamResults } from "./types.js";
1212import { createPRFixPrompt } from "./prompts.js" ;
1313import { runPytestOnFiles } from "./utils.js" ;
1414import { v4 as uuidv4 } from "uuid" ;
15- import { MANAGER_GRAPH_ID , GITHUB_PAT , GITHUB_INSTALLATION_ID } from "@open-swe/shared/constants" ;
15+ import { MANAGER_GRAPH_ID , GITHUB_PAT } from "@open-swe/shared/constants" ;
1616import { createLangGraphClient } from "../src/utils/langgraph-client.js" ;
1717import { encryptSecret } from "@open-swe/shared/crypto" ;
1818import { ManagerGraphState } from "@open-swe/shared/open-swe/manager/types" ;
@@ -93,21 +93,19 @@ async function runOpenSWEWithStreamTracking(inputs: {
9393 try {
9494 const encryptionKey = process . env . SECRETS_ENCRYPTION_KEY ;
9595 const githubPat = process . env . GITHUB_PAT ;
96- const githubInstallationId = process . env . GITHUB_INSTALLATION_ID ;
9796
98- if ( ! encryptionKey || ! githubPat || ! githubInstallationId ) {
97+ if ( ! encryptionKey || ! githubPat ) {
9998 throw new Error (
100- "SECRETS_ENCRYPTION_KEY, GITHUB_PAT, and GITHUB_INSTALLATION_ID environment variables are required"
99+ "SECRETS_ENCRYPTION_KEY and GITHUB_PAT environment variables are required" ,
101100 ) ;
102101 }
103102
104103 const encryptedGitHubToken = encryptSecret ( githubPat , encryptionKey ) ;
105104
106105 const lgClient = createLangGraphClient ( {
107106 includeApiKey : true ,
108- defaultHeaders : {
107+ defaultHeaders : {
109108 [ GITHUB_PAT ] : encryptedGitHubToken ,
110- [ GITHUB_INSTALLATION_ID ] : githubInstallationId ,
111109 } ,
112110 } ) ;
113111
@@ -165,6 +163,10 @@ async function runOpenSWEWithStreamTracking(inputs: {
165163 plannerRun = await withRetry ( ( ) =>
166164 lgClient . runs . join ( plannerSession . threadId , plannerSession . runId ) ,
167165 ) ;
166+
167+ logger . info ( "Agent joined planner session" , {
168+ plannerSession,
169+ } ) ;
168170 } catch ( error ) {
169171 logger . error ( "Error joining planner run" , {
170172 thread_id : threadId ,
@@ -192,6 +194,10 @@ async function runOpenSWEWithStreamTracking(inputs: {
192194 return result ; // instead of skipping, we should award 0 points
193195 }
194196
197+ logger . info ( "Agent joined programmer session" , {
198+ programmerSession,
199+ } ) ;
200+
195201 let programmerRun ;
196202 try {
197203 programmerRun = await withRetry ( ( ) =>
@@ -231,8 +237,8 @@ async function runOpenSWEWithStreamTracking(inputs: {
231237 result . managerRunId = ( managerRun as any ) . run_id ;
232238 result . plannerRunId = plannerSession . runId ;
233239 result . programmerRunId = programmerSession . runId ;
240+ result . branchName = branchName ;
234241 result . success = true ;
235-
236242 } catch ( error ) {
237243 result . error = error instanceof Error ? error . message : String ( error ) ;
238244 logger . error ( "Open-swe stream tracking failed" , {
@@ -312,30 +318,28 @@ async function processPR(prData: PRData): Promise<PRProcessResult> {
312318 logger . info ( "Starting open-swe..." ) ;
313319 const openSWEResults = await runOpenSWEWithStreamTracking ( {
314320 repoOwner : prData . repoOwner ,
315- repoName : prData . repoName ,
321+ repoName : prData . repoName ,
316322 baseCommit : preMergeCommit ,
317323 userInput : createPRFixPrompt ( prData ) ,
318324 } ) ;
319325 result . openSWEResults = openSWEResults ;
320326
321- // Checkout test files from the merge commit to get the updated test files
322- if ( testFiles . length > 0 ) {
327+ // Only proceed with test checkout and execution if open-swe was successful and created a branch
328+ if (
329+ openSWEResults . success &&
330+ openSWEResults . branchName &&
331+ testFiles . length > 0
332+ ) {
323333 logger . info (
324- `Checking out test files from merge commit: ${ prData . mergeCommitSha } ` ,
334+ `Open-swe completed successfully with branch: ${ openSWEResults . branchName } . Checking out test files from merge commit: ${ prData . mergeCommitSha } ` ,
325335 ) ;
326336 await checkoutFilesFromCommit ( {
327337 sandbox,
328338 repoDir,
329339 commitSha : prData . mergeCommitSha ,
330340 filePaths : testFiles ,
331341 } ) ;
332- }
333342
334- // Run tests on detected test files
335- if ( testFiles . length > 0 ) {
336- logger . info (
337- `Running pytest on ${ testFiles . length } detected test files...` ,
338- ) ;
339343 const testResults = await runPytestOnFiles ( {
340344 sandbox,
341345 testFiles,
@@ -345,13 +349,24 @@ async function processPR(prData: PRData): Promise<PRProcessResult> {
345349 result . testResults = testResults ;
346350
347351 logger . info ( `Test execution completed for PR #${ prData . prNumber } ` , {
352+ branchName : openSWEResults . branchName ,
348353 totalTests : testResults . totalTests ,
349354 passedTests : testResults . passedTests ,
350355 failedTests : testResults . failedTests ,
351356 success : testResults . success ,
352357 } ) ;
353358 } else {
354- logger . info ( `No test files to run for PR #${ prData . prNumber } ` ) ;
359+ if ( ! openSWEResults . success ) {
360+ logger . info (
361+ `Open-swe failed for PR #${ prData . prNumber } , skipping test execution` ,
362+ ) ;
363+ } else if ( ! openSWEResults . branchName ) {
364+ logger . info (
365+ `No branch created by open-swe for PR #${ prData . prNumber } , skipping test execution` ,
366+ ) ;
367+ } else if ( testFiles . length === 0 ) {
368+ logger . info ( `No test files found for PR #${ prData . prNumber } ` ) ;
369+ }
355370 }
356371
357372 result . success = true ;
0 commit comments