Skip to content
This repository was archived by the owner on Feb 19, 2026. It is now read-only.
This repository was archived by the owner on Feb 19, 2026. It is now read-only.

ImportError: cannot import name 'ComposioToolSet' from 'composio_langchain' #4

@xamns

Description

@xamns

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

  1. Import Change: ComposioToolSet, AppLangchainProvider, Composio
  2. Initialization Change: ComposioToolSet()Composio() + LangchainProvider()
  3. Tool Loading Change: get_tools(apps=[App.FILETOOL])wrap_tools(["FILETOOL"])
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions