Skip to content

Commit cacb952

Browse files
authored
Merge pull request #292 from ag-ui-protocol/fix/include-payload-with-regenerated-message
fix: include payload with regenerated message
2 parents 8de46a4 + 0c693a6 commit cacb952

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,15 @@ 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]
692+
693+
merged_values = {**checkpoint.values, **snapshot_values_without_messages}
694+
checkpoint = checkpoint._replace(values=merged_values)
695+
696+
return checkpoint
689697

690698
raise ValueError("Message ID not found in history")
691699

typescript-sdk/integrations/langgraph/python/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "ag-ui-langgraph"
3-
version = "0.0.5"
3+
version = "0.0.6"
44
description = "Implementation of the AG-UI protocol for LangGraph."
55
authors = ["Ran Shem Tov <[email protected]>"]
66
readme = "README.md"

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)