Rename agent tool properties and switch to OpenAI-compatible provider#846
Conversation
…patible provider Rename `args` to `inputSchema` and `handler` to `execute` across all agent tools to align with AI SDK conventions. Switch from @ai-sdk/openai to @ai-sdk/openai-compatible for native reasoning_content extraction support.
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
📝 WalkthroughWalkthroughThis PR systematically refactors the agent tool framework integration across the codebase by updating the Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@services/platform/convex/agent_tools/files/pptx_tool.ts`:
- Around line 186-187: The createTool call is using AI SDK names
inputSchema/execute instead of Convex's expected args/handler; update the
createTool properties so that inputSchema: pptxArgs becomes args: pptxArgs and
execute: async (ctx: ToolCtx, args) becomes handler: async (ctx: ToolCtx, args)
(preserve the Promise<PptxResult> return type and ToolCtx/ pptxArgs symbols) so
the handler signature and types match the `@convex-dev/agent` API.
In
`@services/platform/convex/agent_tools/human_input/request_human_input_tool.ts`:
- Around line 162-163: The createTool call is using Vercel SDK prop names;
change inputSchema to args (use the existing Zod schema requestHumanInputArgs)
and change execute to handler (make the async function currently assigned to
execute the handler function), and update the function signature of that async
function to accept (ctx, args) or the Convex expected parameters so the Convex
context is passed correctly; locate the createTool invocation and the async
function around the symbols createTool, requestHumanInputArgs, and the current
execute function and replace those property names and signature accordingly.
In `@services/platform/convex/lib/create_agent_config.ts`:
- Around line 187-189: Update the conditional config property name from
embeddingModel to textEmbeddingModel in the agent config spread so it matches
the `@convex-dev/agent` v0.6.0 API; specifically, change the object created when
embeddingModel is truthy (the spread that currently yields { embeddingModel:
openai.textEmbeddingModel(embeddingModel) }) to instead produce {
textEmbeddingModel: openai.textEmbeddingModel(embeddingModel) } so the call
using openai.textEmbeddingModel and the embeddingModel variable remain the same
but the property key matches the library.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: ccb145e3-5672-47a5-9509-ed782a90b49e
⛔ Files ignored due to path filters (2)
bun.lockis excluded by!**/*.lockservices/platform/convex/_generated/api.d.tsis excluded by!**/_generated/**
📒 Files selected for processing (44)
services/platform/convex/agent_tools/create_json_output_tool.tsservices/platform/convex/agent_tools/customers/customer_read_tool.tsservices/platform/convex/agent_tools/database/database_schema_tool.tsservices/platform/convex/agent_tools/delegation/create_delegation_tool.tsservices/platform/convex/agent_tools/documents/__tests__/document_write_tool.test.tsservices/platform/convex/agent_tools/documents/document_find_tool.tsservices/platform/convex/agent_tools/documents/document_retrieve_tool.tsservices/platform/convex/agent_tools/documents/document_write_tool.tsservices/platform/convex/agent_tools/files/docx_tool.tsservices/platform/convex/agent_tools/files/excel_tool.tsservices/platform/convex/agent_tools/files/helpers/analyze_text.tsservices/platform/convex/agent_tools/files/helpers/vision_agent.tsservices/platform/convex/agent_tools/files/image_tool.tsservices/platform/convex/agent_tools/files/pdf_tool.tsservices/platform/convex/agent_tools/files/pptx_tool.tsservices/platform/convex/agent_tools/files/text_tool.tsservices/platform/convex/agent_tools/human_input/request_human_input_tool.tsservices/platform/convex/agent_tools/integrations/create_bound_integration_tool.tsservices/platform/convex/agent_tools/integrations/integration_batch_tool.tsservices/platform/convex/agent_tools/integrations/integration_introspect_tool.tsservices/platform/convex/agent_tools/integrations/integration_tool.tsservices/platform/convex/agent_tools/location/request_user_location_tool.tsservices/platform/convex/agent_tools/products/product_read_tool.tsservices/platform/convex/agent_tools/rag/rag_search_tool.tsservices/platform/convex/agent_tools/web/web_tool.tsservices/platform/convex/agent_tools/workflows/__tests__/create_bound_workflow_tool.test.tsservices/platform/convex/agent_tools/workflows/__tests__/create_workflow_tool.test.tsservices/platform/convex/agent_tools/workflows/__tests__/run_workflow_tool.test.tsservices/platform/convex/agent_tools/workflows/__tests__/save_workflow_definition_tool.test.tsservices/platform/convex/agent_tools/workflows/__tests__/update_workflow_step_tool.test.tsservices/platform/convex/agent_tools/workflows/__tests__/workflow_syntax_tool.test.tsservices/platform/convex/agent_tools/workflows/create_bound_workflow_tool.tsservices/platform/convex/agent_tools/workflows/create_workflow_tool.tsservices/platform/convex/agent_tools/workflows/run_workflow_tool.tsservices/platform/convex/agent_tools/workflows/save_workflow_definition_tool.tsservices/platform/convex/agent_tools/workflows/update_workflow_step_tool.tsservices/platform/convex/agent_tools/workflows/workflow_read_tool.tsservices/platform/convex/agent_tools/workflows/workflow_syntax_tool.tsservices/platform/convex/conversations/improve_message.tsservices/platform/convex/lib/create_agent_config.tsservices/platform/convex/lib/openai_provider.tsservices/platform/convex/lib/summarize_context.tsservices/platform/convex/workflows/triggers/actions.tsservices/platform/package.json
| inputSchema: pptxArgs, | ||
| execute: async (ctx: ToolCtx, args): Promise<PptxResult> => { |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check for the createTool type definitions in the installed package
fd -t f -e ts -e d.ts . node_modules/@convex-dev/agent --exec grep -l "createTool" {} \; 2>/dev/null | head -5 | xargs -I {} sh -c 'echo "=== {} ===" && grep -A 20 "createTool" {}'Repository: tale-project/tale
Length of output: 43
🌐 Web query:
@convex-dev/agent createTool inputSchema execute API 2026
💡 Result:
In Convex Agents (@convex-dev/agent), the Convex-aware helper is:
createTool({ args, handler, description })(Convex context injected)
import { createTool } from "@convex-dev/agent";
import { z } from "zod/v3";
export const ideaSearch = createTool({
description: "Search for ideas in the database",
args: z.object({ query: z.string().describe("Search query") }),
handler: async (ctx, args, options): Promise<Idea[]> => {
return await ctx.runQuery(api.ideas.searchIdeas, { query: args.query });
},
});createTool is a wrapper around the AI SDK tool system; its args is the Zod schema and handler is the implementation. [1]
If you specifically want the inputSchema / execute style, that’s the AI SDK’s plain tool API (no automatic Convex context injection), which Convex docs show alongside createTool:
import { tool } from "ai";
import { z } from "zod/v3";
const myTool = tool({
description: "My tool",
parameters: z.object({ /* ... */ }),
execute: async (args, options) => { /* ... */ },
});
``` [2]
**Mapping:**
- `inputSchema` (your term) ≈ AI SDK `parameters` ≈ Convex `args`
- `execute` ≈ AI SDK `execute` ≈ Convex `handler` [1][2]
**Sources:**
[1] Convex Agents “Tools” docs (createTool/args/handler; AI SDK execute example)
[2] Convex Agents “Agent Usage” docs (shows mixing `createTool(...)` and `tool({ parameters, execute })`)
---
🏁 Script executed:
```shell
cat -n services/platform/convex/agent_tools/files/pptx_tool.ts | head -200Repository: tale-project/tale
Length of output: 8732
🏁 Script executed:
cat package.json | grep -A 2 -B 2 "@convex-dev/agent"Repository: tale-project/tale
Length of output: 43
🏁 Script executed:
git log --oneline services/platform/convex/agent_tools/files/pptx_tool.ts | head -5Repository: tale-project/tale
Length of output: 142
Property names are incorrect for the createTool API.
The code at lines 186–187 uses inputSchema and execute, which are AI SDK property names, not createTool property names. Since this file imports and uses createTool from @convex-dev/agent (line 9) and the function signature includes ctx: ToolCtx (line 187) indicating Convex context injection, the correct property names should be:
args: pptxArgs,(notinputSchema)handler: async (ctx: ToolCtx, args)(notexecute)
Per the @convex-dev/agent API documentation, createTool expects args and handler, not inputSchema and execute.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@services/platform/convex/agent_tools/files/pptx_tool.ts` around lines 186 -
187, The createTool call is using AI SDK names inputSchema/execute instead of
Convex's expected args/handler; update the createTool properties so that
inputSchema: pptxArgs becomes args: pptxArgs and execute: async (ctx: ToolCtx,
args) becomes handler: async (ctx: ToolCtx, args) (preserve the
Promise<PptxResult> return type and ToolCtx/ pptxArgs symbols) so the handler
signature and types match the `@convex-dev/agent` API.
| inputSchema: requestHumanInputArgs, | ||
| execute: async ( |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
@convex-dev/agent createTool inputSchema execute API
💡 Result:
In @convex-dev/agent, createTool does not use inputSchema / execute. It wraps the Vercel AI SDK tool() API, but the Convex wrapper’s fields are:
args: a Zod schema for the tool input (this is the equivalent of “input schema”)handler: the function that runs the tool (this is the equivalent of “execute”), and it receives Convex tool context (ctx) plus the validated args (and optional AI-SDK options/messages)
Example (Convex tool wrapper):
import { createTool } from "@convex-dev/agent";
import { z } from "zod/v3";
export const ideaSearch = createTool({
description: "Search for ideas in the database",
args: z.object({ query: z.string() }),
handler: async (ctx, args, options) => {
return await ctx.runQuery(api.ideas.searchIdeas, { query: args.query });
},
});This is contrasted with the underlying AI SDK form, which uses parameters (schema) and execute (runner). (docs.convex.dev)
Citations:
🏁 Script executed:
# First, find the file and check its content around the changed lines
find . -type f -name "request_human_input_tool.ts" -path "*/human_input/*"Repository: tale-project/tale
Length of output: 139
🏁 Script executed:
# Read the file content around lines 162-163
sed -n '155,175p' ./services/platform/convex/agent_tools/human_input/request_human_input_tool.tsRepository: tale-project/tale
Length of output: 986
🏁 Script executed:
# Check the package.json or dependencies for `@convex-dev/agent` version
find . -name "package.json" -type f | head -5 | xargs grep -l "@convex-dev/agent"Repository: tale-project/tale
Length of output: 93
🏁 Script executed:
# Check the `@convex-dev/agent` version in the package.json
grep "@convex-dev/agent" ./services/platform/package.jsonRepository: tale-project/tale
Length of output: 95
🏁 Script executed:
# Check the createTool import and surrounding context
sed -n '1,20p' ./services/platform/convex/agent_tools/human_input/request_human_input_tool.tsRepository: tale-project/tale
Length of output: 773
Fix property names in createTool call: use args and handler instead of inputSchema and execute.
The @convex-dev/agent library's createTool function expects args (Zod schema) and handler (async function), not inputSchema and execute. The latter are properties from the underlying Vercel AI SDK, but the Convex wrapper deliberately uses args and handler to integrate Convex context. Update lines 162–163 and the corresponding function signature to use the correct property names.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@services/platform/convex/agent_tools/human_input/request_human_input_tool.ts`
around lines 162 - 163, The createTool call is using Vercel SDK prop names;
change inputSchema to args (use the existing Zod schema requestHumanInputArgs)
and change execute to handler (make the async function currently assigned to
execute the handler function), and update the function signature of that async
function to accept (ctx, args) or the Convex expected parameters so the Convex
context is passed correctly; locate the createTool invocation and the async
function around the symbols createTool, requestHumanInputArgs, and the current
execute function and replace those property names and signature accordingly.
| ...(embeddingModel | ||
| ? { textEmbeddingModel: openai.embedding(embeddingModel) } | ||
| ? { embeddingModel: openai.textEmbeddingModel(embeddingModel) } | ||
| : {}), |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
@convex-dev/agent 0.6.0 embedding model configuration property name
💡 Result:
In @convex-dev/agent, the configuration property for the embedding model is:
textEmbeddingModel(passed in theAgentconstructor config / sharedConfig) [1][2]
Example: textEmbeddingModel: openai.embedding("text-embedding-3-small") [1]
Sources:
[1] (docs.convex.dev)
[2] (docs.convex.dev)
Citations:
- 1: https://docs.convex.dev/agents/agent-usage?utm_source=openai
- 2: https://docs.convex.dev/agents/context?utm_source=openai
Change the property name from embeddingModel to textEmbeddingModel.
The official @convex-dev/agent v0.6.0 documentation specifies the configuration property must be named textEmbeddingModel, not embeddingModel. Update line 188 to use the correct property name.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@services/platform/convex/lib/create_agent_config.ts` around lines 187 - 189,
Update the conditional config property name from embeddingModel to
textEmbeddingModel in the agent config spread so it matches the
`@convex-dev/agent` v0.6.0 API; specifically, change the object created when
embeddingModel is truthy (the spread that currently yields { embeddingModel:
openai.textEmbeddingModel(embeddingModel) }) to instead produce {
textEmbeddingModel: openai.textEmbeddingModel(embeddingModel) } so the call
using openai.textEmbeddingModel and the embeddingModel variable remain the same
but the property key matches the library.
Summary
args→inputSchemaandhandler→executeacross all agent tools to align with AI SDK conventions@ai-sdk/openaito@ai-sdk/openai-compatiblefor nativereasoning_contentextraction supportTest plan
Summary by CodeRabbit
Release Notes
Note: This release includes internal refactoring and dependency updates. No user-facing features or functionality changes.