Skip to content

Commit 35705db

Browse files
committed
fix(sdk-python): update current_graph_state after manual emit to persist across iterations
The _merge_emit_state call merges emitted state with current_graph_state into manually_emitted_state, but the `continue` statement skips the later current_graph_state.update(updated_state). Without this update, the next manual emit merges against stale current_graph_state and loses keys from the previous emit. Also guards the update call against non-dict values from _merge_emit_state to prevent TypeError on edge-case non-dict emits.
1 parent a4171ec commit 35705db

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

sdk-python/copilotkit/langgraph_agent.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,8 @@ async def _stream_events( # pylint: disable=too-many-locals
436436

437437
if manually_emit_intermediate_state:
438438
manually_emitted_state = _merge_emit_state(current_graph_state, cast(Any, event["data"]))
439+
if isinstance(manually_emitted_state, dict):
440+
current_graph_state.update(manually_emitted_state)
439441
yield self._emit_state_sync_event(
440442
thread_id=thread_id,
441443
run_id=run_id,

0 commit comments

Comments
 (0)