fix(imports): replace ToolConfig with InterruptOnConfig for latest LangChain compatibility #163
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.
Contribution: LangChain HITL Compatibility Update
Author: Mudasir Shah
Date: October 13, 2025
PR Title:
fix: replace ToolConfig with InterruptOnConfig for latest LangChain compatibility
Branch:
fix/langchain-hitl-update
Summary
This contribution addresses a critical compatibility issue in the DeepAgents library by replacing the deprecated
ToolConfig
import withInterruptOnConfig
indeepagents/graph.py
. This change ensures compatibility with current LangChain middleware API releases and prevents import-time errors when using newer LangChain versions that no longer expose theToolConfig
class.Problem Statement
Recent LangChain API updates have renamed/refactored the Human-in-the-Loop (HITL) configuration architecture. The previous
ToolConfig
class has been deprecated and replaced withInterruptOnConfig
. Without this update, users encounterImportError
exceptions when attempting to create agents with tool interrupt configurations, breaking the functionality of the DeepAgents library with modern LangChain releases.Changes Implemented
1. Import Statement Update
Previous:
Updated:
2. Usage Updates
All instances where
ToolConfig(...)
was instantiated have been updated toInterruptOnConfig(...)
to maintain consistency with the new API.3. Files Modified
src/deepagents/graph.py
— Updated import statement and all usages of the configuration classTechnical Details
Backward Compatibility
This change is designed to be non-breaking and backward-compatible in terms of functionality. The behavior of the HITL middleware remains unchanged; only the class name has been updated to align with LangChain's current API.
Target Compatibility
This update targets LangChain releases that expose
InterruptOnConfig
in their middleware API. Users running supported LangChain versions will benefit from this change immediately.Validation & Testing
Automated Testing
The existing test suite can be executed to validate this change:
# From the repository root pytest -v
All existing tests should pass without modification, confirming that the change is functionally equivalent.
Manual Validation
create_deep_agent(..., tool_configs=...)
with HITL configurationImportError
exceptions occur during agent initializationReviewer Validation Steps
fix/langchain-hitl-update
branchpytest -v
from the repository roottool_configs
to exercise the HITL middlewareMotivation & Impact
Why This Change Matters
User Impact
This fix enables users to:
Optional Enhancement: Compatibility Shim
For maintainers who wish to preserve compatibility with older LangChain versions that only provide
ToolConfig
, a conditional import shim can be added:This approach would allow DeepAgents to work with both legacy and modern LangChain installations. This enhancement is available upon request.
Commit Message
Conclusion
This contribution represents a targeted, low-risk update that maintains DeepAgents' compatibility with the evolving LangChain ecosystem. The change has been carefully implemented to minimize code churn while maximizing compatibility with modern API standards.
Key Contributions:
I am happy to make any additional modifications or incorporate feedback from the maintainers to ensure this contribution meets the project's standards.
Signed-off-by: Mudasir Shah
Repository: deepagents