Processing Tools
Customize tool behavior by modifying schemas, inputs, and outputs
Composio allows you to refine how tools interact with LLMs and external APIs through Processors. These are custom functions you provide to modify data at key stages:
- before the LLM sees the tool’s definition
- before Composio executes the tool
- after Composio executes the tool
Why use Processors?
- Improve Reliability: Remove confusing parameters or inject required values the LLM might miss.
- Guide LLMs: Simplify tool schemas or descriptions for better tool selection.
- Manage Context & Cost: Filter large API responses to send only relevant data back to the LLM, saving tokens.
- Adapt to Workflows: Transform tool inputs or outputs to match your application’s specific needs.
Python SDK Only
Tool Processors described on this page are currently only available in Composio’s Python SDK. Support for TypeScript is planned for the future.
How Processors Work
Processors are Python functions you define and pass to get_tools
within a processors
dictionary. The dictionary maps the processing stage ("schema"
, "pre"
, "post"
) to another dictionary, which maps the specific Action
to your processor function.
Let’s look at each type.
Schema Processing (schema
)
Goal: Modify the tool’s definition (schema) before it’s provided to the LLM.
Example: Simplifying GMAIL_SEND_EMAIL
Schema
Let’s hide the recipient_email
and attachment
parameters from the LLM, perhaps because our application handles the recipient logic separately and doesn’t support attachments in this flow.
Preprocessing (pre
)
Goal: Modify the input parameters provided by the LLM just before the tool executes.
Use this to inject required values hidden from the LLM (like the recipient_email
from the previous example), add default values, clean up or format LLM-generated inputs, or perform last-minute validation.
Example: Injecting recipient_email
for GMAIL_SEND_EMAIL
Continuing the previous example, since we hid recipient_email
from the LLM via schema processing, we now need to inject the correct value before Composio executes the GMAIL_SEND_EMAIL
action.
Schema vs. Preprocessing
Think of schema
processing as changing the tool’s instructions for the LLM, while pre
processing adjusts the actual inputs right before execution based on those instructions (or other logic).
Postprocessing (post
)
Goal: Modify the result returned by the tool’s execution before it is passed back.
This is invaluable for filtering large or complex API responses to extract only the necessary information, reducing the number of tokens sent back to the LLM, improving clarity, and potentially lowering costs.
Example: Filtering GMAIL_FETCH_EMAILS
Response
The GMAIL_FETCH_EMAILS
action can return a lot of data per email. Let’s filter the response to include only the sender
and subject
, significantly reducing the payload sent back to the LLM.
By using postprocessing, you can make tool results much more manageable and useful for the LLM, preventing context overflow and focusing its attention on the most relevant information.