> ## Documentation Index
> Fetch the complete documentation index at: https://composio-27-feat-docs-revamp.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 🛠️ What are Tools & Actions?

> Learn about tools in Composio

### What are tools?

Large Language Models (LLMs) are like a highly intelligent person who can understand and reason about almost anything but is sitting in an empty room with no ability to interact with the outside world. They can think and talk about sending emails, creating a ticket on Jira, or cloning a repository from GitHub, but can't actually DO these things.

This is where tools come in. Tools give this intelligent being specific abilities to interact with the real world. Many AI models support tool calling (also called function calling).

<Note>
  The term **tools** and **actions** are used interchangeably in the documentation
</Note>

### How tool calling works

AI models with tool calling capabilities decide when and how to use specific tools to meet user requests. Developers create and provide these tools, equipping the AI with a toolbox to select the best tool for each task

For example, if a user asks an LLM to send an email to `john@example.com` with subject `Meeting Tomorrow`, the LLM can use the [Gmail](https://app.composio.dev/app/gmail) tool's `GMAIL_SEND_EMAIL` action to send the email.

LLM's thinking process:

1. Recognizes this requires email sending capability
2. Identifies the appropriate tool ([Gmail](https://app.composio.dev/app/gmail)) & action (`GMAIL_SEND_EMAIL`)
3. Structures the necessary parameters:
   * recipient: [john@example.com](mailto:john@example.com)
   * subject: "Meeting Tomorrow"
   * body: \[drafts appropriate content]
4. Calls the action with these parameters

### Tool calling with Composio

At Composio, tools are offered for multiple platforms, accessible via Python and JavaScript SDKs. These platforms, referred to as **Apps** or **Tools**, include popular services like GitHub, Twitter, Salesforce, Jira, and Notion. Within each of these Apps, we provide **Actions**, which are essentially functions that can be executed. For example, you can send an email on Gmail, star a repository on GitHub, or create an issue on Jira. These tools can also be used directly, similar to function calls, without needing agents.

<Tabs>
  <Tab title="Python">
    Use the `ComposioToolSet` class to use and configure tools:

    * Use [composio-core](https://pypi.org/project/composio-core) package for non-agentic use cases
    * Use framework-specific packages [composio-langchain](https://pypi.org/project/composio-langchain) or [composio-crewai](https://pypi.org/project/composio-crewai) when working with Agentic frameworks

    See all supported frameworks [here](../../framework/autogen).

    ### Arguments Accepted by ComposioToolSet

    #### Basic Uscase:

    * `api_key`: Composio API key. Get your API key [here](https://app.composio.dev/developers)
    * `entity_id`: The ID of the entity to execute the action on. Defaults to **default**
    * `connected_account_ids`: Use this to define connected accounts to use when executing an action for a specific app

    #### Extensive Use Case:

    * `output_dir`: Directory path to store downloaded files
    * `metadata`: Additional metadata for executing an action. Learn more [here](use-tools/configure-tools)
    * `processors`: Request and response processors, use these to pre-process requests before executing an action and post-process the response after an action has been executed. Learn more [here](use-tools/processing-actions)
    * `logging_level`: Accepted values: CRITICAL, FATAL, ERROR, WARNING, WARN, INFO, DEBUG
    * `verbosity_level`: This defines the size of the log object that will be printed on the console

    #### Advanced Use Case:

    * `base_url`: Base URL for the Composio API server
    * `output_in_file`: Whether to output the result to a file
    * `workspace_id`: Workspace ID for loading an existing workspace
    * `workspace_config`: Used to specify the configuration for the workspace environment. Supported workspace types: Host, Docker, FlyIO, and E2B
    * `max_retries`: Maximum number of times a tool should be retried in case of a failure during execution
    * `**kwargs`: Additional arguments for advanced use cases

    #### Getting Tools & Actions

    <Steps>
      <Step title="Install packages">
        ```bash Python
        pip install composio-langchain
        ```
      </Step>

      <Step title="Get tools">
        ```python Python 
        from composio_langchain import ComposioToolSet, Action, App

        tool_set = ComposioToolSet()

        # Get all actions from a tool
        tools = tool_set.get_tools(apps=[App.GITHUB])
        ```
      </Step>
    </Steps>
  </Tab>

  <Tab title="JavaScript">
    Tools and Actions are available through different toolset classes:

    * Use `ComposioToolSet` class for non-agentic use cases
    * Use framework-specific classes like `OpenAIToolSet` or `LangchainToolSet` when working with OpenAI, LangChain or other [frameworks](../../framework/autogen).

    <Note>JavaScript SDK has just one package [composio-core](https://www.npmjs.com/package/composio-core) that contains all the necessary classes for both direct usage and framework integrations</Note>

    #### Basic Uscase:

    * `apiKey`: Composio API key. Get your API key [here](https://app.composio.dev/developers)
    * `entityId`: The ID of the entity to execute the action on. Defaults to **default**

    #### Advanced Use Case:

    * `baseUrl`: Base URL for the Composio API server

    <Steps>
      <Step title="Install packages">
        ```bash JavaScript
        npm install composio-core
        ```
      </Step>

      <Step title="Get tools">
        ```javascript JavaScript
        import { LangchainToolSet } from "composio-core";

        const composioToolset = new LangchainToolSet();

        // Get all actions from a tool
        const tools = await composioToolset.getTools({ apps: ["GITHUB"] });
        ```
      </Step>
    </Steps>
  </Tab>
</Tabs>

### Action Types

1. **External Tool Actions**: Pre-configured actions for specific tools, such as creating issues or changing issue status in Jira.
2. **System Management Actions**: Actions that interact with the execution environment, like file system operations, shell commands, and browser automation.
3. **Custom Actions**: User-defined actions in Python or JavaScript that extend Composio's capabilities to interact with new or existing tools.

### Action Limits

Empirical evidence indicates that agents perform optimally when limited to **fewer than 20 actions**. Providing LLMs with too many actions can lead to significant performance issues, such as **increased response time** and **decreased accuracy**.

To optimize agent performance, it's essential to limit the number of actions available. This can be achieved through effective action filtering strategies. Here are some recommended approaches:

1. Use specific actions from a tool
2. Use tags to filter actions
3. Use use cases to filter actions
4. Implement custom filtering logic

By carefully curating the action set, you can significantly improve agent efficiency and response quality.

### Listing All Apps (Tools)

You can list all available tools in Composio along with their details in the following ways:

<CodeGroup>
  ```python Python
  from composio import ComposioToolSet

  toolset = ComposioToolSet()
  print(toolset.get_apps())
  ```

  ```javascript JavaScript
  import { Composio } from "composio-core";

  const composio = new Composio();
  console.log(await composio.apps.list());
  ```

  ```bash CLI
  composio apps
  ```
</CodeGroup>

### Listing All Actions

You can list all available actions in Composio along with their details in the following ways:

<CodeGroup>
  ```python Python
  from composio import Composio

  client = Composio()
  print(client.actions.get(limit=10)) # print all actions supported
  ```

  ```javascript JavaScript
  import { Composio } from "composio-core";
  const composio = new Composio();
  const actions = await composio.actions.list({ data: { limit: 10 } });

  console.log(actions); // print all actions supported
  ```

  ```bash CLI
  composio actions --limit 10
  ```
</CodeGroup>
