fix(prebuilt): support generic type arguments for ToolRuntime injection#6509
Merged
Sydney Runkle (sydney-runkle) merged 5 commits intoJan 12, 2026
Merged
Conversation
|
Sidharth Rajmohan (@dumko2001) is attempting to deploy a commit to the LangChain Team on Vercel. A member of the Team first needs to authorize it. |
4 tasks
8abcea9 to
29f4d21
Compare
Sydney Runkle (sydney-runkle)
approved these changes
Jan 12, 2026
Sydney Runkle (sydney-runkle)
left a comment
Collaborator
There was a problem hiding this comment.
Thanks so much. This is consistent w/ the logic we have for checking the origin in langchain-core as well.
It's actually a bit odd that these functions aren't unified.
cb2faa7
into
langchain-ai:main
56 checks passed
Contributor
Author
xingshuozhu1998
pushed a commit
to xingshuozhu1998/langgraph
that referenced
this pull request
May 1, 2026
…on (langchain-ai#6509) **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 langchain-ai#6465 **Dependencies:** None **Twitter handle:** @SidharthRajmoh2 --------- Co-authored-by: Sydney Runkle <54324534+sydney-runkle@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
This PR fixes an issue where injection types (like
ToolRuntime) were not recognized byToolNodewhen used with generic type arguments (e.g.,ToolRuntime[MyContext]).Previously, the
_is_injectioncheck relied solely onisinstanceandissubclass, which fail fortyping._GenericAliasobjects. This update adds a check usingtyping.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