@@ -115,7 +115,6 @@ def worker():
115115 return worker_thread
116116
117117
118- @debug_saver .capture ("notify" ) if debug_saver else lambda x : x
119118def notify (metadata , message : Response ):
120119 """Callback to receive notifications from the graph."""
121120 global task_queue , session_manager
@@ -272,14 +271,16 @@ def handle_message(data):
272271
273272 # If in replay mode, trigger replay with current session
274273 global debug_saver
275- if debug_saver and debug_saver .mode == "replay" :
276- debug_saver .start_replay_session (message .strip (), current_metadata )
277- return
274+ if debug_saver :
275+ if debug_saver .mode == "replay" :
276+ debug_saver .start_replay_session (message .strip (), current_metadata )
277+ return
278+ else :
279+ debug_saver .save_prompt (session_id , message .strip ())
278280
279281 # Update session timestamp on activity
280282 session_manager .update_session_timestamp (session_id )
281283
282- @debug_saver .capture ("notify_planai" ) if debug_saver else lambda x : x
283284 def wrapped_notify_planai (* args , ** kwargs ):
284285 return notify_planai (* args , ** kwargs )
285286
@@ -295,7 +296,6 @@ def wrapped_notify_planai(*args, **kwargs):
295296 session_metadata ["provenance" ] = provenance
296297
297298
298- @debug_saver .capture ("notify_planai" ) if debug_saver else lambda x : x
299299def notify_planai (
300300 metadata : Dict [str , Any ],
301301 prefix : ProvenanceChain ,
@@ -312,7 +312,7 @@ def notify_planai(
312312 global session_manager
313313 # get the metadata for this session
314314 session_metadata = session_manager .metadata (session_id )
315- if session_metadata .get ("started" ):
315+ if session_metadata .get ("started" ) and False : # ignore for now
316316 # this indicates that we failed the task
317317 task_queue .put (
318318 (
@@ -360,6 +360,14 @@ def notify_planai(
360360 )
361361
362362
363+ def patch_notify_functions ():
364+ """Patch the notify functions with debug_saver decorators."""
365+ global notify , notify_planai , debug_saver
366+ if debug_saver :
367+ notify = debug_saver .capture ("notify" )(notify )
368+ notify_planai = debug_saver .capture ("notify_planai" )(notify_planai )
369+
370+
363371def main ():
364372 import argparse
365373
@@ -386,6 +394,9 @@ def main():
386394 replay_delay = args .replay_delay ,
387395 )
388396
397+ # Patch the notify functions after debug_saver is initialized
398+ patch_notify_functions ()
399+
389400 if args .replay :
390401 # Register the original functions for replay
391402 debug_saver .register_replay_handler ("notify" , notify )
0 commit comments