Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
docs: add description modifier example
[email protected]87db57d8c434
diff --git a/fern/pages/src/tool-calling/schema-modifiers.mdx b/fern/pages/src/tool-calling/schema-modifiers.mdxindex 67bfc61c8..c7864a365 100644--- a/fern/pages/src/tool-calling/schema-modifiers.mdx+++ b/fern/pages/src/tool-calling/schema-modifiers.mdx@@ -16,6 +16,7 @@ Schema modifiers transform a tool's schema before the tool is seen by an agent.<img src="../../../assets/images/schema-modifier.png" alt="Schema Modifier" /></Frame>**Useful for:**+- Modifying or rewriting the tool description to better fit your use case.- Adding arguments to the tool. For example, adding a `thought` argument to the tool to prompt the agent to explain the reasoning.- Hiding arguments from the tool. In cases where the argument is irrelevant to the tool.- 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);</CodeGroup></Accordion>+++## Example: Modifying the tool description++<CodeGroup>+<SnippetCode+ src="fern/snippets/modifiers/python/description.py"+ title="Python"+ startLine={1}+ endLine={27}+ highlightStart={13}+ highlightEnd={20}+/>+<SnippetCode+ src="fern/snippets/modifiers/typescript/description.ts"+ title="TypeScript"+ startLine={1}+ endLine={31}+ highlightStart={13}+ highlightEnd={18}+/>++</CodeGroup>diff --git a/fern/snippets/modifiers/python/description.py b/fern/snippets/modifiers/python/description.pynew file mode 100644index 000000000..fce5b6198--- /dev/null+++ b/fern/snippets/modifiers/python/description.py@@ -0,0 +1,43 @@+from composio import Composio, schema_modifier+from composio.types import Tool+from composio_google import GoogleProvider+from google import genai+from google.genai import types+from uuid import uuid4++composio = Composio(provider=GoogleProvider())+client = genai.Client()+user_id = uuid4() # User ID from DB/App+++@schema_modifier(tools=["GITHUB_LIST_REPOSITORY_ISSUES"])+def append_repository(+ tool: str,+ toolkit: str,+ schema: Tool,+) -> Tool:+ schema.description += " When not specified, use the `composiohq/composio` repository"+ return schema+++tools = composio.tools.get(+ user_id=user_id, tools=["GITHUB_LIST_REPOSITORY_ISSUES"], modifiers=[append_repository]+)++print(tools)++model = "gemini-2.5-pro"+config = types.GenerateContentConfig(+ temperature=1.5,+ system_instruction="You're a GitHub Taskmaster. Help me with managing my GitHub",+ max_output_tokens=65536,+ top_p=0.95,+ tools=tools,+)+++response = client.models.generate_content(+ model=model, config=config, contents=["What are some issues on my GitHub repo?"]+)++print(response.text)diff --git a/fern/snippets/modifiers/typescript/description.ts b/fern/snippets/modifiers/typescript/description.tsnew file mode 100644index 000000000..36bce2640--- /dev/null+++ b/fern/snippets/modifiers/typescript/description.ts@@ -0,0 +1,44 @@+import { Composio } from '@composio/core';+import { generateText } from 'ai';+import { anthropic } from '@ai-sdk/anthropic';+import { VercelProvider } from '@composio/vercel';+import { v4 as uuidv4 } from 'uuid';++const userId = uuidv4(); // The user's ID.+const composio = new Composio({+ apiKey: process.env.COMPOSIO_API_KEY,+ provider: new VercelProvider(),+});++const addDescription = ({ toolSlug, toolkitSlug, schema }) => {+ if (toolSlug === 'GITHUB_LIST_REPOSITORY_ISSUES') {+ schema.description += 'If not specified, use the `composiohq/composio` repository';+ }+ return schema;+};++const tools = await composio.tools.get(+ userId,+ {+ tools: ['GITHUB_LIST_REPOSITORY_ISSUES'],+ },+ {+ modifySchema: addDescription,+ }+);++console.log(tools);++// const { text } = await generateText({+// model: anthropic('claude-4-sonnet'),+// messages: [+// {+// role: 'user',+// content: 'What are some issues on my GitHub repo?',+// },+// ],+// tools,+// maxSteps: 3,+// });++// console.log(text);