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
What happened?
When
agent.use_gateway_loop=trueis enabled for non-Anthropic providers (DeepSeek, OpenAI, OpenRouter, etc.), subagent tool loops fail with:Root Cause
In
src/core/ai/gateway.tsline 2460, thechat()function passes tool definitions togenerateText()using:The Vercel AI SDK expects the
parameterskey withjsonSchema()-wrapped values. TheinputSchemakey is silently ignored for openai-compatible providers, causing the SDK to fall through to calling.schema()onundefined.Expected Behavior
Non-Anthropic subagent tool loops should work correctly with the gateway loop.
Fix
Environment
agent.use_gateway_loop: true