#Tools compatibility issue, vercel ai, Cannot read properties of undefined (reading '_def')

1 messages · Page 1 of 1 (latest)

open summit
#

"@composio/core": "^0.1.53",
"@composio/vercel": "^0.2.9",
"ai": "^4.2.9",
"@ai-sdk/anthropic": "^1.2.8",

"use server"
import { Composio } from '@composio/core';
import { generateText } from 'ai';
import { anthropic } from '@ai-sdk/anthropic';
import { VercelProvider } from '@composio/vercel';

type TestResult = {
success: boolean
result: string | null
error?: string
toolsCount: number
}

export async function runComposioTest(): Promise<TestResult> {
try {
// Use a unique identifier for each user in your application
const userId = '';

    // Initialize Composio toolset
    const composio = new Composio({
        apiKey: process.env.COMPOSIO_API_KEY,
        provider: new VercelProvider(),
    });

    // Get all tools for the user
    const tools = await composio.tools.get(userId, {
        toolkits: ['linear'],
        limit: 10,
    });

    console.log(tools)

    // Generate a deep research on hackernews
    const { text } = await generateText({
        model: anthropic('claude-sonnet-4-20250514'),
        messages: [
            {
                role: 'user',
                content: 'test linear tools',
            },
        ],
        tools,
    });

    return {
        success: true,
        result: text,
        toolsCount: Array.isArray(tools) ? tools.length : 0
    };
} catch (error) {
    console.error('Error running Composio test:', error);
    return {
        success: false,
        error: error instanceof Error ? error.message : 'Unknown error occurred',
        result: null,
        toolsCount: 0
    };
}

}

#

Error running Composio test: TypeError: Cannot read properties of undefined (reading '_def')
at Array.map (<anonymous>)
at async runComposioTest (file://C%3A/Users/sagar/Desktop/development/work/nextjs/swarm/new/SwarmLabs/reasoning-stack/src/lib/test.ts:35:25)
33 |
34 | // Generate a deep research on hackernews

35 | const { text } = await generateText({
| ^
36 | model: anthropic('claude-sonnet-4-20250514'),
37 | messages: [
38 | {

tame loomBOT
#

Hey there, looks like your ai lib is not latest, could you try updating your ai to latest?
"ai": "^5.0.60"

open summit
#

could you please confirm is the tools are not compatible with v4, is it mandatory to use v5 of vercel ai

tame loomBOT
#

Hey, some tools might not be compatible with v4. We recommend using v5, alternatively you can use an older version of the SDK.

open summit