https://linen.dev logo
Composio tools throwing formatting error in Vercel...
# 🖥│support-forum
r
Hi all, I'd like to use the latest version of the vercel ai sdk (v5) with composio - is there any update on compatibility? It seems like composio tools no longer work out of the box given how the ai sdk is structuring the tool calls. For example, the following code snippet doesn't work out of the box
Copy code
@typescript
const composioTools = await getComposioTools(session.user.id, enabledToolkits);

const result = streamText({
    model: openai('gpt-4.1-nano'),
    system: systemPrompt({
      requestHints,
      agent,
    }),
    messages: convertToModelMessages(messages),
    tools: {
      ...composioTools
    },
It throws the following error:
Copy code
'{\n' +
    '  "error": {\n' +
    `    "message": "Invalid schema for function 'GMAIL_CREATE_EMAIL_DRAFT': schema must be a JSON Schema of 'type: \\"object\\"', got 'type: \\"None\\"'.",\n` +
    '    "type": "invalid_request_error",\n' +
    '    "param": "tools[0].parameters",\n' +
    '    "code": "invalid_function_parameters"\n' +
    '  }\n' +
    '}',
Instead I need to reformat the tools to look like the following in order to use it, ex:
Copy code
@typescript
const gmailCreateDraftTool = tool({
      description: composioTools['GMAIL_CREATE_EMAIL_DRAFT']?.description,
      inputSchema: jsonSchema(
        composioTools['GMAIL_CREATE_EMAIL_DRAFT']?.parameters?.jsonSchema
      ),
      execute: composioTools['GMAIL_CREATE_EMAIL_DRAFT'].execute
    })

const result = streamText({
    model: openai('gpt-4.1-nano'),
    system: systemPrompt({
      requestHints,
      agent,
    }),
    messages: convertToModelMessages(messages),
    tools: {
      gmailCreateDraftTool
    },
packages:
ai@5.0.0-beta.33
@ai-sdk/openai@2.0.0-beta.15
@composio/core@0.1.39
@composio/vercel@0.1.39
c
Hi Kristen, Thanks for bringing this to my attention. I’ve escalated the issue to the engineering team, and they’ll be working on a fix. I’ll keep you updated!
r
awesome, thanks so much!
g
@udaysidagana any update on this?
a
not yet, Let me check and get back soon
k
c
Hi folks, support for AI SDK v5 has been added. You can install the latest
@composio/vercel@0.2.0
SDK. Let me know if you face any issues.
r
I'm seeing this error [Error [AI_APICallError]: Invalid schema for function 'GMAIL_CREATE_EMAIL_DRAFT': schema must be a JSON Schema of 'type: "object"', got 'type: "None"'.] {
a
Hey! Can you share the reproducible code snippet with package versions? Thanks
r
Essentially doing something lie this:
Copy code
import composio from '@/lib/services/composio'

export async function getComposioTools(userId: string) {
  try {
    const tools = await composio.tools.get(userId, {
      tools: ['GMAIL_CREATE_EMAIL_DRAFT'],
    })

    return tools || {}
  } catch (error) {
    console.error('Failed to fetch Composio tools:', error)
    return {}
  }
}
and then in my /chat route:
Copy code
const tools = await getComposioTools(session.user.id)

  const result = streamText({
    model: openai.responses('gpt-4.1'),
    system: await systemPrompt({
      requestHints,
      agent: agent,
    }),
    messages: convertToModelMessages(messages),
    tools,
...
Copy code
"@composio/core": "0.1.46",
    "@composio/vercel": "0.2.2",
c
thanks for the details, we'll take a look into it.
Hey Kristen, just checking, could you let me know if you are still facing the issue?
l
Do you need developer?