Overview
Modifiers are powerful hooks that allow you to intercept and transform tool operations at different stages. You can use modifiers to customize request parameters, transform responses, add logging, implement custom caching, and more.Types of Modifiers
Composio supports three types of modifiers:- Schema Modifiers - Transform tool schemas before they’re exposed
- Before Execute Modifiers - Modify parameters before tool execution
- After Execute Modifiers - Transform responses after tool execution
Schema Modifiers
Schema modifiers allow you to customize tool metadata, parameters, and descriptions before tools are used.Basic Schema Modification
Adding Custom Metadata
Modifying Input Parameters
Tool-Specific Modifications
Before Execute Modifiers
Before execute modifiers intercept and modify parameters before a tool is executed.Basic Parameter Modification
Adding Authentication Headers
Conditional Parameter Transformation
Input Validation
After Execute Modifiers
After execute modifiers transform responses after a tool has executed.Basic Response Transformation
Error Enhancement
Response Filtering and Enrichment
Logging and Monitoring
Combining Modifiers
You can use multiple modifiers together for powerful customization:Tool Router Meta Tool Modifiers
For tool router sessions, use session-specific modifiers:Best Practices
Keep Modifiers Pure
Avoid side effects in modifiers. Return new objects instead of mutating existing ones.
Handle Errors Gracefully
Wrap modifier logic in try-catch blocks to prevent breaking tool execution.
Use Type Safety
Leverage TypeScript types to ensure modifier functions match expected signatures.
Performance Matters
Keep modifiers lightweight. Heavy operations should be async and properly awaited.
Common Use Cases
Caching Responses
Rate Limiting
Request/Response Logging
Limitations
Next Steps
Tool Execution
Apply modifiers to tool execution
Custom Tools
Use modifiers with custom tools
File Handling
Learn about automatic file upload/download modifiers
Error Handling
Handle errors in modifiers