@@ -35,7 +35,8 @@ async function assembleReviewFixRequirements(
3535 hasConflicts : boolean ,
3636) {
3737 "use step" ;
38- const { assembleFixingFeedbackContext } = await import ( "../sandbox/context.js" ) ;
38+ const { assembleFixingFeedbackContext } =
39+ await import ( "../sandbox/context.js" ) ;
3940 const { getPrompt } = await import ( "../lib/prompts.js" ) ;
4041
4142 const prompt = getPrompt ( "review-fix.md" ) ;
@@ -56,7 +57,10 @@ async function assembleReviewFixRequirements(
5657async function runFixingAgentInSandbox (
5758 branchName : string ,
5859 requirementsMd : string ,
59- ) : Promise < { output : AgentOutput ; files : Array < { path : string ; content : string } > } > {
60+ ) : Promise < {
61+ output : AgentOutput ;
62+ files : Array < { path : string ; content : string } > ;
63+ } > {
6064 "use step" ;
6165 const { env } = await import ( "../../env.js" ) ;
6266 const { SandboxManager } = await import ( "../sandbox/manager.js" ) ;
@@ -77,7 +81,12 @@ async function runFixingAgentInSandbox(
7781 } ) ;
7882
7983 const sandbox = await manager . provision ( branchName , requirementsMd ) ;
80- return runAgent ( { sandbox, manager, model : env . CLAUDE_MODEL , debug : env . DEBUG_AGENT } ) ;
84+ return runAgent ( {
85+ sandbox,
86+ manager,
87+ model : env . CLAUDE_MODEL ,
88+ debug : env . DEBUG_AGENT ,
89+ } ) ;
8190}
8291
8392async function pushChanges (
@@ -114,18 +123,17 @@ async function unregisterRun(ticketIdentifier: string) {
114123
115124// --- Workflow ---
116125
117- export async function reviewFixWorkflow (
118- ticketId : string ,
119- branchName : string ,
120- ) {
126+ export async function reviewFixWorkflow ( ticketId : string , branchName : string ) {
121127 "use workflow" ;
122128
123129 const { env } = await import ( "../../env.js" ) ;
124130
125131 const ticket = await fetchAndValidateTicket ( ticketId , env . COLUMN_AI ) ;
126132 if ( ! ticket ) return ;
127133
128- await notifySlack ( `Task ${ ticket . identifier } started — fixing review feedback` ) ;
134+ await notifySlack (
135+ `Task ${ ticket . identifier } started — fixing review feedback` ,
136+ ) ;
129137
130138 const { pr, comments, hasConflicts } = await fetchPRContext ( branchName ) ;
131139
@@ -135,18 +143,36 @@ export async function reviewFixWorkflow(
135143 hasConflicts ,
136144 ) ;
137145
138- const { output, files } = await runFixingAgentInSandbox ( branchName , requirementsMd ) ;
146+ let output : AgentOutput ;
147+ let files : Array < { path : string ; content : string } > ;
148+ try {
149+ ( { output, files } = await runFixingAgentInSandbox (
150+ branchName ,
151+ requirementsMd ,
152+ ) ) ;
153+ } catch ( err ) {
154+ await moveTicket ( ticketId , env . COLUMN_BACKLOG ) ;
155+ await notifySlack (
156+ `Task ${ ticket . identifier } sandbox error: ${ ( err as Error ) . message ?? "unknown" } ` ,
157+ ) ;
158+ await unregisterRun ( ticket . identifier ) ;
159+ throw err ;
160+ }
139161
140162 await pushChanges ( branchName , files ) ;
141163
142164 if ( output . result === "implemented" ) {
143165 await moveTicket ( ticketId , env . COLUMN_AI_REVIEW ) ;
144- await notifySlack ( `Task ${ ticket . identifier } fixes applied, ready for re-review` ) ;
166+ await notifySlack (
167+ `Task ${ ticket . identifier } fixes applied, ready for re-review` ,
168+ ) ;
145169 await unregisterRun ( ticket . identifier ) ;
146170 return ;
147171 }
148172
149- await notifySlack ( `Task ${ ticket . identifier } review-fix failed: ${ output . error ?? "unknown error" } ` ) ;
173+ await moveTicket ( ticketId , env . COLUMN_BACKLOG ) ;
174+ await notifySlack (
175+ `Task ${ ticket . identifier } review-fix failed: ${ output . error ?? "unknown error" } ` ,
176+ ) ;
150177 await unregisterRun ( ticket . identifier ) ;
151- throw new Error ( `Agent failed for ${ ticketId } : ${ output . error } ` ) ;
152178}
0 commit comments