Conversation
Co-authored-by: zboyles <2215540+zboyles@users.noreply.github.com>
Co-authored-by: zboyles <2215540+zboyles@users.noreply.github.com>
Document version alignment strategy with AI SDK in CHANGELOG
Co-authored-by: zboyles <2215540+zboyles@users.noreply.github.com>
- Update LanguageModelV2 to LanguageModelV3 in mockModel.ts - Update example type declarations to use LanguageModelV3 - Add embeddingModel to Config (deprecate textEmbeddingModel) - Update Agent class to support both embeddingModel and textEmbeddingModel - Remove mode field from generateObject call (deprecated in v6) - Update search.ts and saveInputMessages.ts to support both embedding fields Co-authored-by: zboyles <2215540+zboyles@users.noreply.github.com>
Remove @openrouter/ai-sdk-provider dependency and migrate to AI SDK v3
Trigger pkg pr new build for the AI SDK v6 update
Co-authored-by: zboyles <2215540+zboyles@users.noreply.github.com>
…referred key Co-authored-by: zboyles <2215540+zboyles@users.noreply.github.com>
Update AI SDK packages to latest versions
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
🔥 |
Two fixes: 1. normalizeToolResult in mapping.ts was stripping the isError flag. Now preserves isError when transforming tool result parts. 2. createAssistantUIMessage in UIMessages.ts now checks contentPart.isError in addition to message.error when determining tool state. This ensures tool results with isError: true show "output-error" state instead of incorrectly showing "output-available". Fixes get-convex#162 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…written at index 0
…r reporting in UIMessages
…mpatibility Co-authored-by: zboyles <2215540+zboyles@users.noreply.github.com>
Co-authored-by: zboyles <2215540+zboyles@users.noreply.github.com>
…-213 Merge upstream PRs get-convex#211, get-convex#212, and get-convex#213 created by @sethconvex
|
Merged recent PRs, #211, #212, & #213 from @sethconvex, applying minor compatibility update to support AI SDK v6 |
|
To help test these latest additions, replace your npm i https://pkg.pr.new/zboyles/agent/@convex-dev/agent@e03ecf6
# or with bun, etc
bun add https://pkg.pr.new/zboyles/agent/@convex-dev/agent@e03ecf6 |
Co-authored-by: zboyles <2215540+zboyles@users.noreply.github.com>
|
Hey this is great. When will it be ready? |
…in generated types. Ran `convex codegen --component-dir ./src/component`.
…itions for consistency
Co-authored-by: zboyles <2215540+zboyles@users.noreply.github.com>
…esult output types Co-authored-by: zboyles <2215540+zboyles@users.noreply.github.com>
…plan Fix AI SDK v6 type errors: tool-call input/args union type and tool-result output types
[WIP] Update createTool to support AI SDK v5 and v6 features
- Implemented handling of `tool-approval-request` and `tool-approval-response` in `deltas.ts` to update tool state accordingly. - Enhanced tests in `deltas.test.ts` and `toUIMessages.test.ts` to verify the approval workflow, including state transitions for approval requests and responses. - Updated `UIMessages.ts` to manage tool approval states and responses, ensuring correct state updates for tool calls based on approval outcomes.
@alioftech That said, the zboyles/ai-sdk-v6/add-tool-approval branch is trying to plug the gaps in tool approval support. The latest commit has the tests passing and I've installed in into my project locally without any schema warnings or type errors (other than the preexisting If you want to join in to help test an approval process, install with: npm i https://pkg.pr.new/zboyles/agent/@convex-dev/agent@502d9d8Let me know if you get any schema warnings or type errors - and hopefully any success. And obviously backup and all that 😉 |
…t` and `tool-approval-response`.
…tToolApprovals`. Without the fix, the tool call was being filtered out because it had no tool-result, even though it had an approval response - which caused the SDK to fail at line 91 in `ai/src/generate-text/collect-tool-approvals.ts`.
…rove deprecation handling.
…result errors since stored messages have the complete data.
… tool approval, as stored messages contain complete context.
Tool approval flow is working to the point a call is approved, assuming the user sends the tool approval response (save message/start streaming), this will automatically execute the tool and save the results to messages and stops the response before sharing the results with the model. Need to investigate continuing the stream as in multi-step tool calls.
|
@ianmacartney @sethconvex The approval flow works correctly, when The AI SDK has the helper function |
commit: |
|
I'll be taking a look at this pr today @zboyles what outstanding tasks do you think are left to get it over the finish line? |
|
Hey @sethconvex, The MVP work is essentially done, with the build and tests completing without errors, the validators all setup with unions for schema backwards compatibility for existing data, and Remaining Questions (Nice-to-have)The one open item I'd really like to improve prior to a merge is tool call approval continuation. Technically tool approvals are functional however the execution stops at an inconvenient time. When a user approves a tool call, it executes and results are saved to If you have a chance and could take a look at it, I'd appreciate it. The AI SDK has an optional helper function The other high priority feature, but one that can wait for a future update, is streaming data parts. I was hoping to look into it today but was held up with other tasks. Other Issues
|
@zboyles this could be related vercel/ai#11966 |
|
I've built an rc branch on top of this, and have a WIP PR that adds tool approval #217 |
|
@delta575 I think the issue was caused by the native process handling the tool execution as it would add the result without the tool approval response tool content part. The AI SDK docs tell you to just add it but they have functions that modify the message, in our situation, it was being added as a separate message and staying separate. Seth made a function that executes the tool then puts all the tool content parts together in the same message. |
## Summary Upgrades `@convex-dev/agent` to support AI SDK v6, dropping support for AI SDK v5. Fixes #202 Based on @zboyles's work in #208, merged with latest main and lint/typecheck fixes. ## Breaking Changes - Requires AI SDK v6 (`ai@^6.0.35`) - Drops support for AI SDK v5 - Package version jumps to 0.6.0 to align with AI SDK major version ## Key Changes - Updates message and tool invocation types to align with AI SDK v6 - Adds tool approval workflow support (`tool-approval-request`, `tool-approval-response`) - `inputSchema` replaces `parameters` in tool definitions - `input` replaces `args` in tool calls (with backwards compat) - `mediaType` replaces `mimeType` (with backwards compat) - New `embeddingModel` config option (deprecates `textEmbeddingModel`) ## Migration See the [AI SDK v6 migration guide](https://ai-sdk.dev/docs/migration-guides/migration-guide-6-0) for details on AI SDK changes. ## Test plan - [x] `npm run typecheck` passes - [x] `npm run lint` passes - [x] All 212 tests pass - [ ] Manual testing with real providers (OpenAI, Anthropic) - [ ] Test tool approval workflow 🤖 Generated with [Claude Code](https://claude.ai/code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Tool approval workflow (request/response/denial), richer tool hooks, inputSchema/input support, and needsApproval. * Unified embeddingModel support and LanguageModel V3 mock behavior. * **Breaking Changes** * Bumped to 0.6.0; AI SDK v6 required. * textEmbeddingModel → embeddingModel; args → input (deprecated). * mimeType → mediaType for file metadata; stopWhen/stepCountIs replaces maxSteps. * **Bug Fixes** * Improved streaming, async message handling, error suppression, and orphaned tool-message handling. * **Documentation** * Added MIGRATION.md, updated usage and agent/docs. <!-- end of auto-generated comment: release notes by coderabbit.ai -->

This draft pull request upgrades the
@convex-dev/agentpackage to version 0.6.0, aligning it with AI SDK v6 for improved compatibility and developer clarity. It introduces breaking changes, updates dependencies, and revises internal APIs and documentation to match the new AI SDK v6 standards. The most important changes are grouped at the bottom.Consider this an extremely rough draft that could use with people testing it. Anyone interested, use the pkg-pr-new below or whatever the most recent version. If you do find yourself installing to help test, follow the Vercel v6 migration guide. I've performed very minimal testing so far and haven't tried functionality like the
approval-requestedstate so please try the new features and provide feedback.Versioning and Compatibility
API and Type Updates
ToolExecutionOptionsinstead ofToolCallOptionsandinputSchemainstead ofparameters. [1] [2] [3] [4] [5] [6] [7]Dependency and Example Updates
moduleResolution: "bundler").Documentation Improvements
maxStepswithstopWhen: stepCountIs(...)and updating tool definitions to useinputSchema. [1] [2] [3] [4]Internal Refactoring and Bugfixes
These changes collectively ensure that the package is fully compatible with AI SDK v6, simplifies integration, and provides clearer guidance and improved developer experience.
This pull request is a major release (v0.6.0) of the
@convex-dev/agentpackage, aligning its versioning with AI SDK v6 for clearer compatibility. It drops support for AI SDK v5, updates dependencies and types to match the new SDK, and revises documentation and examples to reflect these changes. There are also improvements to tool definitions, internal helper functions, and type usage for better integration and developer experience.Versioning and Compatibility Updates
0.6.0to match AI SDK v6, with clear documentation about the versioning strategy and migration steps. Support for AI SDK v5 is dropped, requiring all projects to upgrade their dependencies before updating this package. (CHANGELOG.md,package.json) [1] [2]Dependency and Type Updates
package.json,example/convex/modelsForDemo.ts) [1] [2] [3] [4]Tool Definition and Usage Improvements
inputSchemainstead ofparameters, and the tool handler options now useToolExecutionOptions(from AI SDK v6) instead of the deprecatedToolCallOptions. Documentation and examples are revised to demonstrate these changes. (docs/agent-usage.mdx,docs/tools.mdx,src/client/createTool.ts) [1] [2] [3]Agent Configuration and API Changes
stopWhen: stepCountIs(n)instead ofmaxSteps, and examples are updated to show the new usage pattern. (docs/agent-usage.mdx,docs/getting-started.mdx) [1] [2]Internal Helper and Type Improvements
getEmbeddingModelmethod. (src/client/index.ts)