agents icon indicating copy to clipboard operation
agents copied to clipboard

Can onStateUpdate include the prev state?

Open kchro3 opened this issue 5 months ago • 1 comments

I have a case where I'd like to handle specific types of updates, so if the state is an object, i want to handle a change to a field.

However, I think I need access to the previous state in order to see if the field had changed.

Proposed:

  onStateUpdate(state: State | undefined, prevState: State | undefined, source: Connection | "server") {
    if (state?.field !== prevState?.state) {
      // do something
    }
  }

kchro3 avatar May 12 '25 22:05 kchro3