File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1124,6 +1124,12 @@ export const OpenClawSchema = z
11241124 )
11251125 . optional ( ) ,
11261126 proxy : ProxyConfigSchema ,
1127+ trajectory : z
1128+ . object ( {
1129+ flushTimeoutMs : z . number ( ) . int ( ) . positive ( ) . optional ( ) ,
1130+ } )
1131+ . strict ( )
1132+ . optional ( ) ,
11271133 } )
11281134 . strict ( )
11291135 . superRefine ( ( cfg , ctx ) => {
Original file line number Diff line number Diff line change @@ -47,10 +47,7 @@ type TrajectoryRuntimeInit = {
4747 * 2. env.OPENCLAW_TRAJECTORY_FLUSH_TIMEOUT_MS
4848 * 3. undefined (no periodic flush)
4949 */
50- function resolveFlushTimeoutMs (
51- cfg ?: OpenClawConfig ,
52- env ?: NodeJS . ProcessEnv ,
53- ) : number | undefined {
50+ function resolveFlushTimeoutMs ( cfg ?: OpenClawConfig , env ?: NodeJS . ProcessEnv ) : number | undefined {
5451 const cfgValue = cfg ?. trajectory ?. flushTimeoutMs ;
5552 if ( typeof cfgValue === "number" && cfgValue > 0 ) {
5653 return cfgValue ;
@@ -390,11 +387,8 @@ export function createTrajectoryRuntimeRecorder(
390387 }
391388 writeBoundedLine ( line , { reserveSentinel : true } ) ;
392389
393- // Reschedule periodic flush on new events.
394- if ( flushTimeoutMs !== undefined ) {
395- cancelFlushTimer ( ) ;
396- scheduleFlush ( ) ;
397- }
390+ // Do NOT reschedule on each event — timer runs independently once started.
391+ // scheduleFlush() is called once at initialization.
398392 } ,
399393 flush : async ( ) => {
400394 // Cancel any pending periodic flush.
@@ -417,10 +411,7 @@ export function createTrajectoryRuntimeRecorder(
417411 if ( ! params . writer ) {
418412 writers . delete ( filePath ) ;
419413 }
420-
421- // Reschedule periodic flush if enabled.
422- lastFlushTime = Date . now ( ) ;
423- scheduleFlush ( ) ;
414+ // Timer already cancelled above; do not reschedule after final flush.
424415 } ,
425416 } ;
426417}
You can’t perform that action at this time.
0 commit comments