Pydantic Validation Problem with RemoveMessage in AnyMessage Tagged Union #3212
Unanswered
maxence-oden
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Description
I am encountering a validation issue when using
RemoveMessage
with theAnyMessage
Pydantic tagged union in the context of a StateGraph. Specifically, I want to includeRemoveMessage
as part of the messages field in my state object, butRemoveMessage
is not tagged withinAnyMessage
. This leads to validation problems.Here is a minimal reproducible example of the behavior I am trying to achieve:
Problem
When I try to return
RemoveMessage
in thenode
function, I get the following validation error:I understand that
RemoveMessage
is not currently tagged in theAnyMessage
union. However, this limitation makes it harder to work withRemoveMessage
in use cases where Pydantic objects are required.Questions
RemoveMessage
in theAnyMessage
union in the future?RemoveMessage
fromAnyMessage
intentional because it’s primarily used with the add_messages function?RemoveMessage
into theAnyMessage
union or to work around this limitation?Additional Context
Here is the version information for the relevant packages:
langgraph: 0.2.67
I’d appreciate any insights or clarification on whether this behavior is intentional or if support for
RemoveMessage
inAnyMessage
might be added. Thank you!Beta Was this translation helpful? Give feedback.
All reactions