genkit icon indicating copy to clipboard operation
genkit copied to clipboard

Feature request: session updateState should patch the state instead of replace

Open pavelgj opened this issue 1 year ago • 1 comments

Description

Currently there's inconsistent behavior when using updateState(). When updating a single property, it appears to replace the entire state object rather than patching it:

console.log(session.state) 
// { userName: 'God', colour: 'Green' }

async (input) => {
  ai.currentSession().updateState({ 
    colour: input.colour,
  });
  return `colour updated to ${input.colour}`;
}

console.log(session.state)
// { colour: 'Green' }  // userName was cleared

The current workaround is to manually spread the existing state:

async (input) => {
  ai.currentSession().updateState({
    ...ai.currentSession().state,
    userName: input.userName,
  });
}

It should be changed to patch

pavelgj avatar Dec 02 '24 15:12 pavelgj

Firebase is restricting my incoming messages on my device. I want this to stop asap. I have disabled my accounts from firebase. Why is this feature yet working. Please stop!!! I want all notification and messages capabilities on device. I don't need nor do I want any account protection

ghost avatar Jan 08 '25 01:01 ghost