useProcessMemory

useProcessMemory

The useProcessMemory hook returns a local memory container as a way to persist information outside the WorkingMemory across invocations of a MentalProcess.

exampleProcess.ts
import { useProcessMemory } from "@opensouls/engine"
 
const exampleProcess: MentalProcess = async ({ workingMemory }) => {
  // create a persistent memory container scoped to this mental process
  const wasProvoked = useProcessMemory(false)
 
  console.log("current value of wasProvoked", wasProvoked.current)
 
  // set the current value immediately
  wasProvoked.current = true
 
  // do other stuff ...
 
  return workingMemory
}
 
export default exampleProcess
ℹ️

Process memories persist while a MentalProcess is continually invoked, but reset when the process changes.