You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Recursive $ref in postgres tool schemas breaks Meta Muse Spark ("Recursive JSON schemas are not currently supported") #45800
Using Muse Spark 1.2 Contributor via OpenCode Go (paid subscription) fails immediately with:
_
AI_APICallError: Error from provider (Console Go): Upstream request failed:
[invalid_request_error] Recursive JSON schemas are not currently supported
_
The error occurs on the first request before any tool executes. The cause is the PostgreSQL tool schemas (postgres-readonly_pg_explain, postgres-readonly_pg_readonly, postgres-readonly_pg_query) which contain a self-referencing $ref:
packages/opencode/src/provider/transform.ts has per-provider schema sanitizers for OpenAI, Moonshot/Kimi, and Gemini — but no Meta/Muse-specific sanitization. The sanitizeOpenAISchema function (which applies to Meta via @ai-sdk/openai) preserves $ref/$defs verbatim, so recursive schemas pass through to Meta's API unchanged.
Suggested fix
Flatten recursive $ref cycles in the schema transform layer before sending to any provider that rejects them. The approach from unmerged PR #29295 (inline local $refs, replace recursive refs with permissive {}) or the merged MCP fix #16910 (fallback to {type:"object", additionalProperties:true}) would both work.
Workaround
Disable PostgreSQL tools in opencode.json:
{
"permission": {
"postgres-*": "deny"
}
}
Environment
opencode: latest (2026-08-28) 1.18.23
Provider: opencode-go → Console Go → Meta Model API
Another instance of the same root cause, different MCP server: substack-mcp's set_post_body tool publishes a ProseMirror-style document schema (packages/substack-mcp/src/api/substack/document.js) where listItemNode and bulletListNode/orderedListNode reference each other via getters — a genuine mutual recursion that zod-to-json-schema turns into a $ref cycle. Same symptoms as this issue: fails on the very first message, even with the plain build agent and no other plugins/MCPs enabled, as soon as substack MCP is configured and model is muse-spark-1.2/1.3-contributor-free via Console. Workaround that worked for me: "permission": {"substack_set_post_body": "deny"} in opencode.jsonc, which drops just that one tool and leaves the rest of the MCP working. +1 for fixing this generally in the schema transform layer rather than per-MCP-server, since it's clearly not limited to postgres/houseCARL/substack — any tool with a tree-shaped schema will hit it.
Activity
Parker-Fawcett commentedon Sep 6, 2026
Another instance of the same root cause, different MCP server:
substack-mcp'sset_post_bodytool publishes a ProseMirror-style document schema (packages/substack-mcp/src/api/substack/document.js) wherelistItemNodeandbulletListNode/orderedListNodereference each other via getters — a genuine mutual recursion that zod-to-json-schema turns into a $ref cycle. Same symptoms as this issue: fails on the very first message, even with the plainbuildagent and no other plugins/MCPs enabled, as soon assubstackMCP is configured and model ismuse-spark-1.2/1.3-contributor-freevia Console. Workaround that worked for me:"permission": {"substack_set_post_body": "deny"}in opencode.jsonc, which drops just that one tool and leaves the rest of the MCP working. +1 for fixing this generally in the schema transform layer rather than per-MCP-server, since it's clearly not limited to postgres/houseCARL/substack — any tool with a tree-shaped schema will hit it.thdxr commentedon Oct 11, 2026
Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (
opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊