Skip to content

Rename agent tool properties and switch to OpenAI-compatible provider#846

Merged
larryro merged 2 commits into
mainfrom
feat/agent-tools-ai-sdk-refactor
Mar 24, 2026
Merged

Rename agent tool properties and switch to OpenAI-compatible provider#846
larryro merged 2 commits into
mainfrom
feat/agent-tools-ai-sdk-refactor

Conversation

@larryro
Copy link
Copy Markdown
Collaborator

@larryro larryro commented Mar 24, 2026

Summary

  • Rename argsinputSchema and handlerexecute 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
  • Enable structured outputs for the OpenAI-compatible provider

Test plan

  • Verify agent tool execution works end-to-end with the renamed properties
  • Confirm structured output responses are correctly parsed
  • Test reasoning content extraction from compatible models

Summary by CodeRabbit

Release Notes

  • Chores
    • Updated AI framework dependencies and agent tool infrastructure
    • Modernized OpenAI provider integration for improved compatibility

Note: This release includes internal refactoring and dependency updates. No user-facing features or functionality changes.

larryro added 2 commits March 24, 2026 17:57
…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.
Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 24, 2026

📝 Walkthrough

Walkthrough

This PR systematically refactors the agent tool framework integration across the codebase by updating the createTool configuration API. The primary changes involve renaming args to inputSchema and handler to execute in approximately 35 tool definitions and their corresponding tests. Additionally, the PR updates OpenAI model initialization from openai.chat() to openai.chatModel() and switches the provider implementation from @ai-sdk/openai to @ai-sdk/openai-compatible. Dependency versions are bumped accordingly, including @convex-dev/agent to ^0.6.0 and ai to ^6.0.35. All underlying function logic and control flow remain unchanged.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the two main changes: renaming agent tool properties (args→inputSchema, handler→execute) and switching to OpenAI-compatible provider.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/agent-tools-ai-sdk-refactor

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between adf3b38 and 9b713c9.

⛔ Files ignored due to path filters (2)
  • bun.lock is excluded by !**/*.lock
  • services/platform/convex/_generated/api.d.ts is excluded by !**/_generated/**
📒 Files selected for processing (44)
  • services/platform/convex/agent_tools/create_json_output_tool.ts
  • services/platform/convex/agent_tools/customers/customer_read_tool.ts
  • services/platform/convex/agent_tools/database/database_schema_tool.ts
  • services/platform/convex/agent_tools/delegation/create_delegation_tool.ts
  • services/platform/convex/agent_tools/documents/__tests__/document_write_tool.test.ts
  • services/platform/convex/agent_tools/documents/document_find_tool.ts
  • services/platform/convex/agent_tools/documents/document_retrieve_tool.ts
  • services/platform/convex/agent_tools/documents/document_write_tool.ts
  • services/platform/convex/agent_tools/files/docx_tool.ts
  • services/platform/convex/agent_tools/files/excel_tool.ts
  • services/platform/convex/agent_tools/files/helpers/analyze_text.ts
  • services/platform/convex/agent_tools/files/helpers/vision_agent.ts
  • services/platform/convex/agent_tools/files/image_tool.ts
  • services/platform/convex/agent_tools/files/pdf_tool.ts
  • services/platform/convex/agent_tools/files/pptx_tool.ts
  • services/platform/convex/agent_tools/files/text_tool.ts
  • services/platform/convex/agent_tools/human_input/request_human_input_tool.ts
  • services/platform/convex/agent_tools/integrations/create_bound_integration_tool.ts
  • services/platform/convex/agent_tools/integrations/integration_batch_tool.ts
  • services/platform/convex/agent_tools/integrations/integration_introspect_tool.ts
  • services/platform/convex/agent_tools/integrations/integration_tool.ts
  • services/platform/convex/agent_tools/location/request_user_location_tool.ts
  • services/platform/convex/agent_tools/products/product_read_tool.ts
  • services/platform/convex/agent_tools/rag/rag_search_tool.ts
  • services/platform/convex/agent_tools/web/web_tool.ts
  • services/platform/convex/agent_tools/workflows/__tests__/create_bound_workflow_tool.test.ts
  • services/platform/convex/agent_tools/workflows/__tests__/create_workflow_tool.test.ts
  • services/platform/convex/agent_tools/workflows/__tests__/run_workflow_tool.test.ts
  • services/platform/convex/agent_tools/workflows/__tests__/save_workflow_definition_tool.test.ts
  • services/platform/convex/agent_tools/workflows/__tests__/update_workflow_step_tool.test.ts
  • services/platform/convex/agent_tools/workflows/__tests__/workflow_syntax_tool.test.ts
  • services/platform/convex/agent_tools/workflows/create_bound_workflow_tool.ts
  • services/platform/convex/agent_tools/workflows/create_workflow_tool.ts
  • services/platform/convex/agent_tools/workflows/run_workflow_tool.ts
  • services/platform/convex/agent_tools/workflows/save_workflow_definition_tool.ts
  • services/platform/convex/agent_tools/workflows/update_workflow_step_tool.ts
  • services/platform/convex/agent_tools/workflows/workflow_read_tool.ts
  • services/platform/convex/agent_tools/workflows/workflow_syntax_tool.ts
  • services/platform/convex/conversations/improve_message.ts
  • services/platform/convex/lib/create_agent_config.ts
  • services/platform/convex/lib/openai_provider.ts
  • services/platform/convex/lib/summarize_context.ts
  • services/platform/convex/workflows/triggers/actions.ts
  • services/platform/package.json

Comment on lines +186 to +187
inputSchema: pptxArgs,
execute: async (ctx: ToolCtx, args): Promise<PptxResult> => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 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 -200

Repository: 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 -5

Repository: 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, (not inputSchema)
  • handler: async (ctx: ToolCtx, args) (not execute)

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.

Comment on lines +162 to +163
inputSchema: requestHumanInputArgs,
execute: async (
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 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.ts

Repository: 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.json

Repository: 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.ts

Repository: 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.

Comment on lines 187 to 189
...(embeddingModel
? { textEmbeddingModel: openai.embedding(embeddingModel) }
? { embeddingModel: openai.textEmbeddingModel(embeddingModel) }
: {}),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 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 the Agent constructor config / shared Config) [1][2]

Example: textEmbeddingModel: openai.embedding("text-embedding-3-small") [1]

Sources:
[1] (docs.convex.dev)
[2] (docs.convex.dev)

Citations:


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.

@larryro larryro merged commit b640198 into main Mar 24, 2026
17 checks passed
@larryro larryro deleted the feat/agent-tools-ai-sdk-refactor branch March 24, 2026 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant