-
Notifications
You must be signed in to change notification settings - Fork 600
feat(tools): add initial langchain_tool implementation in experimental #1434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat(tools): add initial langchain_tool implementation in experimental #1434
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
cagataycali
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review: LangChain Tool Integration
🎉 Great work on this PR, @dbschmigelski! This is a valuable addition that enables the LangChain ecosystem to work with Strands Agents.
What I like:
- Experimental namespace - Smart placement in
strands.experimental.toolssince the API may evolve - Lazy loading pattern - Proper handling of optional
langchain-coredependency via__getattr__ - Comprehensive testing - 426 lines of unit tests + 79 lines of integration tests
- Clear documentation - The PR description thoroughly explains the implementation approach
Observations:
-
Content type handling: As you mentioned, currently only string results are handled. For future iterations, consider:
- Image content → convert to base64 data or reference URI
- JSON content → serialize as structured content block
- Document content → handle as text with metadata
-
Error handling: Does the wrapper properly propagate LangChain tool exceptions? This would be good to verify in integration tests.
-
Async support: The PR mentions supporting async tools - would be helpful to have explicit tests demonstrating async tool invocation patterns.
Minor suggestion:
Consider adding a brief docstring example in the class showing the most common usage pattern:
from langchain_community.tools import WikipediaQueryRun
from strands import Agent
from strands.experimental.tools import LangChainTool
wiki_tool = LangChainTool(WikipediaQueryRun())
agent = Agent(tools=[wiki_tool])Overall: This is a well-thought-out implementation. The scaffolding approach makes sense - ship what works now, expand as needed. ✅
Reviewed by strands-coder 🦆
✅ Ready for Merge - LangChain IntegrationThis PR is ALL GREEN and brings valuable LangChain interoperability to Strands! Status✅ All 18 CI checks passing (Python 3.10-3.13, all platforms) What This AddsEnables users to use LangChain tools directly in Strands agents via
Why Experimental is RightThis is correctly placed in the experimental namespace, allowing:
Code Quality
Great work @dbschmigelski! This expands the ecosystem nicely. 🎉 🤖 This is an experimental AI agent response from the Strands team, powered by Strands Agents. We're exploring how AI agents can help with community support and development. Your feedback helps us improve! If you'd prefer human assistance, please let us know. |
Description
This PR introduces
LangChainTool, a wrapper that enables integration of LangChain tools with Strands Agents. The implementation lives instrands.experimental.toolsand allows users to wrap any LangChainBaseToolinstance for use with a Strands Agent.The wrapper accepts any LangChain tool variant since all LangChain tools inherit from
BaseTool. This includes tools created with the@tooldecorator (both sync and async),StructuredTool.from_function(), and customBaseToolsubclasses. The implementation extracts the tool's name, description, and input schema from the LangChain tool and converts them into a Strands-compatibleToolSpec. Users can optionally override the tool name and description if needed.Since
langchain-coreis an optional dependency, theLangChainToolclass uses a lazy loading pattern via__getattr__in the module's__init__.py. This ensures that users withoutlangchain-coreinstalled won't encounter import errors unless they explicitly try to useLangChainTool.. LangChain's TOOL_MESSAGE_BLOCK_TYPES includes additional content types like image, json, and document that may be added in future versions as needed. Currently, _convert_result_to_content only supports string results from LangChain tools. This clearly will not handle most use cases. But, what I want to do is have the scaffolding down, then we can expand the mappings as we go
As part of the review process I encourage everyone to pull this down and actually experiment.
Related Issues
N/A
Documentation PR
ToDo
Type of Change
New feature
Testing
The changes have been tested with both unit tests and integration tests covering all LangChain tool variants. All tests pass successfully.
hatch run prepareChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.