Open s97712 opened 3 months ago
currently everything must go through the reducer
Hi @s97712 would love to hear more about your use case. The ways I do it depend on the context.
type reduceOperation = {
action: "delete"
}
function reduceMessages(a?: BaseMessage[] , b?: BaseMessage[] | reduceOperation) -> BaseMessage[]{
if (b?.action === "delete") {
return []
}
return [...a, ...b];
}
const graphState: StateGraphArgs<IState>["channels"] = {
messages: {
reducer: (a, b) => [...a, ...b],
default: () => [],
},
history: {
reducer: (a, b) => [...a, ...b],
default: () => []
},
};
This is my state definition
I want to reset the
messages
after theagent
process, and put the output intohistory
.But after hours of hard work, I found that all the ways to set state go through the
reducer
, and I can't directly set state to a certain value.Can you provide a way to set the state without going through the'reducer ', so that we can reset the state?