Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Update examples to use toolkit slug in modifiers
haxzie committed
May 16, 2025 at 14:45 UTC
a736500205c54e17a4ebb98e23f25476a17005eb
2 files changed
+7
-7
examples/pre-processors/src/index.ts
+4
-4
@@ -14,7 +14,7 @@ console.log(toolkit);
14
15
const tools = await composio.tools.get('default', 'HACKERNEWS_GET_USER', {
16
// toolkit slug too
17
- modifyToolSchema: (toolSlug, toolSchema) => {
17
+ modifyToolSchema: (toolSlug, toolkitSlug, toolSchema) => {
18
if (toolSlug === 'HACKERNEWS_GET_USER') {
19
toolSchema = {
20
...toolSchema,
@@ -45,15 +45,15 @@ const agenticTools = await vercel.tools.get(
45
// what is the type error i am getting here?
46
{ tools: ['HACKERNEWS_GET_USER'] },
47
{
48
- afterToolExecute: (toolSlug, result) => {
48
+ afterToolExecute: (toolSlug, toolkitSlug, result) => {
49
// modify the result
50
return result;
51
},
52
- beforeToolExecute: (toolSlug, params) => {
52
+ beforeToolExecute: (toolSlug, toolkitSlug, params) => {
53
// modify the params
54
return params;
55
},
56
- modifyToolSchema: (toolSlug, toolSchema) => {
56
+ modifyToolSchema: (toolSlug, toolkitSlug, toolSchema) => {
57
// modify the tool schema
58
return toolSchema;
59
},
packages/core/README.md
+3
-3
@@ -70,7 +70,7 @@ Schema modifiers allow you to transform tool schemas before they are used:
70
71
```typescript
72
const tool = await composio.tools.get('user123', 'HACKERNEWS_SEARCH_POSTS', {
73
- modifyToolSchema: (toolSlug: string, tool: Tool) => ({
73
+ modifyToolSchema: (toolSlug: string, toolkitSlug: string, tool: Tool) => ({
74
...tool,
75
description: 'Enhanced HackerNews search with additional features',
76
inputParameters: {
@@ -92,7 +92,7 @@ For agentic toolsets (like Vercel AI and Langchain), you can also modify tool ex
92
```typescript
93
const tool = await composio.tools.get('user123', 'HACKERNEWS_SEARCH_POSTS', {
94
// Transform input before execution
95
- beforeToolExecute: (toolSlug: string, params: ToolExecuteParams) => ({
95
+ beforeToolExecute: (toolSlug: string, toolkitSlug: string, params: ToolExecuteParams) => ({
96
...params,
97
arguments: {
98
...params.arguments,
@@ -101,7 +101,7 @@ const tool = await composio.tools.get('user123', 'HACKERNEWS_SEARCH_POSTS', {
101
}),
102
103
// Transform output after execution
104
- afterToolExecute: (toolSlug: string, response: ToolExecuteResponse) => ({
104
+ afterToolExecute: (toolSlug: string, toolkitSlug: string, response: ToolExecuteResponse) => ({
105
...response,
106
data: {
107
...response.data,