fix(langgraph): guard replace_state() against closed StateManager in execute()
CI / benchmark-publish (push) Has started running
CI / push-validation (push) Successful in 34s
CI / helm (push) Successful in 51s
CI / build (push) Successful in 1m4s
CI / lint (push) Successful in 1m24s
CI / typecheck (push) Successful in 1m39s
CI / quality (push) Successful in 1m42s
CI / security (push) Successful in 2m16s
CI / benchmark-regression (push) Has been skipped
CI / integration_tests (push) Successful in 4m45s
CI / e2e_tests (push) Failing after 5m33s
CI / unit_tests (push) Successful in 6m45s
CI / docker (push) Successful in 2m21s
CI / coverage (push) Successful in 16m15s
CI / status-check (push) Failing after 4s
CI / benchmark-publish (pull_request) Has been skipped
CI / benchmark-regression (pull_request) Failing after 1m0s
CI / status-check (pull_request) Successful in 6s
CI / helm (pull_request) Successful in 28s
CI / unit_tests (pull_request) Successful in 9m57s
CI / push-validation (pull_request) Successful in 24s
CI / typecheck (pull_request) Successful in 2m3s
CI / e2e_tests (pull_request) Successful in 3m32s
CI / security (pull_request) Successful in 2m12s
CI / docker (pull_request) Successful in 1m57s
CI / lint (pull_request) Successful in 46s
CI / quality (pull_request) Successful in 1m37s
CI / build (pull_request) Successful in 30s
CI / integration_tests (pull_request) Successful in 6m57s
CI / coverage (pull_request) Successful in 13m15s
CI / benchmark-publish (push) Has started running
CI / push-validation (push) Successful in 34s
CI / helm (push) Successful in 51s
CI / build (push) Successful in 1m4s
CI / lint (push) Successful in 1m24s
CI / typecheck (push) Successful in 1m39s
CI / quality (push) Successful in 1m42s
CI / security (push) Successful in 2m16s
CI / benchmark-regression (push) Has been skipped
CI / integration_tests (push) Successful in 4m45s
CI / e2e_tests (push) Failing after 5m33s
CI / unit_tests (push) Successful in 6m45s
CI / docker (push) Successful in 2m21s
CI / coverage (push) Successful in 16m15s
CI / status-check (push) Failing after 4s
CI / benchmark-publish (pull_request) Has been skipped
CI / benchmark-regression (pull_request) Failing after 1m0s
CI / status-check (pull_request) Successful in 6s
CI / helm (pull_request) Successful in 28s
CI / unit_tests (pull_request) Successful in 9m57s
CI / push-validation (pull_request) Successful in 24s
CI / typecheck (pull_request) Successful in 2m3s
CI / e2e_tests (pull_request) Successful in 3m32s
CI / security (pull_request) Successful in 2m12s
CI / docker (pull_request) Successful in 1m57s
CI / lint (pull_request) Successful in 46s
CI / quality (pull_request) Successful in 1m37s
CI / build (pull_request) Successful in 30s
CI / integration_tests (pull_request) Successful in 6m57s
CI / coverage (pull_request) Successful in 13m15s
Replace direct state assignment in LangGraph.execute() with state_manager.replace_state(), which enforces the is_closed guard and notifies state stream subscribers through the proper StateManager API, preventing silent state corruption after StateManager.close() is called. replace_state() is the semantically correct method for this use case: it atomically replaces the entire state for a fresh execution context, enforces the is_closed guard, and notifies subscribers. update_state() is designed for incremental updates with execution_count tracking, not for resetting state to a fresh execution context. Closes #9994
This commit was merged in pull request #10768.
This commit is contained in:
@@ -108,7 +108,9 @@ class LangGraph: # pylint: disable=too-many-instance-attributes
|
||||
if isinstance(input_data, GraphState)
|
||||
else GraphState.from_dict(input_data)
|
||||
)
|
||||
# Replace state manager state for a fresh execution context
|
||||
# Use replace_state() so the is_closed guard is enforced and state stream
|
||||
# subscribers are notified through the proper StateManager API, preventing
|
||||
# silent state corruption after StateManager.close() has been called.
|
||||
self.state_manager.replace_state(state)
|
||||
start_stream = f"__{self.name}_node_start__"
|
||||
if start_stream in self.stream_router.streams:
|
||||
|
||||
Reference in New Issue
Block a user