@@ -59,6 +59,7 @@ npm run typecheck # Full TypeScript validation including example/convex
5959- ** Message-centric design** - All operations revolve around message persistence/retrieval
6060- ** Component-based encapsulation** - Uses Convex Components pattern
6161- ** Multi-user support** - Threads have optional ` userId ` for ownership
62+ - ** Tool approval flow** - Tools can require human approval via ` needsApproval ` , with ` agent.approveToolCall() ` and ` agent.denyToolCall() ` methods
6263
6364### Database Tables (Convex Component)
6465
@@ -87,82 +88,94 @@ Follow the rules in `.cursor/rules/convex_rules.mdc`:
8788- ` @convex-dev/agent/validators ` - Convex validators for integration
8889- ` @convex-dev/agent/test ` - Testing utilities
8990
90- ## Upgrading to v0.6.0 (AI SDK v6)
91+ ## AI Guidance: Helping Users Upgrade to v0.6.0
9192
92- When helping users upgrade from @convex-dev/agent v0.3.x to v0.6.0, follow these steps :
93+ When helping users upgrade from @convex-dev/agent v0.3.x (AI SDK v5) to v0.6.0 (AI SDK v6) :
9394
94- ### Step 1: Update dependencies in package.json
95+ ### Step 1: Detect v5 Patterns
9596
96- ``` bash
97- npm install @convex-dev/agent@^0.6.0 ai@^6.0.35 @ai-sdk/provider-utils@^4.0.6
98- ```
97+ Search for these patterns indicating v5 usage:
98+ - ` createTool({ parameters: ` - should be ` inputSchema `
99+ - ` createTool({ handler: ` - should be ` execute `
100+ - ` textEmbeddingModel: ` - should be ` embeddingModel `
101+ - ` maxSteps: ` in generateText/streamText - should be ` stopWhen: stepCountIs(N) `
102+ - ` @ai-sdk/* ` packages at v1.x or v2.x - should be v3.x
103+
104+ ### Step 2: Update Dependencies
99105
100- Also update any AI SDK provider packages:
101106``` bash
102- npm install @ai-sdk/openai@^3.0.10 @ai-sdk/anthropic@^3.0.13
107+ npm install @convex-dev/agent@^0.6.0 ai@^6.0.35 @ai-sdk/provider-utils@^4.0.6
108+ npm install @ai-sdk/openai@^3.0.10 # or whichever provider
103109```
104110
105- ### Step 2: Update tool definitions
106-
107- Replace ` parameters ` with ` inputSchema ` :
111+ ### Step 3: Apply Transformations
108112
113+ ** Tool definitions:**
109114``` typescript
110- // Before (v5)
115+ // BEFORE (v5)
111116const myTool = createTool ({
112117 description: " ..." ,
113118 parameters: z .object ({ query: z .string () }),
114- execute : async (ctx , args ) => { ... }
119+ handler : async (ctx , args ) => {
120+ return args .query .toUpperCase ();
121+ }
115122})
116123
117- // After (v6)
124+ // AFTER (v6)
118125const myTool = createTool ({
119126 description: " ..." ,
120127 inputSchema: z .object ({ query: z .string () }),
121- execute : async (ctx , input , options ) => { ... }
128+ execute : async (ctx , input , options ) => {
129+ return input .query .toUpperCase ();
130+ }
122131})
123132```
124133
125- ### Step 3: Update maxSteps usage (if applicable)
134+ ** Agent embedding config:**
135+ ``` typescript
136+ // BEFORE
137+ new Agent (components .agent , {
138+ textEmbeddingModel: openai .embedding (" text-embedding-3-small" )
139+ })
140+
141+ // AFTER
142+ new Agent (components .agent , {
143+ embeddingModel: openai .embedding (" text-embedding-3-small" )
144+ })
145+ ```
126146
147+ ** Step limits:**
127148``` typescript
128- // Before (v5)
149+ // BEFORE
129150await agent .generateText (ctx , { threadId }, {
130151 prompt: " ..." ,
131152 maxSteps: 5
132153})
133154
134- // After (v6) - maxSteps still works but stopWhen is preferred
135- import { stepCountIs } from " ai "
155+ // AFTER
156+ import { stepCountIs } from " @convex-dev/agent "
136157await agent .generateText (ctx , { threadId }, {
137158 prompt: " ..." ,
138159 stopWhen: stepCountIs (5 )
139160})
140161```
141162
142- ### Step 4: Update embedding model config (optional)
143-
144- ``` typescript
145- // Before
146- new Agent (components .agent , {
147- textEmbeddingModel: openai .embedding (" text-embedding-3-small" )
148- })
149-
150- // After (textEmbeddingModel still works but embeddingModel is preferred)
151- new Agent (components .agent , {
152- embeddingModel: openai .embedding (" text-embedding-3-small" )
153- })
154- ```
155-
156- ### Step 5: Verify the upgrade
163+ ### Step 4: Verify
157164
158165``` bash
159166npm run typecheck
160- npm run lint
161167npm test
162168```
163169
164- ### Common issues
170+ ### Common Issues
171+
172+ - ** EmbeddingModelV2 vs V3 errors** : Ensure all ` @ai-sdk/* ` packages are v3.x
173+ - ** Tool ` args ` vs ` input ` ** : v6 uses ` input ` in execute signature (2nd param)
174+ - ** ` mimeType ` vs ` mediaType ` ** : v6 prefers ` mediaType ` (backwards compat maintained)
175+
176+ ### New v6 Features to Mention
165177
166- - ** EmbeddingModelV2 vs V3 errors** : Ensure all @ai-sdk /* packages are updated to v3.x
167- - ** Tool input/args** : v6 uses ` input ` instead of ` args ` in tool calls (backwards compat maintained)
168- - ** mimeType vs mediaType** : v6 uses ` mediaType ` (backwards compat maintained)
178+ After upgrade, users can now use:
179+ - ** Tool approval** : ` needsApproval ` in createTool, ` agent.approveToolCall() ` , ` agent.denyToolCall() `
180+ - ** Reasoning streaming** : Works with models like Groq that support reasoning
181+ - ** Detailed token usage** : ` inputTokenDetails ` , ` outputTokenDetails ` in usage tracking
0 commit comments