Skip to content

Non-Anthropic subagent tool loops fail with 'schema is not a function' #1739

@justemu

Description

@justemu

What happened?

When agent.use_gateway_loop=true is enabled for non-Anthropic providers (DeepSeek, OpenAI, OpenRouter, etc.), subagent tool loops fail with:

[chat(deepseek:...)] schema is not a function

Root Cause

In src/core/ai/gateway.ts line 2460, the chat() function passes tool definitions to generateText() using:

inputSchema: { jsonSchema: t.inputSchema } as any,

The Vercel AI SDK expects the parameters key with jsonSchema()-wrapped values. The inputSchema key is silently ignored for openai-compatible providers, causing the SDK to fall through to calling .schema() on undefined.

Expected Behavior

Non-Anthropic subagent tool loops should work correctly with the gateway loop.

Fix

// Import jsonSchema from 'ai'
import { embed as aiEmbed, embedMany, generateObject, generateText, jsonSchema } from 'ai';

// Use parameters key with jsonSchema() wrapper
parameters: jsonSchema(t.inputSchema),

Environment

  • gbrain version: v0.42.1.0 (bug present since v0.38+ when gateway_loop was added)
  • Provider: any non-Anthropic (DeepSeek, OpenAI, OpenRouter, Groq, etc.)
  • Config: agent.use_gateway_loop: true

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions