Description
Subagent jobs (agent run) fail with schema is not a function across all providers (DeepSeek, OpenAI/Qwen, Anthropic). All other gbrain features (search, sync, extract, dream cycle) work correctly.
Error
[chat(deepseek:deepseek-chat)] schema is not a function. (In 'schema()', 'schema' is an instance of Object)
Same error regardless of provider:
anthropic:claude-sonnet-4-6 → same
openai:qwen3.7-max → same
Environment
| Component |
Version |
| gbrain |
0.42.8.0 (commit 0bfe0d0c) |
| ai (AI SDK) |
6.0.174 |
| @ai-sdk/openai |
3.0.58 |
| @ai-sdk/openai-compatible |
2.0.45 |
| @ai-sdk/anthropic |
3.0.74 |
| zod |
3.25.76 (also tested 4.3.6) |
| bun |
1.3.14 |
| Engine |
PostgreSQL (not PGLite) |
Root Cause Analysis
The error occurs in the gatewayToolLoop → generateText call path. In src/core/ai/gateway.ts line 2531, tool schemas are constructed as:
inputSchema: { jsonSchema: t.inputSchema } as any
The AI SDK v6 internally calls .schema() on a tool schema object during processing, but the object lacks this method as a callable function. This happens regardless of:
- zod version (tested v3.25.76 with package.json
overrides and v4.3.6)
- provider (tested DeepSeek via
@ai-sdk/openai-compatible, Qwen via @ai-sdk/openai, Anthropic via @ai-sdk/anthropic)
- run mode (tested both
bun build --compile binary and bun run source)
agent.use_gateway_loop setting (tested both true and false)
The issue appears to be an API mismatch between gbrain's tool schema construction ({ jsonSchema: ... }) and how AI SDK v6.0.174 processes tool schemas internally.
Steps to Reproduce
# On a fresh gbrain v0.42.8.0 install with PostgreSQL engine:
gbrain config set models.tier.subagent deepseek:deepseek-chat
gbrain jobs work --queue default & # start worker
gbrain jobs submit subagent --params '{"prompt":"reply with exactly: working"}'
sleep 15
gbrain jobs get <id> # shows DEAD with schema error
What Was Tried (all failed)
- Upgraded from v0.42.1.0 to v0.42.8.0
- Clean
rm -rf node_modules && bun install
- Pinned zod to v3.25.76 via package.json
overrides
- Tested compiled binary (
bun build --compile)
- Tested source mode (
bun run src/cli.ts)
- Tested all three provider types
- Toggled
agent.use_gateway_loop
- Fresh rebuild after each change
Impact
All subagent/agent-run functionality is completely non-functional. Other gbrain features (search, sync, extract, dream cycle, skillopt) operate normally.
Description
Subagent jobs (agent run) fail with
schema is not a functionacross all providers (DeepSeek, OpenAI/Qwen, Anthropic). All other gbrain features (search, sync, extract, dream cycle) work correctly.Error
Same error regardless of provider:
anthropic:claude-sonnet-4-6→ sameopenai:qwen3.7-max→ sameEnvironment
0.42.8.0(commit0bfe0d0c)6.0.1743.0.582.0.453.0.743.25.76(also tested4.3.6)1.3.14Root Cause Analysis
The error occurs in the
gatewayToolLoop→generateTextcall path. Insrc/core/ai/gateway.tsline 2531, tool schemas are constructed as:The AI SDK v6 internally calls
.schema()on a tool schema object during processing, but the object lacks this method as a callable function. This happens regardless of:overridesand v4.3.6)@ai-sdk/openai-compatible, Qwen via@ai-sdk/openai, Anthropic via@ai-sdk/anthropic)bun build --compilebinary andbun runsource)agent.use_gateway_loopsetting (tested bothtrueandfalse)The issue appears to be an API mismatch between gbrain's tool schema construction (
{ jsonSchema: ... }) and how AI SDK v6.0.174 processes tool schemas internally.Steps to Reproduce
What Was Tried (all failed)
rm -rf node_modules && bun installoverridesbun build --compile)bun run src/cli.ts)agent.use_gateway_loopImpact
All subagent/agent-run functionality is completely non-functional. Other gbrain features (search, sync, extract, dream cycle, skillopt) operate normally.