Skip to content

Commit aeda92e

Browse files
committed
fix(langgraph): include the payload with the original user message that is going to be regenerated
1 parent 393d3d0 commit aeda92e

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

typescript-sdk/integrations/langgraph/python/ag_ui_langgraph/agent.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,12 @@ async def get_checkpoint_before_message(self, message_id: str, thread_id: str):
685685
empty_snapshot = snapshot
686686
empty_snapshot.values["messages"] = []
687687
return empty_snapshot
688-
return history_list[idx - 1] # return one snapshot *before* the one that includes the message
688+
689+
snapshot_values_without_messages = snapshot.values.copy()
690+
del snapshot_values_without_messages["messages"]
691+
checkpoint = history_list[idx - 1] # use one snapshot *before* the one that includes the message
692+
checkpoint.values = {**checkpoint.values, **snapshot_values_without_messages}
693+
return checkpoint
689694

690695
raise ValueError("Message ID not found in history")
691696

typescript-sdk/integrations/langgraph/src/agent.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,9 @@ export class LangGraphAgent extends AbstractAgent {
992992

993993
const targetStateIndex = reversed.indexOf(targetState);
994994

995-
return reversed[targetStateIndex - 1] ?? { ...targetState, values: {} };
995+
const { messages, ...targetStateValuesWithoutMessages } = targetState.values as State
996+
const selectedCheckpoint = reversed[targetStateIndex - 1] ?? { ...targetState, values: {} }
997+
return { ...selectedCheckpoint, values: { ...selectedCheckpoint.values, ...targetStateValuesWithoutMessages } };
996998
}
997999
}
9981000

0 commit comments

Comments
 (0)