[PR #6509] fix(prebuilt): support generic type arguments for ToolRuntime injection #5084

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

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

State: closed
Merged: Yes


Description:
This PR fixes an issue where injection types (like ToolRuntime) were not recognized by ToolNode when used with generic type arguments (e.g., ToolRuntime[MyContext]).

Previously, the _is_injection check relied solely on isinstance and issubclass, which fail for typing._GenericAlias objects. This update adds a check using typing.get_origin() to correctly identify the base class of generic types, ensuring the runtime is injected correctly even when type hints are present.

Issue: Fixes #6465

Dependencies: None

Twitter handle: @SidharthRajmoh2

**Original Pull Request:** https://github.com/langchain-ai/langgraph/pull/6509 **State:** closed **Merged:** Yes --- **Description:** This PR fixes an issue where injection types (like `ToolRuntime`) were not recognized by `ToolNode` when used with generic type arguments (e.g., `ToolRuntime[MyContext]`). Previously, the `_is_injection` check relied solely on `isinstance` and `issubclass`, which fail for `typing._GenericAlias` objects. This update adds a check using `typing.get_origin()` to correctly identify the base class of generic types, ensuring the runtime is injected correctly even when type hints are present. **Issue:** Fixes #6465 **Dependencies:** None **Twitter handle:** @SidharthRajmoh2
yindo added the pull-request label 2026-02-20 17:51:12 -05:00
yindo closed this issue 2026-02-20 17:51:12 -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#5084