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
using snippet fixes
Sushmithamallesh2b267d9fa945
diff --git a/fern/snippets/tool-router/python/native-tools-openai.py b/fern/snippets/tool-router/python/native-tools-openai.pyindex 014f16a32..c0b4d2b2e 100644--- a/fern/snippets/tool-router/python/native-tools-openai.py+++ b/fern/snippets/tool-router/python/native-tools-openai.py@@ -1,7 +1,7 @@import osfrom dotenv import load_dotenvfrom composio import Composio-from agents import Agent, Runner+from agents import Agent, Runner, SQLiteSessionfrom composio_openai_agents import OpenAIAgentsProvider# Load environment variables from .env file@@ -16,15 +16,36 @@ tools = session.tools()# Create OpenAI agent with Composio toolsagent = Agent(name="AI Assistant",- instructions="You are a helpful assistant with access to external tools. Use the available tools to complete user requests.",+ instructions="You are a helpful assistant with access to external tools. Always use the available tools to complete user requests instead of just explaining how to do them.",model="gpt-5.2",tools=tools,)-# Run the agent with a specific task+# Create session for multi-turn conversation+conversation_session = SQLiteSession("conversation_example")++# Execute an initial task that requires GitHub access+print("Executing initial task: Fetching GitHub issues...\n")result = Runner.run_sync(starting_agent=agent,- input="Fetch all open issues from the composio/composio GitHub repository and create a summary of the top 5 by priority"+ input="Fetch all the open GitHub issues on the composio repository and group them by bugs/features/docs.",+ session=conversation_session,)+print(f"Result: {result.final_output}\n")++# Continue with interactive conversation+print("Assistant: What else would you like me to do? Type 'exit' to end the conversation.\n")-print(f"Assistant: {result.final_output}")\ No newline at end of file+while True:+ user_input = input("> ")+ if user_input.lower() == "exit":+ break++ # Run agent with session to maintain context+ result = Runner.run_sync(+ starting_agent=agent,+ input=user_input,+ session=conversation_session,+ )++ print(f"Assistant: {result.final_output}\n")\ No newline at end of filediff --git a/fern/snippets/tool-router/typescript/native-tools-openai.ts b/fern/snippets/tool-router/typescript/native-tools-openai.tsindex 8f4d91108..42e312e52 100644--- a/fern/snippets/tool-router/typescript/native-tools-openai.ts+++ b/fern/snippets/tool-router/typescript/native-tools-openai.ts@@ -1,7 +1,8 @@import "dotenv/config"; // Load environment variables from .env fileimport { Composio } from "@composio/core";-import { Agent, run } from "@openai/agents";+import { Agent, run, MemorySession } from "@openai/agents";import { OpenAIAgentsProvider } from "@composio/openai-agents";+import { createInterface } from "readline/promises";const composioApiKey = process.env.COMPOSIO_API_KEY;const userId = "user_123"; // Your user's unique identifier@@ -15,15 +16,35 @@ const tools = await session.tools();// Create OpenAI agent with Composio toolsconst agent = new Agent({name: "AI Assistant",- instructions: "You are a helpful assistant with access to external tools. Use the available tools to complete user requests.",+ instructions:+ "You are a helpful assistant with access to external tools. " ++ "Always use the available tools to complete user requests instead of just explaining how to do them.",model: "gpt-5.2",tools: tools,});-// Run the agent with a specific task-const result = await run(+// Create session for multi-turn conversation+const conversationSession = new MemorySession();++// Execute an initial task that requires GitHub access+console.log("Executing initial task: Fetching GitHub issues...\n");+const initialResult = await run(agent,- "Fetch all open issues from the composio/composio GitHub repository and create a summary of the top 5 by priority"+ "Fetch all the open GitHub issues on the composio repository and group them by bugs/features/docs.",+ { session: conversationSession });+console.log(`Result: ${initialResult.finalOutput}\n`);++// Continue with interactive conversation+const rl = createInterface({ input: process.stdin, output: process.stdout });+console.log("Assistant: What else would you like me to do? Type 'exit' to end the conversation.\n");-console.log(`Assistant: ${result.finalOutput}`);\ No newline at end of file+while (true) {+ const userInput = await rl.question("> ");+ if (userInput.toLowerCase() === "exit") break;++ // Run agent with session to maintain context+ const result = await run(agent, userInput, { session: conversationSession });+ console.log(`Assistant: ${result.finalOutput}\n`);+}+rl.close();\ No newline at end of filediff --git a/fern/snippets/tool-router/typescript/native-tools-vercel.ts b/fern/snippets/tool-router/typescript/native-tools-vercel.tsindex 2eb1f4c23..b933a53e9 100644--- a/fern/snippets/tool-router/typescript/native-tools-vercel.ts+++ b/fern/snippets/tool-router/typescript/native-tools-vercel.ts@@ -1,8 +1,9 @@-import "dotenv/config"; // Load environment variables from .env file+import "dotenv/config";import { Composio } from "@composio/core";import { VercelProvider } from "@composio/vercel";import { openai } from "@ai-sdk/openai";import { generateText } from "ai";+import { createInterface } from "readline/promises";const composio = new Composio({apiKey: process.env.COMPOSIO_API_KEY,@@ -14,11 +15,41 @@ const session = await composio.create("user_123");// Get native tools from Composioconst tools = await session.tools();-// Use with Vercel AI SDK-const result = await generateText({+const messages: any[] = [];++// Execute an initial task that requires GitHub access+console.log("Executing initial task: Fetching GitHub issues...\n");+const initialResult = await generateText({model: openai("gpt-4-turbo"),- prompt: "Fetch all open issues from the composio/composio GitHub repository and create a summary of the top 5 by priority",+ prompt: "Fetch all the open GitHub issues on the composio repository and group them by bugs/features/docs.",tools: tools,});+console.log(`Result: ${initialResult.text}\n`);++// Add initial conversation to history+messages.push(+ { role: "user", content: "Fetch all the open GitHub issues on the composio repository and group them by bugs/features/docs." },+ { role: "assistant", content: initialResult.text }+);++// Continue with interactive conversation+const rl = createInterface({ input: process.stdin, output: process.stdout });+console.log("Assistant: What else would you like me to do? Type 'exit' to end the conversation.\n");++while (true) {+ const userInput = await rl.question("> ");+ if (userInput.toLowerCase() === "exit") break;++ messages.push({ role: "user", content: userInput });++ const result = await generateText({+ model: openai("gpt-4-turbo"),+ messages: messages,+ tools: tools,+ });++ messages.push({ role: "assistant", content: result.text });+ console.log(`Assistant: ${result.text}\n`);+}-console.log(`Assistant: ${result.text}`);\ No newline at end of file+rl.close();\ No newline at end of file