How can I create “time-travel” checkpoints for each message in a LangGraph + FastAPI SSE chat app? #5507
Unanswered
jamesheavey
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.
-
Background
Goal
For every message in the conversation I’d like to save a checkpoint ID that represents the state of the LangGraph before that message is processed.
That would let a user “rewind” (e.g., re-phrase an earlier question, or rerun an agent response) by resetting the graph state to the chosen checkpoint and replaying from there.
Current Idea
Emit two custom events from LangGraph for each turn
I think this might be possible with
get_state_history()
but it seems quite clunky.Questions
An alternative I could try would be to only checkpoint the agent response messages and have the checkpoints represent successful messages. This is less clean in the frontend, but might be much cleaner in the backend.
Does LangGraph expose a “initial / empty” checkpoint so I can reset the thread to a clean slate (useful when the very first user message is edited)?
Are there alternative patterns (e.g., storing deltas, replaying events, database snapshots) that would achieve the same “editable history” UX with less complexity?
Any pointers, best-practice links, or code samples would be hugely appreciated!
Beta Was this translation helpful? Give feedback.
All reactions