Description: When setting pr.settings.memory_profile = True, the program crashes. This appears to happen because the memory profiler attempts to run the reasoning process multiple times (once for execution, once for profiling) without resetting the graph state in between.
As a result, the second internal run leads to logical inconsistencies or index errors depending on the initial conditions.
Steps to Reproduce:
- Create a simple PyReason script.
- Enable the memory profile setting: pr.settings.memory_profile = True.
- Run pr.reason().
Expected Behavior: The program should profile memory usage without altering the logical flow or crashing. The profiler should implicitly call reset() or isolate the profiling run so it does not conflict with the main execution state.
Actual Behavior: pr.reason() executes multiple times, leading to loss of any coherent output.