Fix ComposioToolSet ImportError in Latest Version
Issue
Hello Team, I discovered this issue
In the latest version of composio-langchain, ComposioToolSet has been deprecated, causing the following error:
ImportError: cannot import name 'ComposioToolSet' from 'composio_langchain'
Solution
Original Code (❌ Broken)
from composio_langchain import ComposioToolSet, App
class GrokAgent:
def __init__(self, api_key, model="grok-4-0709", base_url="https://api.x.ai/v1"):
self.llm = ChatOpenAI(
api_key=api_key,
model=model,
base_url=base_url,
temperature=0.7,
max_tokens=1000
)
self.composio_toolset = ComposioToolSet()
self.tools = self.composio_toolset.get_tools(apps=[App.FILETOOL])
Fixed Code (✅ Working)
from composio_langchain import LangchainProvider
from composio import Composio
class GrokAgent:
def __init__(self, api_key, model="grok-4-0709", base_url="https://api.x.ai/v1"):
self.llm = ChatOpenAI(
api_key=api_key,
model=model,
base_url=base_url,
temperature=0.7,
max_tokens=1000
)
# Use new Composio API
self.composio_client = Composio()
self.langchain_provider = LangchainProvider()
# Get file tools - using new approach
try:
# Try to use FILETOOL or similar tools
self.tools = self.langchain_provider.wrap_tools(["FILETOOL"])
except Exception as e:
print(f"Warning: Could not load FILETOOL, trying alternatives: {e}")
try:
# Try other possible tool names
self.tools = self.langchain_provider.wrap_tools(["FILE"])
except Exception as e2:
print(f"Warning: Could not load FILE tool either: {e2}")
# If all fail, use empty tool list
self.tools = []
Key Changes
- Import Change:
ComposioToolSet, App → LangchainProvider, Composio
- Initialization Change:
ComposioToolSet() → Composio() + LangchainProvider()
- Tool Loading Change:
get_tools(apps=[App.FILETOOL]) → wrap_tools(["FILETOOL"])
- Error Handling: Added try-catch blocks to handle tool name changes
Tested Environment
- Raspberry Pi 4 (ARM64 Linux)
- Latest composio-langchain version
This fix maintains the original functionality while being compatible with the new API structure.
Note: I discovered this issue while testing on my platform and created this fix for reference. If there are any improvements or issues with this approach, please let me know. Thank you!
Suggested Issue Title
[Bug] ComposioToolSet ImportError - Migration needed for latest composio-langchain
Quick Issue Description
The current code uses deprecated `ComposioToolSet` which causes ImportError in latest composio-langchain.
**Error**: `ImportError: cannot import name 'ComposioToolSet' from 'composio_langchain'`
**Fix**: Replace with `LangchainProvider` + `Composio` as shown above.
**Environment**: Raspberry Pi 4, latest composio-langchain
I discovered this issue during testing on my platform and created this fix for reference.
If there are any improvements or issues with this approach, please let me know. Thank you!
Happy to submit a PR with the fix if needed.
Fix ComposioToolSet ImportError in Latest Version
Issue
Hello Team, I discovered this issue
In the latest version of
composio-langchain,ComposioToolSethas been deprecated, causing the following error:Solution
Original Code (❌ Broken)
Fixed Code (✅ Working)
Key Changes
ComposioToolSet, App→LangchainProvider, ComposioComposioToolSet()→Composio()+LangchainProvider()get_tools(apps=[App.FILETOOL])→wrap_tools(["FILETOOL"])Tested Environment
This fix maintains the original functionality while being compatible with the new API structure.
Note: I discovered this issue while testing on my platform and created this fix for reference. If there are any improvements or issues with this approach, please let me know. Thank you!
Suggested Issue Title
[Bug] ComposioToolSet ImportError - Migration needed for latest composio-langchainQuick Issue Description