@devries-cameron20 / composio Mirror · read-only / commits / 87db57d8c
Fork 0

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

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 22, 23:15 UTC

docs: add description modifier example

balyan.sid@gmail.com committed Jun 30, 2025 at 21:35 UTC 87db57d8c434c2cc852b37102716defeea145eb6
3 files changed +111
fern/pages/src/tool-calling/schema-modifiers.mdx
+24
@@ -16,6 +16,7 @@ Schema modifiers transform a tool's schema before the tool is seen by an agent.
16 <img src="../../../assets/images/schema-modifier.png" alt="Schema Modifier" />
17 </Frame>
18 **Useful for:**
19 +- Modifying or rewriting the tool description to better fit your use case.
20 - Adding arguments to the tool. For example, adding a `thought` argument to the tool to prompt the agent to explain the reasoning.
21 - Hiding arguments from the tool. In cases where the argument is irrelevant to the tool.
22 - Adding extra arguments to the tool schema for custom use cases or execution.
@@ -186,3 +187,26 @@ console.log(response.choices[0].message.tool_calls);
187
188 </CodeGroup>
189 </Accordion>
190 +
191 +
192 +## Example: Modifying the tool description
193 +
194 +<CodeGroup>
195 +<SnippetCode
196 + src="fern/snippets/modifiers/python/description.py"
197 + title="Python"
198 + startLine={1}
199 + endLine={27}
200 + highlightStart={13}
201 + highlightEnd={20}
202 +/>
203 +<SnippetCode
204 + src="fern/snippets/modifiers/typescript/description.ts"
205 + title="TypeScript"
206 + startLine={1}
207 + endLine={31}
208 + highlightStart={13}
209 + highlightEnd={18}
210 +/>
211 +
212 +</CodeGroup>
fern/snippets/modifiers/python/description.py new
+43
@@ -0,0 +1,43 @@
1 +from composio import Composio, schema_modifier
2 +from composio.types import Tool
3 +from composio_google import GoogleProvider
4 +from google import genai
5 +from google.genai import types
6 +from uuid import uuid4
7 +
8 +composio = Composio(provider=GoogleProvider())
9 +client = genai.Client()
10 +user_id = uuid4() # User ID from DB/App
11 +
12 +
13 +@schema_modifier(tools=["GITHUB_LIST_REPOSITORY_ISSUES"])
14 +def append_repository(
15 + tool: str,
16 + toolkit: str,
17 + schema: Tool,
18 +) -> Tool:
19 + schema.description += " When not specified, use the `composiohq/composio` repository"
20 + return schema
21 +
22 +
23 +tools = composio.tools.get(
24 + user_id=user_id, tools=["GITHUB_LIST_REPOSITORY_ISSUES"], modifiers=[append_repository]
25 +)
26 +
27 +print(tools)
28 +
29 +model = "gemini-2.5-pro"
30 +config = types.GenerateContentConfig(
31 + temperature=1.5,
32 + system_instruction="You're a GitHub Taskmaster. Help me with managing my GitHub",
33 + max_output_tokens=65536,
34 + top_p=0.95,
35 + tools=tools,
36 +)
37 +
38 +
39 +response = client.models.generate_content(
40 + model=model, config=config, contents=["What are some issues on my GitHub repo?"]
41 +)
42 +
43 +print(response.text)
fern/snippets/modifiers/typescript/description.ts new
+44
@@ -0,0 +1,44 @@
1 +import { Composio } from '@composio/core';
2 +import { generateText } from 'ai';
3 +import { anthropic } from '@ai-sdk/anthropic';
4 +import { VercelProvider } from '@composio/vercel';
5 +import { v4 as uuidv4 } from 'uuid';
6 +
7 +const userId = uuidv4(); // The user's ID.
8 +const composio = new Composio({
9 + apiKey: process.env.COMPOSIO_API_KEY,
10 + provider: new VercelProvider(),
11 +});
12 +
13 +const addDescription = ({ toolSlug, toolkitSlug, schema }) => {
14 + if (toolSlug === 'GITHUB_LIST_REPOSITORY_ISSUES') {
15 + schema.description += 'If not specified, use the `composiohq/composio` repository';
16 + }
17 + return schema;
18 +};
19 +
20 +const tools = await composio.tools.get(
21 + userId,
22 + {
23 + tools: ['GITHUB_LIST_REPOSITORY_ISSUES'],
24 + },
25 + {
26 + modifySchema: addDescription,
27 + }
28 +);
29 +
30 +console.log(tools);
31 +
32 +// const { text } = await generateText({
33 +// model: anthropic('claude-4-sonnet'),
34 +// messages: [
35 +// {
36 +// role: 'user',
37 +// content: 'What are some issues on my GitHub repo?',
38 +// },
39 +// ],
40 +// tools,
41 +// maxSteps: 3,
42 +// });
43 +
44 +// console.log(text);