@@ -16,18 +16,9 @@ const intentDiscoverInputSchema = z.object({
1616 source : z . enum ( [ 'schedule' , 'admin' ] ) . default ( 'schedule' ) ,
1717} )
1818
19- const PROCESS_WORKFLOW_DEFAULT_MAX_DURATION_MS = 4 * 60 * 1000
20- const PROCESS_WORKFLOW_MAX_DURATION_MS = 4 * 60 * 1000
21- const PROCESS_WORKFLOW_MIN_REMAINING_MS = 30_000
2219const PROCESS_WORKFLOW_SELECT_LIMIT = 50
2320
2421const intentProcessInputSchema = z . object ( {
25- maxDurationMs : z
26- . number ( )
27- . int ( )
28- . positive ( )
29- . max ( PROCESS_WORKFLOW_MAX_DURATION_MS )
30- . default ( PROCESS_WORKFLOW_DEFAULT_MAX_DURATION_MS ) ,
3122 source : z . enum ( [ 'schedule' , 'admin' ] ) . default ( 'schedule' ) ,
3223} )
3324
@@ -71,14 +62,11 @@ export function createIntentProcessWorkflow(
7162 id : INTENT_PROCESS_WORKFLOW_ID ,
7263 input : intentProcessInputSchema ,
7364 } ) . handler ( async ( ctx ) => {
74- const deadline = Date . now ( ) + ctx . input . maxDurationMs
7565 const attemptedIds = new Set < number > ( )
7666 const results : Array < IntentVersionProcessResult > = [ ]
77- let deferred = 0
7867 let selectIteration = 0
79- let shouldContinue = true
8068
81- while ( shouldContinue && hasProcessBudget ( deadline ) ) {
69+ while ( true ) {
8270 const versions = await ctx . step (
8371 `select-pending-versions:${ selectIteration } ` ,
8472 ( ) =>
@@ -97,14 +85,7 @@ export function createIntentProcessWorkflow(
9785 )
9886 if ( unattemptedVersions . length === 0 ) break
9987
100- for ( let index = 0 ; index < unattemptedVersions . length ; index ++ ) {
101- if ( ! hasProcessBudget ( deadline ) ) {
102- deferred += unattemptedVersions . length - index
103- shouldContinue = false
104- break
105- }
106-
107- const version = unattemptedVersions [ index ] !
88+ for ( const version of unattemptedVersions ) {
10889 attemptedIds . add ( version . id )
10990
11091 try {
@@ -128,7 +109,7 @@ export function createIntentProcessWorkflow(
128109 if ( versions . length < PROCESS_WORKFLOW_SELECT_LIMIT ) break
129110 }
130111
131- return summarizeIntentProcessResults ( results , { deferred } )
112+ return summarizeIntentProcessResults ( results )
132113 } )
133114}
134115
@@ -155,7 +136,6 @@ export const intentWorkflowRegistrations = {
155136 schedule : every . minutes ( 15 ) ,
156137 overlapPolicy : 'skip' ,
157138 input : {
158- maxDurationMs : PROCESS_WORKFLOW_DEFAULT_MAX_DURATION_MS ,
159139 source : 'schedule' ,
160140 } ,
161141 } ,
@@ -166,7 +146,3 @@ export const intentWorkflowRegistrations = {
166146function getErrorMessage ( error : unknown ) : string {
167147 return error instanceof Error ? error . message : String ( error )
168148}
169-
170- function hasProcessBudget ( deadline : number ) : boolean {
171- return Date . now ( ) + PROCESS_WORKFLOW_MIN_REMAINING_MS < deadline
172- }
0 commit comments