langgraph
langgraph copied to clipboard
use update_state,the state change,but event not show latest message
Checked other resources
- [X] I added a very descriptive title to this issue.
- [X] I searched the LangGraph/LangChain documentation with the integrated search.
- [X] I used the GitHub search to find a similar question and didn't find it.
- [x] I am sure that this is a bug in LangGraph/LangChain rather than my code.
- [ ] I am sure this is better as an issue rather than a GitHub discussion, since this is a LangGraph bug and not a design question.
Example Code
def should_continue(data, config):
messages = data["messages"]
last_message = messages[-1]
action = ReActFormatParser().parse(last_message.content)
if isinstance(action, AgentFinish):
msg = action.return_values["output"]
new_message = AIMessage(content=msg, id=last_message.id)
app.update_state(config, {"messages": [new_message]})
return "end"
# Otherwise, an AgentAction is returned
# Here we return `continue` string
# This will be used when setting up the graph to define the flow
else:
return "continue"
Error Message and Stack Trace (if applicable)
new_message is update, but in this code :
elif event["event"] == "on_chain_end" and event["run_id"] == root_run_id:
messages = event.get("data", {}).get('output', {}).get('messages', [])
if len(messages) > 1:
msg = messages[-1]
if isinstance(msg, AIMessage):
last_messages_list.append(msg)
message_info = MessageStreamDetail(id=root_run_id,
message=last_messages_list[-1],
type="final")
return message_info, root_run_id, last_messages_list, last_stream_run_id
the message not the latest.
Description
I hope the message is the latest
System Info
langchain = "==0.2.3" langgraph = "==0.0.66"