@convex-dev/agent
Version:
A agent component for Convex.
154 lines (110 loc) • 3.96 kB
Markdown
This guide helps you upgrade from @convex-dev/agent v0.3.x to v0.6.0.
Update all AI SDK packages **together** to avoid peer dependency conflicts:
```bash
npm install @convex-dev/agent@^0.6.0 ai@^6.0.35 @ai-sdk/provider-utils@^4.0.6
```
Update your AI SDK provider packages to v3.x:
```bash
npm install @ai-sdk/openai@^3.0.10
npm install @ai-sdk/anthropic@^3.0.13
npm install @ai-sdk/groq@^3.0.8
npm install @ai-sdk/google@^3.0.8
```
Third-party providers also need updates to be compatible with AI SDK v6:
```bash
npm install @openrouter/ai-sdk-provider@^2.0.0
```
If you see peer dependency warnings or errors, try updating all packages at once:
```bash
npm install @convex-dev/agent@^0.6.0 ai@^6.0.35 @ai-sdk/openai@^3.0.10 @openrouter/ai-sdk-provider@^2.0.0
```
If you still have conflicts, you can use `--force` as a last resort:
```bash
npm install @convex-dev/agent@^0.6.0 --force
```
> **Note**: Using `--force` can lead to inconsistent dependency trees. After using it, verify your app works correctly and consider running `npm dedupe` to clean up.
Replace `parameters` with `inputSchema`:
```typescript
// Before (v5)
const myTool = createTool({
description: "My tool",
parameters: z.object({ query: z.string() }),
execute: async (ctx, args) => { ... }
})
// After (v6)
const myTool = createTool({
description: "My tool",
inputSchema: z.object({ query: z.string() }),
execute: async (ctx, input, options) => { ... }
})
```
```typescript
// Before
new Agent(components.agent, {
textEmbeddingModel: openai.embedding("text-embedding-3-small")
})
// After
new Agent(components.agent, {
embeddingModel: openai.embedding("text-embedding-3-small")
})
```
```typescript
// Before
await agent.generateText(ctx, { threadId }, {
prompt: "...",
maxSteps: 5
})
// After (maxSteps still works, but stopWhen is preferred)
import { stepCountIs } from "ai"
await agent.generateText(ctx, { threadId }, {
prompt: "...",
stopWhen: stepCountIs(5)
})
```
```bash
npm run typecheck
npm test
```
Ensure all `@ai-sdk/*` packages are updated to v3.x. Older versions use AI SDK v5 types.
### Tool `args` vs `input`
AI SDK v6 renamed `args` to `input` in tool calls. The library maintains backwards compatibility, but you may see this in types.
### `mimeType` vs `mediaType`
AI SDK v6 renamed `mimeType` to `mediaType`. Backwards compatibility is maintained.
### Peer dependency conflicts
If you see errors like:
```
npm error ERESOLVE unable to resolve dependency tree
npm error peer ai@"^5.0.0" from @openrouter/ai-sdk-provider@1.0.3
```
This means a third-party provider needs updating. Common solutions:
1. **Update the provider** to a version compatible with AI SDK v6
2. **Check npm** for the latest version: `npm view @openrouter/ai-sdk-provider versions`
3. **Use `--force`** if a compatible version isn't available yet (temporary workaround)
### Third-party provider compatibility
| Provider | AI SDK v5 (ai@5.x) | AI SDK v6 (ai@6.x) |
|----------|-------------------|-------------------|
| @openrouter/ai-sdk-provider | v1.x | v2.x |
| @ai-sdk/openai | v1.x-v2.x | v3.x |
| @ai-sdk/anthropic | v1.x-v2.x | v3.x |
| @ai-sdk/groq | v1.x-v2.x | v3.x |
| @ai-sdk/google | v1.x-v2.x | v3.x |
## More Information
- [AI SDK v6 Migration Guide](https://ai-sdk.dev/docs/migration-guides/migration-guide-6-0)
- [Convex Agent Documentation](https://docs.convex.dev/agents)