Skip to content

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Fix docs

haxzie4ba275ca75c4
diff --git a/fern/pages/src/tool-calling/after-execution-modifiers.mdx b/fern/pages/src/tool-calling/after-execution-modifiers.mdx
index 575fe9c9a..94f632eda 100644
--- a/fern/pages/src/tool-calling/after-execution-modifiers.mdx
+++ b/fern/pages/src/tool-calling/after-execution-modifiers.mdx
@@ -136,7 +136,7 @@ const agenticTools = await composio.tools.get(
tools: ["HACKERNEWS_GET_USER"],
},
{
- afterExecute: (toolSlug, _toolkitSlug, result) => {
+ afterExecute: ({ toolSlug, toolkitSlug, result }) => {
if (toolSlug === "HACKERNEWS_GET_USER") {
const {
data: { response_data: { karma } = {} } = {},
diff --git a/fern/pages/src/tool-calling/before-execution-modifiers.mdx b/fern/pages/src/tool-calling/before-execution-modifiers.mdx
index 65412064f..ef8ead7a3 100644
--- a/fern/pages/src/tool-calling/before-execution-modifiers.mdx
+++ b/fern/pages/src/tool-calling/before-execution-modifiers.mdx
@@ -140,7 +140,7 @@ const agenticTools = await composio.tools.get(
],
},
{
- beforeExecute: (toolSlug, _, params) => {
+ beforeExecute: ({toolSlug, toolkitSlug, params}) => {
if (toolSlug === "LINEAR_CREATE_LINEAR_ISSUE") {
params.arguments.project_id = "1234567890";
}
diff --git a/fern/snippets/migration/tool_modifiers.ts b/fern/snippets/migration/tool_modifiers.ts
index aac1ecbaf..a6b9a9a5b 100644
--- a/fern/snippets/migration/tool_modifiers.ts
+++ b/fern/snippets/migration/tool_modifiers.ts
@@ -1,7 +1,6 @@
import { Composio } from '@composio/core';
import { OpenAI } from 'openai';
-
const userId = '[email protected]';
const composio = new Composio();
@@ -12,15 +11,15 @@ const tools = await composio.tools.get(
tools: ['HACKERNEWS_GET_LATEST_POSTS', 'HACKERNEWS_GET_USER'],
},
{
- modifyToolSchema: (toolSlug, _, toolSchema) => {
+ modifySchema: ({ toolSlug, toolkitSlug, schema }) => {
if (toolSlug === 'HACKERNEWS_GET_LATEST_POSTS') {
- const { inputParameters } = toolSchema;
+ const { inputParameters } = schema;
if (inputParameters?.properties) {
delete inputParameters.properties['page'];
}
inputParameters.required = ['size'];
}
- return toolSchema;
+ return schema;
},
}
);
@@ -58,7 +57,7 @@ if (tool_calls) {
arguments: JSON.parse(toolArgs),
},
{
- beforeExecute: (toolSlug, _, params) => {
+ beforeExecute: ({ toolSlug, toolkitSlug, params }) => {
if (toolSlug === 'HACKERNEWS_GET_LATEST_POSTS') {
params.arguments.size = 1;
}
@@ -68,14 +67,14 @@ if (tool_calls) {
}
);
const result_2 = await composio.tools.execute(
- "HACKERNEWS_GET_USER",
+ 'HACKERNEWS_GET_USER',
{
userId,
arguments: JSON.parse(toolArgs),
},
{
- afterToolExecute: (toolSlug, _, result) => {
- if (toolSlug === "HACKERNEWS_GET_USER") {
+ afterExecute: ({ toolSlug, toolkitSlug, result }) => {
+ if (toolSlug === 'HACKERNEWS_GET_USER') {
const { data } = result;
const { karma } = data.response_data as { karma: number };
return {
diff --git a/ts/docs/advanced/modifiers.md b/ts/docs/advanced/modifiers.md
index 8c9b01b6f..5eda825be 100644
--- a/ts/docs/advanced/modifiers.md
+++ b/ts/docs/advanced/modifiers.md
@@ -24,7 +24,7 @@ const tools = await composio.tools.get(
toolkits: ['github'],
},
{
- modifySchema: (toolSlug, toolkitSlug, tool) => {
+ modifySchema: ({ toolSlug, toolkitSlug, schema }) => {
// Add a prefix to all tool descriptions
if (tool.description) {
tool.description = `[Enhanced] ${tool.description}`;
@@ -61,7 +61,7 @@ const result = await composio.tools.execute(
},
},
{
- beforeExecute: (toolSlug, toolkitSlug, params) => {
+ beforeExecute: ({ toolSlug, toolkitSlug, params }) => {
// Convert owner names to lowercase
if (params.arguments.owner) {
params.arguments.owner = params.arguments.owner.toLowerCase();
@@ -97,7 +97,7 @@ const result = await composio.tools.execute(
},
},
{
- afterExecute: (toolSlug, toolkitSlug, result) => {
+ afterExecute: ({ toolSlug, toolkitSlug, result }) => {
// Only when execution was successful
if (result.successful) {
// Filter out sensitive data
@@ -141,19 +141,19 @@ const tools = await composio.tools.get(
},
{
// Schema modifier
- modifySchema: (toolSlug, toolkitSlug, tool) => {
+ modifySchema: ({ toolSlug, toolkitSlug, schema }) => {
// Enhance tool schema
- return tool;
+ return schema;
},
// Before execution modifier (only works with agentic providers)
- beforeExecute: (toolSlug, toolkitSlug, params) => {
+ beforeExecute: ({ toolSlug, toolkitSlug, params }) => {
// Modify execution parameters
return params;
},
// After execution modifier (only works with agentic providers)
- afterExecute: (toolSlug, toolkitSlug, result) => {
+ afterExecute: ({ toolSlug, toolkitSlug, result }) => {
// Transform execution results
return result;
},
@@ -193,19 +193,19 @@ For better code organization, you can create reusable modifier functions:
```typescript
// Define reusable modifiers
-const addTimestamps = (toolSlug, toolkitSlug, result) => {
+const addTimestamps = ({ toolSlug, toolkitSlug, result }) => {
if (result.successful) {
result.data.executedAt = new Date().toISOString();
}
return result;
};
-const logExecutions = (toolSlug, toolkitSlug, params) => {
+const logExecutions = ({ toolSlug, toolkitSlug, params }) => {
console.log(`Executing ${toolSlug} from ${toolkitSlug} at ${new Date().toISOString()}`);
return params;
};
-const sanitizeInputs = (toolSlug, toolkitSlug, params) => {
+const sanitizeInputs = ({ toolSlug, toolkitSlug, params }) => {
// Sanitize input parameters to prevent injection attacks
if (params.arguments) {
Object.keys(params.arguments).forEach(key => {
@@ -270,18 +270,18 @@ const vercel = new Composio({
// All modifiers work with agentic providers
const agenticTools = await vercel.tools.get('default', 'HACKERNEWS_GET_USER', {
// Schema modifier
- modifySchema: (toolSlug, toolkitSlug, tool) => {
+ modifySchema: ({ toolSlug, toolkitSlug, schema }) => {
if (tool.inputParameters?.properties?.userId) {
tool.inputParameters.properties.userId.description = 'HackerNews username (e.g., "pg")';
}
- return tool;
+ return schema;
},
// Execution modifiers (only work with agentic providers)
- beforeExecute: (toolSlug, toolkitSlug, params) => {
+ beforeExecute: ({ toolSlug, toolkitSlug, params }) => {
console.log(`Executing ${toolSlug} from ${toolkitSlug}`);
return params;
},
- afterExecute: (toolSlug, toolkitSlug, result) => {
+ afterExecute: ({ toolSlug, toolkitSlug, result }) => {
if (result.successful) {
result.data.processedAt = new Date().toISOString();
}
@@ -305,11 +305,11 @@ const toolOutputs = await openaiProvider.handleToolCalls(
{ connectedAccountId: 'account_123' }, // Options
{
// Manually apply execution modifiers
- beforeExecute: (toolSlug, toolkitSlug, params) => {
+ beforeExecute: ({ toolSlug, toolkitSlug, params }) => {
console.log(`Executing ${toolSlug}`);
return params;
},
- afterExecute: (toolSlug, toolkitSlug, result) => {
+ afterExecute: ({ toolSlug, toolkitSlug, result }) => {
result.data.processedAt = new Date().toISOString();
return result;
},
@@ -325,7 +325,7 @@ const toolOutputs = await openaiProvider.handleToolCalls(
// Simple in-memory cache
const cache = new Map();
-const cacheModifier = (toolSlug, toolkitSlug, params) => {
+const cacheModifier = ({ toolSlug, toolkitSlug, params }) => {
// Create a cache key based on tool slug and arguments
const cacheKey = `${toolSlug}-${JSON.stringify(params.arguments)}`;
@@ -345,7 +345,7 @@ const cacheModifier = (toolSlug, toolkitSlug, params) => {
return params;
};
-const cacheAfterModifier = (toolSlug, toolkitSlug, result) => {
+const cacheAfterModifier = ({ toolSlug, toolkitSlug, result }) => {
if (result.successful && result.__cacheKey) {
// Store in cache
cache.set(result.__cacheKey, {
@@ -390,7 +390,7 @@ try {
### Adding Authentication Headers
```typescript
-const authModifier = (toolSlug, toolkitSlug, params) => {
+const authModifier = ({ toolSlug, toolkitSlug, params }) => {
// Add authentication parameters for specific toolkits
if (toolkitSlug === 'custom-api') {
if (!params.customAuthParams) {
@@ -429,22 +429,22 @@ const tools = await composio.tools.get(
```typescript
// Create a pipeline of modifiers
const pipeModifiers = (...modifiers) => {
- return (toolSlug, toolkitSlug, result) => {
+ return ({ toolSlug, toolkitSlug, result }) => {
return modifiers.reduce((modifiedResult, modifier) => {
- return modifier(toolSlug, toolkitSlug, modifiedResult);
+ return modifier({ toolSlug, toolkitSlug, result: modifiedResult });
}, result);
};
};
// Individual transformation steps
-const addMetadata = (toolSlug, toolkitSlug, result) => {
+const addMetadata = ({ toolSlug, toolkitSlug, result }) => {
if (result.successful) {
result.data.metadata = { source: toolkitSlug, tool: toolSlug };
}
return result;
};
-const formatDates = (toolSlug, toolkitSlug, result) => {
+const formatDates = ({ toolSlug, toolkitSlug, result }) => {
if (result.successful) {
// Convert all dates to a consistent format
Object.keys(result.data).forEach(key => {
@@ -458,7 +458,7 @@ const formatDates = (toolSlug, toolkitSlug, result) => {
return result;
};
-const removeNulls = (toolSlug, toolkitSlug, result) => {
+const removeNulls = ({ toolSlug, toolkitSlug, result }) => {
if (result.successful) {
// Remove null and undefined values
Object.keys(result.data).forEach(key => {
@@ -551,11 +551,11 @@ const result = await openaiProvider.executeToolCall(
{ connectedAccountId: 'account_123' }, // Options
{
// Manually apply execution modifiers
- beforeExecute: (toolSlug, toolkitSlug, params) => {
+ beforeExecute: ({ toolSlug, toolkitSlug, params }) => {
console.log(`Executing ${toolSlug}`);
return params;
},
- afterExecute: (toolSlug, toolkitSlug, result) => {
+ afterExecute: ({ toolSlug, toolkitSlug, result }) => {
result.data.processedAt = new Date().toISOString();
return result;
},
diff --git a/ts/docs/api/providers.md b/ts/docs/api/providers.md
index 01d3f6dd9..ffdd7d237 100644
--- a/ts/docs/api/providers.md
+++ b/ts/docs/api/providers.md
@@ -102,8 +102,8 @@ const result = await openaiProvider.executeToolCall(
toolCall,
{ connectedAccountId: 'conn_abc123' },
{
- beforeExecute: (toolSlug, toolkitSlug, params) => params,
- afterExecute: (toolSlug, toolkitSlug, result) => result,
+ beforeExecute: ({ toolSlug, toolkitSlug, params }) => params,
+ afterExecute: ({ toolSlug, toolkitSlug, result }) => result,
}
);
```
diff --git a/ts/docs/api/tools.md b/ts/docs/api/tools.md
index f8c16e39e..6086c5a63 100644
--- a/ts/docs/api/tools.md
+++ b/ts/docs/api/tools.md
@@ -59,11 +59,11 @@ const result = await composio.tools.execute(
arguments: { owner: 'composio', repo: 'sdk' },
},
{
- beforeExecute: (toolSlug, toolkitSlug, params) => {
+ beforeExecute: ({ toolSlug, toolkitSlug, params }) => {
// Modify params before execution
return params;
},
- afterExecute: (toolSlug, toolkitSlug, result) => {
+ afterExecute: ({ toolSlug, toolkitSlug, result }) => {
// Transform result after execution
return result;
},
diff --git a/ts/docs/providers/openai.md b/ts/docs/providers/openai.md
index b7c1eee3b..c6bc28b0c 100644
--- a/ts/docs/providers/openai.md
+++ b/ts/docs/providers/openai.md
@@ -294,13 +294,13 @@ const tools = await composio.tools.get(
},
// Modify parameters before execution
- beforeExecute: (toolSlug, toolkitSlug, params) => {
+ beforeExecute: ({ toolSlug, toolkitSlug, params }) => {
console.log(`Executing ${toolSlug} tool`);
return params;
},
// Transform results after execution
- afterExecute: (toolSlug, toolkitSlug, result) => {
+ afterExecute: ({ toolSlug, toolkitSlug, result }) => {
// Format the result data for better presentation
if (result.successful && toolSlug === 'GITHUB_GET_REPO') {
result.data = {
diff --git a/ts/packages/core/src/models/Tools.ts b/ts/packages/core/src/models/Tools.ts
index 5e9a6eb2f..d21f5771c 100644
--- a/ts/packages/core/src/models/Tools.ts
+++ b/ts/packages/core/src/models/Tools.ts
@@ -260,7 +260,11 @@ export class Tools<
let modifiedParams = params;
if (modifier) {
if (typeof modifier === 'function') {
- modifiedParams = await modifier(toolSlug, toolkitSlug, modifiedParams);
+ modifiedParams = await modifier({
+ toolSlug,
+ toolkitSlug,
+ params: modifiedParams,
+ });
} else {
throw new ComposioInvalidModifierError('Invalid beforeExecute modifier. Not a function.');
}
@@ -298,7 +302,11 @@ export class Tools<
let modifiedResult = result;
if (modifier) {
if (typeof modifier === 'function') {
- modifiedResult = await modifier(toolSlug, toolkitSlug, modifiedResult);
+ modifiedResult = await modifier({
+ toolSlug,
+ toolkitSlug,
+ result: modifiedResult,
+ });
} else {
throw new ComposioInvalidModifierError('Invalid afterExecute modifier. Not a function.');
}
@@ -409,7 +417,11 @@ export class Tools<
if (modifier) {
if (typeof modifier === 'function') {
const modifiedPromises = modifiedTools.map(tool =>
- modifier(tool.slug, tool.toolkit?.slug ?? 'unknown', tool)
+ modifier({
+ toolSlug: tool.slug,
+ toolkitSlug: tool.toolkit?.slug ?? 'unknown',
+ schema: tool,
+ })
);
modifiedTools = await Promise.all(modifiedPromises);
} else {
@@ -458,7 +470,11 @@ export class Tools<
// apply local modifiers if they are provided
if (modifier) {
if (typeof modifier === 'function') {
- modifiedTool = await modifier(slug, modifiedTool.toolkit?.slug ?? 'unknown', modifiedTool);
+ modifiedTool = await modifier({
+ toolSlug: slug,
+ toolkitSlug: modifiedTool.toolkit?.slug ?? 'unknown',
+ schema: modifiedTool,
+ });
} else {
throw new ComposioInvalidModifierError('Invalid schema modifier. Not a function.');
}
@@ -602,7 +618,11 @@ export class Tools<
): Promise<ToolExecuteResponse> {
if (modifiers?.beforeExecute) {
if (typeof modifiers.beforeExecute === 'function') {
- body = await modifiers.beforeExecute(tool.slug, 'unknown', body);
+ body = await modifiers.beforeExecute({
+ toolSlug: tool.slug,
+ toolkitSlug: tool.toolkit?.slug ?? 'unknown',
+ params: body,
+ });
} else {
throw new ComposioInvalidModifierError('Invalid beforeExecute modifier. Not a function.');
}
@@ -612,7 +632,11 @@ export class Tools<
if (modifiers?.afterExecute) {
if (typeof modifiers.afterExecute === 'function') {
- result = await modifiers.afterExecute(tool.slug, 'unknown', result);
+ result = await modifiers.afterExecute({
+ toolSlug: tool.slug,
+ toolkitSlug: tool.toolkit?.slug ?? 'unknown',
+ result,
+ });
} else {
throw new ComposioInvalidModifierError('Invalid afterExecute modifier. Not a function.');
}
diff --git a/ts/packages/core/src/types/modifiers.types.ts b/ts/packages/core/src/types/modifiers.types.ts
index 14b1dc9ce..310369f2e 100644
--- a/ts/packages/core/src/types/modifiers.types.ts
+++ b/ts/packages/core/src/types/modifiers.types.ts
@@ -18,41 +18,69 @@ import { ToolExecuteParams, ToolExecuteResponse, Tool } from './tool.types';
*
* @example
* ```typescript
- * // Add authentication headers to all tool requests
- * const beforeExecute = (toolSlug, toolkitSlug, params) => {
+ * // Example 1: Add authentication headers to all tool requests
+ * const beforeExecute = ({ params, toolSlug, toolkitSlug }) => {
+ * // Log the execution attempt
+ * console.log(`Executing ${toolSlug} from toolkit ${toolkitSlug}`);
+ *
+ * // Add authentication and tracking headers
* return {
* ...params,
* customAuthParams: {
* ...params.customAuthParams,
* headers: {
* ...params.customAuthParams?.headers,
- * 'X-API-Key': 'my-api-key'
+ * 'X-API-Key': 'my-api-key',
+ * 'X-Request-ID': generateRequestId(),
+ * 'X-Toolkit': toolkitSlug
* }
* }
* };
* };
*
- * // Transform input parameters for a specific tool
- * const beforeExecute = (toolSlug, toolkitSlug, params) => {
- * if (toolSlug === 'GITHUB_SEARCH_REPOS') {
- * // Convert simple query to structured query format
- * return {
- * ...params,
- * arguments: {
- * ...params.arguments,
- * q: `${params.arguments.query} in:name,description`
+ * // Example 2: Transform input parameters for specific tools with validation
+ * const beforeExecute = ({ params, toolSlug, toolkitSlug }) => {
+ * // Handle different tools
+ * switch (toolSlug) {
+ * case 'GITHUB_SEARCH_REPOS':
+ * // Enhance search query with additional filters
+ * return {
+ * ...params,
+ * arguments: {
+ * ...params.arguments,
+ * q: `${params.arguments.query} in:name,description language:typescript stars:>100`,
+ * sort: 'stars',
+ * order: 'desc'
+ * }
+ * };
+ *
+ * case 'NPM_PACKAGE_INFO':
+ * // Validate and normalize package name
+ * const pkgName = params.arguments.packageName.trim().toLowerCase();
+ * if (!pkgName) {
+ * throw new Error('Package name is required');
* }
- * };
+ *
+ * return {
+ * ...params,
+ * arguments: {
+ * ...params.arguments,
+ * packageName: pkgName,
+ * includeVersions: true
+ * }
+ * };
+ *
+ * default:
+ * return params;
* }
- * return params;
* };
* ```
*/
-export type beforeExecuteModifier = (
- toolSlug: string,
- toolkitSlug: string,
- toolExecuteParams: ToolExecuteParams
-) => Promise<ToolExecuteParams> | ToolExecuteParams;
+export type beforeExecuteModifier = (context: {
+ toolSlug: string;
+ toolkitSlug: string;
+ params: ToolExecuteParams;
+}) => Promise<ToolExecuteParams> | ToolExecuteParams;
/**
* Modifier for altering the tool execution response after execution completes.
@@ -71,44 +99,85 @@ export type beforeExecuteModifier = (
*
* @example
* ```typescript
- * // Transform the response data format
- * const afterExecute = (toolSlug, toolkitSlug, response) => {
- * if (toolSlug === 'GITHUB_LIST_REPOS' && response.successful) {
- * // Transform the returned repos into a simpler format
+ * // Example 1: Transform and enrich response data
+ * const afterExecute = ({ result, toolSlug, toolkitSlug }) => {
+ * // Handle successful GitHub repository listing
+ * if (toolSlug === 'GITHUB_LIST_REPOS' && result.successful) {
+ * // Transform the returned repos into a more useful format
+ * const repositories = result.data.items.map(repo => ({
+ * name: repo.name,
+ * url: repo.html_url,
+ * stars: repo.stargazers_count,
+ * // Add derived and computed fields
+ * isPopular: repo.stargazers_count > 1000,
+ * lastUpdated: new Date(repo.updated_at).toLocaleDateString(),
+ * topics: repo.topics || [],
+ * license: repo.license?.spdx_id || 'No License'
+ * }));
+ *
+ * // Add metadata about the response
* return {
- * ...response,
+ * ...result,
* data: {
- * repositories: response.data.items.map(repo => ({
- * name: repo.name,
- * url: repo.html_url,
- * stars: repo.stargazers_count
- * }))
+ * repositories,
+ * totalCount: result.data.total_count,
+ * metadata: {
+ * queryTime: new Date().toISOString(),
+ * toolkit: toolkitSlug,
+ * filterApplied: true
+ * }
* }
* };
* }
- * return response;
+ *
+ * return result;
* };
*
- * // Add error handling with custom messages
- * const afterExecute = (toolSlug, toolkitSlug, response) => {
- * if (!response.successful) {
+ * // Example 2: Comprehensive error handling and logging
+ * const afterExecute = ({ result, toolSlug, toolkitSlug }) => {
+ * // Log all executions for monitoring
+ * logToolExecution(toolSlug, toolkitSlug, result.successful);
+ *
+ * if (!result.successful) {
+ * // Get error details
+ * const errorCode = result.error?.code || 'UNKNOWN_ERROR';
+ * const errorMessage = result.error?.message || 'An unknown error occurred';
+ *
+ * // Handle specific error cases
+ * switch (errorCode) {
+ * case 'RATE_LIMIT_EXCEEDED':
+ * notifyRateLimitExceeded(toolkitSlug);
+ * break;
+ * case 'AUTHENTICATION_FAILED':
+ * refreshAuthToken(toolkitSlug);
+ * break;
+ * }
+ *
+ * // Return enhanced error response
* return {
- * ...response,
+ * ...result,
* error: {
- * message: `Error using ${toolSlug}: ${response.error?.message || 'Unknown error'}`,
- * code: response.error?.code || 'UNKNOWN_ERROR'
+ * message: `Error using ${toolSlug}: ${errorMessage}`,
+ * code: errorCode,
+ * timestamp: new Date().toISOString(),
+ * context: {
+ * toolkit: toolkitSlug,
+ * severity: getSeverityLevel(errorCode),
+ * retryable: isRetryableError(errorCode)
+ * }
* }
* };
* }
- * return response;
+ *
+ * return result;
* };
* ```
*/
-export type afterExecuteModifier = (
- toolSlug: string,
- toolkitSlug: string,
- toolExecuteResponse: ToolExecuteResponse
-) => Promise<ToolExecuteResponse> | ToolExecuteResponse;
+export type afterExecuteModifier = (context: {
+ toolSlug: string;
+ toolkitSlug: string;
+ result: ToolExecuteResponse;
+}) => Promise<ToolExecuteResponse> | ToolExecuteResponse;
/**
* Modifier for altering the tool schema before it's exposed to consumers.
@@ -127,53 +196,133 @@ export type afterExecuteModifier = (
*
* @example
* ```typescript
- * // Modify the input parameters for a specific tool
- * const modifySchema = (toolSlug, toolkitSlug, toolSchema) => {
+ * // Example 1: Comprehensive schema modification with validation
+ * const modifySchema = ({ schema, toolSlug, toolkitSlug }) => {
+ * // Handle specific tools
* if (toolSlug === 'HACKERNEWS_GET_USER') {
* return {
- * ...toolSchema,
+ * ...schema,
+ * name: 'Get HackerNews User Profile',
+ * description: 'Retrieve detailed user information from HackerNews',
+ * version: '2.0.0',
* inputParameters: {
- * ...toolSchema.inputParameters,
+ * ...schema.inputParameters,
* userId: {
* type: 'string',
* description: 'The HackerNews username to retrieve information for',
- * required: true
+ * required: true,
+ * minLength: 2,
+ * maxLength: 15,
+ * pattern: '^[a-zA-Z0-9_-]+$'
+ * },
+ * includeSubmissions: {
+ * type: 'boolean',
+ * description: 'Include user submissions in the response',
+ * default: false
+ * },
+ * submissionLimit: {
+ * type: 'number',
+ * description: 'Maximum number of submissions to return',
+ * default: 10,
+ * minimum: 1,
+ * maximum: 100
+ * }
+ * },
+ * outputSchema: {
+ * type: 'object',
+ * properties: {
+ * user: {
+ * type: 'object',
+ * properties: {
+ * id: { type: 'string' },
+ * karma: { type: 'number' },
+ * created: { type: 'string', format: 'date-time' },
+ * submissions: { type: 'array', items: { type: 'object' } }
+ * }
+ * }
* }
* }
* };
* }
- * return toolSchema;
+ *
+ * return schema;
* };
*
- * // Add custom descriptions to all tools in a toolkit
- * const modifySchema = (toolSlug, toolkitSlug, toolSchema) => {
+ * // Example 2: Add organization-specific customizations
+ * const modifySchema = ({ schema, toolSlug, toolkitSlug }) => {
+ * // Add organization prefix to all GitHub tools
* if (toolkitSlug === 'github') {
- * return {
- * ...toolSchema,
- * description: `Company GitHub tool: ${toolSchema.description}`,
- * important: true
+ * const enhancedSchema = {
+ * ...schema,
+ * name: `Acme Corp - ${schema.name}`,
+ * description: `Company GitHub tool: ${schema.description}`,
+ * category: 'Internal Tools',
+ * tags: [...(schema.tags || []), 'acme-corp', 'internal'],
+ * metadata: {
+ * ...(schema.metadata || {}),
+ * organization: 'acme-corp',
+ * department: 'engineering',
+ * supportContact: '[email protected]'
+ * },
+ * authentication: {
+ * type: 'oauth2',
+ * scopes: ['repo', 'user'],
+ * enterpriseServer: 'github.acme-corp.com'
+ * }
* };
+ *
+ * // Add rate limiting metadata
+ * if (schema.rateLimit) {
+ * enhancedSchema.rateLimit = {
+ * ...schema.rateLimit,
+ * enterprise: {
+ * requests: 5000,
+ * per: '1 hour'
+ * }
+ * };
+ * }
+ *
+ * return enhancedSchema;
* }
- * return toolSchema;
+ *
+ * return schema;
* };
*
- * // Simplify tool schemas for a specific consumer
- * const modifySchema = (toolSlug, toolkitSlug, toolSchema) => {
- * // Remove advanced or complex parameters
- * const { complexParam1, complexParam2, ...simpleInputParams } = toolSchema.inputParameters;
+ * // Example 3: Simplify schemas for external consumers
+ * const modifySchema = ({ schema }) => {
+ * // Remove internal or complex parameters
+ * const {
+ * debugMode,
+ * internalFlags,
+ * experimentalFeatures,
+ * ...simpleInputParams
+ * } = schema.inputParameters;
+ *
+ * // Simplify authentication requirements
+ * const { oauth2, apiKey, ...simpleAuth } = schema.authentication || {};
*
* return {
- * ...toolSchema,
- * inputParameters: simpleInputParams
+ * ...schema,
+ * inputParameters: simpleInputParams,
+ * authentication: {
+ * type: 'apiKey',
+ * in: 'header',
+ * name: 'X-API-Key'
+ * },
+ * // Remove internal metadata
+ * metadata: {
+ * isPublic: true,
+ * version: schema.metadata?.version
+ * }
* };
* };
* ```
*/
-export type TransformToolSchemaModifier = (
- toolSlug: string,
- toolkitSlug: string,
- toolSchema: Tool
-) => Tool | Promise<Tool>;
+export type TransformToolSchemaModifier = (context: {
+ toolSlug: string;
+ toolkitSlug: string;
+ schema: Tool;
+}) => Tool | Promise<Tool>;
/**
* Options for non-agentic tool configuration.
@@ -187,9 +336,9 @@ export type TransformToolSchemaModifier = (
* const tools = await composio.tools.get('default', {
* toolkits: ['github']
* }, {
- * modifySchema: (toolSlug, toolkitSlug, schema) => {
+ * modifySchema: (context) => {
* // Custom schema modifications
- * return schema;
+ * return context.schema;
* }
* });
* ```
@@ -216,15 +365,15 @@ export type ToolOptions = {
* userId: 'default',
* arguments: { owner: 'composio' }
* }, {
- * beforeExecute: (toolSlug, toolkitSlug, params) => {
- * console.log(`Executing ${toolSlug} from ${toolkitSlug}`);
- * return params;
+ * beforeExecute: (context) => {
+ * console.log(`Executing ${context.toolSlug} from ${context.toolkitSlug}`);
+ * return context.params;
* },
- * afterExecute: (toolSlug, toolkitSlug, response) => {
- * if (response.successful) {
- * console.log(`Successfully executed ${toolSlug}`);
+ * afterExecute: (context) => {
+ * if (context.result.successful) {
+ * console.log(`Successfully executed ${context.toolSlug}`);
* }
- * return response;
+ * return context.result;
* }
* });
* ```
@@ -254,27 +403,27 @@ export type ExecuteToolModifiers = {
* ```typescript
* // Configure agentic tools with schema and execution modifications
* const agenticTools = await vercel.tools.get('default', 'GITHUB_GET_REPOS', {
- * modifySchema: (toolSlug, toolkitSlug, schema) => {
+ * modifySchema: (context) => {
* return {
- * ...schema,
- * description: `Enhanced ${toolSlug} for better context`
+ * ...context.schema,
+ * description: `Enhanced ${context.toolSlug} for better context`
* };
* },
*
* // Intercept before execution
- * beforeExecute: (toolSlug, toolkitSlug, params) => {
+ * beforeExecute: (context) => {
* // Add analytics tracking
- * trackToolUsage(toolSlug);
- * return params;
+ * trackToolUsage(context.toolSlug);
+ * return context.params;
* },
*
* // Transform after execution
- * afterExecute: (toolSlug, toolkitSlug, response) => {
+ * afterExecute: (context) => {
* // Log results and handle errors
- * if (!response.successful) {
- * logToolError(toolSlug, response.error);
+ * if (!context.result.successful) {
+ * logToolError(context.toolSlug, context.result.error);
* }
- * return response;
+ * return context.result;
* }
* });
* ```
@@ -293,7 +442,7 @@ export type AgenticToolOptions = ToolOptions & ExecuteToolModifiers;
* ```typescript
* // With standard provider (non-agentic)
* const tools = await composio.tools.get('default', 'GITHUB_GET_REPOS', {
- * modifySchema: (toolSlug, toolkitSlug, schema) => schema
+ * modifySchema: (context) => context.schema
* });
*
* // With agentic provider (e.g., VercelProvider)
@@ -303,9 +452,9 @@ export type AgenticToolOptions = ToolOptions & ExecuteToolModifiers;
* });
*
* const agenticTools = await vercel.tools.get('default', 'GITHUB_GET_REPOS', {
- * modifySchema: (toolSlug, toolkitSlug, schema) => schema,
- * beforeExecute: (toolSlug, toolkitSlug, params) => params,
- * afterExecute: (toolSlug, toolkitSlug, response) => response
+ * modifySchema: (context) => context.schema,
+ * beforeExecute: (context) => context.params,
+ * afterExecute: (context) => context.result
* });
* ```
*/
diff --git a/ts/packages/core/test/provider/openai-provider.test.ts b/ts/packages/core/test/provider/openai-provider.test.ts
index c3322b43e..f3d2e5cd9 100644
--- a/ts/packages/core/test/provider/openai-provider.test.ts
+++ b/ts/packages/core/test/provider/openai-provider.test.ts
@@ -126,14 +126,14 @@ describe('OpenAIProvider', () => {
// Create a valid ExecuteToolModifiers object with beforeExecute and afterExecute functions
const modifiers: ExecuteToolModifiers = {
- beforeExecute: vi.fn((toolSlug, toolkitSlug, params) => {
+ beforeExecute: vi.fn(({ toolSlug, toolkitSlug, params }) => {
return {
...params,
allowTracing: true,
};
}),
- afterExecute: vi.fn((toolSlug, toolkitSlug, response) => {
- return response;
+ afterExecute: vi.fn(({ toolSlug, toolkitSlug, result }) => {
+ return result;
}),
};
diff --git a/ts/packages/core/test/provider/provider.test.ts b/ts/packages/core/test/provider/provider.test.ts
index c291b4929..e711734cd 100644
--- a/ts/packages/core/test/provider/provider.test.ts
+++ b/ts/packages/core/test/provider/provider.test.ts
@@ -110,8 +110,8 @@ describe('BaseProvider', () => {
arguments: { query: 'test' },
};
const modifiers = {
- beforeExecute: vi.fn(x => x),
- afterExecute: vi.fn(x => x),
+ beforeExecute: vi.fn(({ params }) => params),
+ afterExecute: vi.fn(({ result }) => result),
};
const result = await nonAgenticProvider.executeTool(toolSlug, toolParams, modifiers);
@@ -209,8 +209,8 @@ describe('BaseProvider', () => {
arguments: { query: 'test' },
};
const modifiers = {
- beforeExecute: vi.fn(x => x),
- afterExecute: vi.fn(x => x),
+ beforeExecute: vi.fn(({ params }) => params),
+ afterExecute: vi.fn(({ result }) => result),
};
const result = await agenticProvider.executeTool(toolSlug, toolParams, modifiers);
diff --git a/ts/packages/core/test/tools/modifiers.test.ts b/ts/packages/core/test/tools/modifiers.test.ts
index 95e61a5de..0ab202adc 100644
--- a/ts/packages/core/test/tools/modifiers.test.ts
+++ b/ts/packages/core/test/tools/modifiers.test.ts
@@ -30,9 +30,11 @@ describe('Tools Modifiers', () => {
expect(schemaModifier).toHaveBeenCalledTimes(1);
expect(schemaModifier).toHaveBeenCalledWith(
- slug,
- expect.any(String),
- expect.objectContaining({ slug })
+ expect.objectContaining({
+ toolSlug: slug,
+ toolkitSlug: expect.any(String),
+ schema: expect.objectContaining({ slug }),
+ })
);
expect(result.name).toEqual('Modified Name');
expect(result.description).toEqual('Modified description');
@@ -40,9 +42,9 @@ describe('Tools Modifiers', () => {
it('should apply schema modifiers to all tools when getting multiple tools', async () => {
const userId = 'test-user';
- const schemaModifier = createSchemaModifier((tool: Tool) => ({
- ...tool,
- name: `Modified ${tool.name}`,
+ const schemaModifier = createSchemaModifier(({ schema }) => ({
+ ...schema,
+ name: `Modified ${schema.name}`,
}));
mockClient.tools.list.mockResolvedValueOnce({
@@ -82,7 +84,13 @@ describe('Tools Modifiers', () => {
await context.tools.execute(slug, body, { beforeExecute });
expect(beforeExecute).toHaveBeenCalledTimes(1);
- expect(beforeExecute).toHaveBeenCalledWith(slug, expect.any(String), body);
+ expect(beforeExecute).toHaveBeenCalledWith(
+ expect.objectContaining({
+ toolSlug: slug,
+ toolkitSlug: expect.any(String),
+ params: body,
+ })
+ );
expect(mockClient.tools.execute).toHaveBeenCalledWith(
slug,
expect.objectContaining({
@@ -106,11 +114,13 @@ describe('Tools Modifiers', () => {
expect(afterExecute).toHaveBeenCalledTimes(1);
expect(afterExecute).toHaveBeenCalledWith(
- slug,
- expect.any(String),
expect.objectContaining({
- data: expect.any(Object),
- successful: expect.any(Boolean),
+ toolSlug: slug,
+ toolkitSlug: expect.any(String),
+ result: expect.objectContaining({
+ data: expect.any(Object),
+ successful: expect.any(Boolean),
+ }),
})
);
expect(result.data).toHaveProperty('enhanced', true);
@@ -120,32 +130,166 @@ describe('Tools Modifiers', () => {
describe('Combined Modifiers', () => {
it('should apply both schema and execution modifiers together', async () => {
const userId = 'test-user';
- const slug = 'COMPOSIO_TOOL';
+ const slug = 'GITHUB_GET_REPOS';
- const schemaModifier = createSchemaModifier({
- description: 'Modified schema',
- });
+ // Mock analytics and logging functions
+ const trackToolUsage = vi.fn();
+ const logToolError = vi.fn();
+
+ const schemaModifier = createSchemaModifier(({ schema, toolSlug }) => ({
+ ...schema,
+ description: `Enhanced ${toolSlug} for better context`,
+ tags: [...(schema.tags || []), 'enhanced', 'modified'],
+ inputParameters: {
+ type: 'object' as const,
+ properties: {
+ ...schema.inputParameters?.properties,
+ tracking: {
+ type: 'object' as const,
+ properties: {
+ enabled: {
+ type: 'boolean' as const,
+ default: true,
+ },
+ },
+ },
+ },
+ },
+ }));
- const executionModifiers = createExecutionModifiers();
+ const executionModifiers = {
+ beforeExecute: vi.fn(({ params, toolSlug }) => {
+ // Add analytics tracking
+ trackToolUsage(toolSlug);
+ return {
+ ...params,
+ arguments: {
+ ...(params.arguments || {}),
+ tracking: {
+ enabled: true,
+ timestamp: expect.any(String),
+ },
+ },
+ };
+ }),
+ afterExecute: vi.fn(({ result, toolSlug }) => {
+ // Log results and handle errors
+ if (!result.successful) {
+ logToolError(toolSlug, result.error);
+ }
+ return {
+ ...result,
+ data: {
+ ...(result.data || {}),
+ processed: true,
+ timestamp: expect.any(String),
+ },
+ };
+ }),
+ };
const getRawComposioToolBySlugSpy = vi.spyOn(context.tools, 'getRawComposioToolBySlug');
- getRawComposioToolBySlugSpy.mockResolvedValueOnce({
+ const mockTool = {
...(toolMocks.transformedTool as unknown as Tool),
- description: 'Modified schema',
- });
+ description: 'Enhanced GITHUB_GET_REPOS for better context',
+ tags: ['enhanced', 'modified'],
+ inputParameters: {
+ type: 'object' as const,
+ properties: {
+ tracking: {
+ type: 'object' as const,
+ properties: {
+ enabled: {
+ type: 'boolean' as const,
+ default: true,
+ },
+ },
+ },
+ },
+ },
+ };
+ getRawComposioToolBySlugSpy.mockResolvedValueOnce(mockTool);
const createExecuteToolFnSpy = vi.spyOn(context.tools as any, 'createExecuteToolFn');
+ const executeWithModifiers = async (params: any) => {
+ // Apply beforeExecute modifier
+ const modifiedParams = await executionModifiers.beforeExecute({
+ toolSlug: slug,
+ toolkitSlug: 'default',
+ params,
+ });
- await context.tools.get(userId, slug, {
+ // Execute the tool
+ const response = await mockClient.tools.execute(slug, modifiedParams);
+
+ // Apply afterExecute modifier
+ return executionModifiers.afterExecute({
+ toolSlug: slug,
+ toolkitSlug: 'default',
+ result: response,
+ });
+ };
+ createExecuteToolFnSpy.mockReturnValueOnce(executeWithModifiers);
+
+ const tool = await context.tools.get(userId, slug, {
modifySchema: schemaModifier,
...executionModifiers,
});
+ // Verify schema modification
expect(getRawComposioToolBySlugSpy).toHaveBeenCalledWith(slug, schemaModifier);
+ expect(mockTool.description).toBe('Enhanced GITHUB_GET_REPOS for better context');
+ expect(mockTool.tags).toContain('enhanced');
+ expect(mockTool.tags).toContain('modified');
+ expect(mockTool.inputParameters).toHaveProperty(['properties', 'tracking']);
+
+ // Verify execution function creation
expect(createExecuteToolFnSpy).toHaveBeenCalledWith(
userId,
expect.objectContaining(executionModifiers)
);
+
+ // Mock a tool execution to verify the full flow
+ await mockToolExecution(context.tools);
+ mockClient.tools.execute.mockResolvedValueOnce({
+ data: {
+ results: true,
+ },
+ error: null,
+ successful: true,
+ log_id: '123',
+ session_info: {},
+ });
+
+ // Execute the tool using the wrapped execute function
+ const result = await executeWithModifiers({ query: 'test' });
+
+ // Verify analytics tracking was called
+ expect(trackToolUsage).toHaveBeenCalledWith(slug);
+
+ // Verify the execution flow
+ expect(executionModifiers.beforeExecute).toHaveBeenCalledWith({
+ toolSlug: slug,
+ toolkitSlug: 'default',
+ params: { query: 'test' },
+ });
+
+ expect(executionModifiers.afterExecute).toHaveBeenCalledWith({
+ toolSlug: slug,
+ toolkitSlug: 'default',
+ result: {
+ data: {
+ results: true,
+ },
+ error: null,
+ successful: true,
+ log_id: '123',
+ session_info: {},
+ },
+ });
+
+ // Verify no error logging occurred
+ expect(logToolError).not.toHaveBeenCalled();
});
});
});
diff --git a/ts/packages/core/test/utils/toolExecuteUtils.ts b/ts/packages/core/test/utils/toolExecuteUtils.ts
index 3b4da0552..601bfa40c 100644
--- a/ts/packages/core/test/utils/toolExecuteUtils.ts
+++ b/ts/packages/core/test/utils/toolExecuteUtils.ts
@@ -4,9 +4,9 @@ import { mockClient } from './mocks/client.mock';
import { MockProvider } from './mocks/provider.mock';
import { connectedAccountMocks, toolkitMocks, toolMocks } from './mocks/data.mock';
import ComposioClient from '@composio/client';
-import { Tool } from '../../src/types/tool.types';
+import { Tool, ToolExecuteResponse, ToolExecuteParams } from '../../src/types/tool.types';
-export type TestTools = Tools<unknown, unknown, unknown, MockProvider>;
+export type TestTools = Tools<Tool[], Tool, MockProvider>;
export interface TestContext {
tools: TestTools;
@@ -67,13 +67,15 @@ export const mockToolExecution = async (
};
};
-export type SchemaModification = Partial<Tool> | ((tool: Tool) => Partial<Tool>);
+export type SchemaModification =
+ | Partial<Tool>
+ | ((context: { schema: Tool; toolSlug: string; toolkitSlug: string }) => Partial<Tool>);
export const createSchemaModifier = (modifications: SchemaModification) => {
- return vi.fn((toolSlug: string, toolkitSlug: string, tool: Tool) => {
- const mods = typeof modifications === 'function' ? modifications(tool) : modifications;
+ return vi.fn((context: { schema: Tool; toolSlug: string; toolkitSlug: string }) => {
+ const mods = typeof modifications === 'function' ? modifications(context) : modifications;
return {
- ...tool,
+ ...context.schema,
...mods,
};
});
@@ -84,13 +86,17 @@ export const createExecutionModifiers = ({
afterModifications = {},
} = {}) => {
return {
- beforeExecute: vi.fn((toolSlug: string, toolkitSlug: string, params: any) => ({
- ...params,
- ...beforeModifications,
- })),
- afterExecute: vi.fn((toolSlug: string, toolkitSlug: string, response: any) => ({
- ...response,
- ...afterModifications,
- })),
+ beforeExecute: vi.fn(
+ (context: { toolSlug: string; toolkitSlug: string; params: ToolExecuteParams }) => ({
+ ...context.params,
+ ...beforeModifications,
+ })
+ ),
+ afterExecute: vi.fn(
+ (context: { toolSlug: string; toolkitSlug: string; result: ToolExecuteResponse }) => ({
+ ...context.result,
+ ...afterModifications,
+ })
+ ),
};
};
diff --git a/ts/packages/providers/anthropic/test/anthropic.test.ts b/ts/packages/providers/anthropic/test/anthropic.test.ts
index ae9778566..3d93123a7 100644
--- a/ts/packages/providers/anthropic/test/anthropic.test.ts
+++ b/ts/packages/providers/anthropic/test/anthropic.test.ts
@@ -189,8 +189,8 @@ describe('AnthropicProvider', () => {
};
const modifiers = {
- beforeExecute: vi.fn(params => params),
- afterExecute: vi.fn(response => response),
+ beforeExecute: vi.fn(({ params }) => params),
+ afterExecute: vi.fn(({ result }) => result),
};
await provider.executeToolCall(userId, toolUse, options, modifiers);
@@ -344,8 +344,8 @@ describe('AnthropicProvider', () => {
};
const modifiers = {
- beforeExecute: vi.fn(params => params),
- afterExecute: vi.fn(response => response),
+ beforeExecute: vi.fn(({ params }) => params),
+ afterExecute: vi.fn(({ result }) => result),
};
await provider.executeTool(toolSlug, toolParams, modifiers);
diff --git a/ts/packages/providers/cloudflare/test/cloudflare.test.ts b/ts/packages/providers/cloudflare/test/cloudflare.test.ts
index 0aa13cdec..0cc2f4c67 100644
--- a/ts/packages/providers/cloudflare/test/cloudflare.test.ts
+++ b/ts/packages/providers/cloudflare/test/cloudflare.test.ts
@@ -240,8 +240,8 @@ describe('CloudflareProvider', () => {
};
const modifiers = {
- beforeExecute: vi.fn(params => params),
- afterExecute: vi.fn(response => response),
+ beforeExecute: vi.fn(({ params }) => params),
+ afterExecute: vi.fn(({ result }) => result),
};
await provider.executeToolCall(userId, toolCall, options, modifiers);
@@ -285,8 +285,8 @@ describe('CloudflareProvider', () => {
};
const modifiers = {
- beforeExecute: vi.fn(params => params),
- afterExecute: vi.fn(response => response),
+ beforeExecute: vi.fn(({ params }) => params),
+ afterExecute: vi.fn(({ result }) => result),
};
await provider.executeTool(toolSlug, toolParams, modifiers);
diff --git a/ts/packages/providers/google/test/google.test.ts b/ts/packages/providers/google/test/google.test.ts
index abac884eb..d71e887a4 100644
--- a/ts/packages/providers/google/test/google.test.ts
+++ b/ts/packages/providers/google/test/google.test.ts
@@ -172,8 +172,8 @@ describe('GoogleProvider', () => {
};
const modifiers = {
- beforeExecute: vi.fn(params => params),
- afterExecute: vi.fn(response => response),
+ beforeExecute: vi.fn(({ params }) => params),
+ afterExecute: vi.fn(({ result }) => result),
};
await provider.executeToolCall(userId, toolCall, options, modifiers);
@@ -217,8 +217,8 @@ describe('GoogleProvider', () => {
};
const modifiers = {
- beforeExecute: vi.fn(params => params),
- afterExecute: vi.fn(response => response),
+ beforeExecute: vi.fn(({ params }) => params),
+ afterExecute: vi.fn(({ result }) => result),
};
await provider.executeTool(toolSlug, toolParams, modifiers);
diff --git a/ts/packages/providers/mastra/test/mastra.test.ts b/ts/packages/providers/mastra/test/mastra.test.ts
index 4f0727dfa..5273a4c03 100644
--- a/ts/packages/providers/mastra/test/mastra.test.ts
+++ b/ts/packages/providers/mastra/test/mastra.test.ts
@@ -332,8 +332,8 @@ describe('MastraProvider', () => {
};
const modifiers = {
- beforeExecute: vi.fn(params => params),
- afterExecute: vi.fn(response => response),
+ beforeExecute: vi.fn(({ params }) => params),
+ afterExecute: vi.fn(({ result }) => result),
};
await provider.executeTool(toolSlug, toolParams, modifiers);
diff --git a/ts/packages/providers/openai-agents/test/openai-agents.test.ts b/ts/packages/providers/openai-agents/test/openai-agents.test.ts
index 7333b2808..1cb26f680 100644
--- a/ts/packages/providers/openai-agents/test/openai-agents.test.ts
+++ b/ts/packages/providers/openai-agents/test/openai-agents.test.ts
@@ -191,8 +191,8 @@ describe('OpenAIAgentsProvider', () => {
};
const modifiers = {
- beforeExecute: vi.fn(params => params),
- afterExecute: vi.fn(response => response),
+ beforeExecute: vi.fn(({ params }) => params),
+ afterExecute: vi.fn(({ result }) => result),
};
await provider.executeTool(toolSlug, toolParams, modifiers);
diff --git a/ts/packages/providers/openai/test/opeanai-responses.test.ts b/ts/packages/providers/openai/test/opeanai-responses.test.ts
index 33b657935..a1fa67e62 100644
--- a/ts/packages/providers/openai/test/opeanai-responses.test.ts
+++ b/ts/packages/providers/openai/test/opeanai-responses.test.ts
@@ -199,8 +199,8 @@ describe('OpenAIResponsesProvider', () => {
};
const modifiers = {
- beforeExecute: vi.fn(params => params),
- afterExecute: vi.fn(response => response),
+ beforeExecute: vi.fn(({ params }) => params),
+ afterExecute: vi.fn(({ result }) => result),
};
await provider.executeToolCall(userId, toolCall, options, modifiers);
diff --git a/ts/packages/providers/openai/test/openai.test.ts b/ts/packages/providers/openai/test/openai.test.ts
index 86783b663..98b9aa3f9 100644
--- a/ts/packages/providers/openai/test/openai.test.ts
+++ b/ts/packages/providers/openai/test/openai.test.ts
@@ -214,8 +214,8 @@ describe('OpenAIProvider', () => {
};
const modifiers = {
- beforeExecute: vi.fn(params => params),
- afterExecute: vi.fn(response => response),
+ beforeExecute: vi.fn(({ params }) => params),
+ afterExecute: vi.fn(({ result }) => result),
};
await provider.executeToolCall(userId, toolCall, options, modifiers);
@@ -445,8 +445,8 @@ describe('OpenAIProvider', () => {
};
const modifiers = {
- beforeExecute: vi.fn(params => params),
- afterExecute: vi.fn(response => response),
+ beforeExecute: vi.fn(({ params }) => params),
+ afterExecute: vi.fn(({ result }) => result),
};
await provider.executeTool(toolSlug, toolParams, modifiers);
diff --git a/ts/packages/providers/vercel/test/vercel.test.ts b/ts/packages/providers/vercel/test/vercel.test.ts
index 5fd63ded5..c37f36c9b 100644
--- a/ts/packages/providers/vercel/test/vercel.test.ts
+++ b/ts/packages/providers/vercel/test/vercel.test.ts
@@ -187,8 +187,8 @@ describe('VercelProvider', () => {
};
const modifiers = {
- beforeExecute: vi.fn(params => params),
- afterExecute: vi.fn(response => response),
+ beforeExecute: vi.fn(({ params }) => params),
+ afterExecute: vi.fn(({ result }) => result),
};
await provider.executeTool(toolSlug, toolParams, modifiers);