[PR #5596] fix(langgraph): Use concrete types for StateLike validation #4543

Closed
opened 2026-02-20 17:50:21 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langchain-ai/langgraph/pull/5596

State: closed
Merged: No


Closes #32067

Description

This change updates the StateLike type alias in langgraph/typing.py to use only concrete, runtime-valid types (dict, BaseModel) rather than abstract protocols. This directly resolves runtime validation errors (such as SchemaError and isinstance checks) raised by Pydantic when tools are annotated with StateLike.

How to Test

A new regression test, test_tool_with_statelike_annotation_does_not_raise_error, has been added to libs/langgraph/tests/test_type_checking.py.
To verify, run:

pytest libs/langgraph/tests/test_type_checking.py -k 'statelike'
**Original Pull Request:** https://github.com/langchain-ai/langgraph/pull/5596 **State:** closed **Merged:** No --- Closes #32067 #### Description This change updates the `StateLike` type alias in `langgraph/typing.py` to use only concrete, runtime-valid types (`dict`, `BaseModel`) rather than abstract protocols. This directly resolves runtime validation errors (such as `SchemaError` and `isinstance` checks) raised by Pydantic when tools are annotated with `StateLike`. #### How to Test A new regression test, `test_tool_with_statelike_annotation_does_not_raise_error`, has been added to `libs/langgraph/tests/test_type_checking.py`. To verify, run: ```sh pytest libs/langgraph/tests/test_type_checking.py -k 'statelike'
yindo added the pull-request label 2026-02-20 17:50:21 -05:00
yindo closed this issue 2026-02-20 17:50:21 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#4543