From c912c99b4c3e4a6abd4f08ea6306201f3fbb95ea Mon Sep 17 00:00:00 2001 From: ran Date: Wed, 16 Jul 2025 13:59:06 +0200 Subject: [PATCH] fix: emit the manual state when manually emit state event is discovered --- .../integrations/langgraph/python/ag_ui_langgraph/agent.py | 2 +- typescript-sdk/integrations/langgraph/src/agent.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript-sdk/integrations/langgraph/python/ag_ui_langgraph/agent.py b/typescript-sdk/integrations/langgraph/python/ag_ui_langgraph/agent.py index 310a85436..ada84d429 100644 --- a/typescript-sdk/integrations/langgraph/python/ag_ui_langgraph/agent.py +++ b/typescript-sdk/integrations/langgraph/python/ag_ui_langgraph/agent.py @@ -602,7 +602,7 @@ async def _handle_single_event(self, event: Any, state: State) -> AsyncGenerator elif event["name"] == CustomEventNames.ManuallyEmitState: self.active_run["manually_emitted_state"] = event["data"] yield self._dispatch_event( - StateSnapshotEvent(type=EventType.STATE_SNAPSHOT, snapshot=self.get_state_snapshot(state), raw_event=event) + StateSnapshotEvent(type=EventType.STATE_SNAPSHOT, snapshot=self.get_state_snapshot(self.active_run["manually_emitted_state"]), raw_event=event) ) yield self._dispatch_event( diff --git a/typescript-sdk/integrations/langgraph/src/agent.ts b/typescript-sdk/integrations/langgraph/src/agent.ts index ec61999ca..b0ddb474c 100644 --- a/typescript-sdk/integrations/langgraph/src/agent.ts +++ b/typescript-sdk/integrations/langgraph/src/agent.ts @@ -609,7 +609,7 @@ export class LangGraphAgent extends AbstractAgent { this.activeRun!.manuallyEmittedState = event.data; this.dispatchEvent({ type: EventType.STATE_SNAPSHOT, - snapshot: this.getStateSnapshot(state), + snapshot: this.getStateSnapshot(this.activeRun!.manuallyEmittedState!), rawEvent: event, }); }