Skip to content

Conversation

@dbschmigelski
Copy link
Member

Description

This PR introduces LangChainTool, a wrapper that enables integration of LangChain tools with Strands Agents. The implementation lives in strands.experimental.tools and allows users to wrap any LangChain BaseTool instance 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 @tool decorator (both sync and async), StructuredTool.from_function(), and custom BaseTool subclasses. The implementation extracts the tool's name, description, and input schema from the LangChain tool and converts them into a Strands-compatible ToolSpec. Users can optionally override the tool name and description if needed.

Since langchain-core is an optional dependency, the LangChainTool class uses a lazy loading pattern via __getattr__ in the module's __init__.py. This ensures that users without langchain-core installed won't encounter import errors unless they explicitly try to use LangChainTool.

. 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.

  • I ran hatch run prepare

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov
Copy link

codecov bot commented Jan 7, 2026

Codecov Report

❌ Patch coverage is 90.47619% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/strands/experimental/tools/langchain_tool.py 92.98% 2 Missing and 2 partials ⚠️
src/strands/experimental/tools/__init__.py 66.66% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@dbschmigelski dbschmigelski marked this pull request as ready for review January 7, 2026 18:17
Copy link
Member

@cagataycali cagataycali left a 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:

  1. Experimental namespace - Smart placement in strands.experimental.tools since the API may evolve
  2. Lazy loading pattern - Proper handling of optional langchain-core dependency via __getattr__
  3. Comprehensive testing - 426 lines of unit tests + 79 lines of integration tests
  4. Clear documentation - The PR description thoroughly explains the implementation approach

Observations:

  1. 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
  2. Error handling: Does the wrapper properly propagate LangChain tool exceptions? This would be good to verify in integration tests.

  3. 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 🦆

@strands-agent
Copy link
Contributor

✅ Ready for Merge - LangChain Integration

This PR is ALL GREEN and brings valuable LangChain interoperability to Strands!

Status

All 18 CI checks passing (Python 3.10-3.13, all platforms)
Approved (by me - strands-coder)
90.5% test coverage (codecov green)
check-api passed (no breaking changes)

What This Adds

Enables users to use LangChain tools directly in Strands agents via experimental.tools.langchain_tool:

  • Wraps LangChain tools in Strands' tool interface
  • Preserves tool metadata and schemas
  • Handles async/sync execution
  • Added to experimental namespace (appropriate for new integrations)

Why Experimental is Right

This is correctly placed in the experimental namespace, allowing:

  • Community feedback on the API
  • Iteration without breaking changes
  • Validation of the integration pattern

Code Quality

  • Clean implementation with proper error handling
  • Comprehensive tests
  • Well-documented with examples

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants