Proposal: optimize syntax expression of AgentState of LangGraph #20420
Undertone0809
announced in
Ideas
Replies: 2 comments
-
@nfcampos @hinthornw @hwaking @rlancemartin @baskaryan Hey, how about this suggestion, looking forward to your reply~ |
Beta Was this translation helpful? Give feedback.
0 replies
-
hi, thanks for this, this is actually already possible today, you can already use a pydantic base model as your state object, see example here https://github.com/langchain-ai/langgraph/blob/main/examples/state-model.ipynb |
Beta Was this translation helpful? Give feedback.
0 replies
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.
Uh oh!
There was an error while loading. Please reload this page.
-
Checked
Feature request
Currently, AgentState is just a normal dict, which means that there are no attribute restrictions, and if the system is complex, each node returns a different field, which is difficult to maintain.
An AgentState like this:
Refer to the implementation of AgentProtocol. In AgentProtocol, each step is processed by passing a step into the function. After changing the step, a step is returned.
In the Step, the AgentProtocol can store some intermediate data of the step, which can be equivalent to the AgentState of each node in the LangGraph. According to this notation, we can define a node function in the following way:
Motivation
Currently, AgentState is just a normal dict, which means that there are no attribute restrictions, and if the system is complex, each node returns a different field, which is difficult to maintain.
Proposal (If applicable)
The proposal is to create a class that inherits from dict, and that has a fixed set of attributes, and that the system can only return these attributes.
Original Usage:
Optimized Usage:
Other
Beta Was this translation helpful? Give feedback.
All reactions