-
Notifications
You must be signed in to change notification settings - Fork 897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
langgraph.errors.InvalidUpdateError: Invalid update for channel medical with values #766
Comments
Hello @xtu-xiaoc - could you share what |
Has there been an answer to this? I have the same problem with the following GraphSate:
I have one conditional branch and the error message always displays that there was an invalid update for the first element of GraphState. So I'm assuming that a step is missing in the documentation where you join the two different states of GraphState back to one when the branch converges. |
try making a reducer for every single key |
I can try but in the documentation it says that if you don't make a reducer for a key it assumes that every new entry should overwrite the old one. |
I am >80% sure it will work. There is something about fan-ins that breaks default override behavior that I cannot explain in one sentence. |
You can just use something as dumb as |
Okay, creating a reducer for every key with your lambda-function worked. Thank you very much! |
@hinthornw I wonder if it is intended that fan-ins causes InvalidUpdateError when no reducer is provided. Basically the fan-in node receives everything at once and the type changes from T to list[T] |
I have a feeling that the fan-in step is generally a bit buggy. I have three nodes that converge now. One value in my state dict is a boolean and one of the nodes sets that boolean. After the nodes converge that value gets set to None because it isn't set in the other two nodes. |
that is just stable sorting no? |
you can also just... not rely on overriding and write a simple reducer |
I tried writing my own reducer but it never worked. I wrote a function that accepted three values and then returned the value that wasn't None. |
a function that accepts three values is just wrong. try lambda x, y: y if y is not None else x |
I wrote that function in the exact same logic as if you used operator.add, which takes two values (a, b) and returns a + b |
Checked other resources
Example Code
Error Message and Stack Trace (if applicable)
Description
I did some tests: I found that when chan='medical', after completing the mentor_pass task, len(vals)==2, which is the reason for the error.
If I force the switch
if chan== 'medical' and len(vals)>1:
vals= [vals[-1]]
It can run, but it will always loop in medical_mentor and medical_mentor_pass and cannot jump out of end. Why is this?
System Info
langgraph==0.0.66
The text was updated successfully, but these errors were encountered: