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
Strict JSON Schema validation fail on backends like SGLang (Missing required field in empty tool parameters) #8184
When using opencode with backends that perform strict JSON Schema validation (such as SGLang or other Pydantic-based LLM servers), tool calls for built-in tools with empty parameters (e.g., todoread) fail during the initial request.
The server returns a 400 Bad Request or a validation error similar to: Tool function has invalid 'parameters' schema: None is not of type 'array' on schema['required']
Root Cause Analysis
The issue stems from how zod schemas are converted to JSON Schema for the LLM provider.
In packages/opencode/src/tool/todo.ts, the todoread tool defines its parameters as an empty object:
exportconstTodoReadTool=Tool.define("todoread",{description: "Use this tool to read your todo list",parameters: z.object({}),// This results in a schema without a 'required' field// ...})
In packages/opencode/src/session/prompt.ts, the schema is generated using z.toJSONSchema(item.parameters). For an empty object, it produces:
Strict validators like SGLang's internal pydantic models fail because they expect "required": [] to be explicitly present if the schema is of type object.
Suggested Fix
The most robust place to fix this is in the provider transformation layer to ensure all object-based schemas satisfy strict requirements. File:packages/opencode/src/provider/transform.ts
exportfunctionschema(model: Provider.Model,schema: any){// ... existing logic ...// Ensure 'required' is always an array for object types to satisfy strict backendsif(schema.type==='object'&&!schema.required){schema.required=[];}returnschema;}
Environment
Opencode Version: 1.1.14
LLM Backend: SGLang (v1/chat/completions)
Platform: macOS / Linux
Plugins
No response
OpenCode version
1.1.14
Steps to reproduce
Configure opencode to use an SGLang backend (or any backend using strict JSON Schema validation).
Start a session where built-in tools are enabled.
Observe the v1/chat/completions request failing because the backend rejects the todoread tool definition.
Activity
github-actions commentedon Jan 13, 2026
This issue might be a duplicate of existing issues. Please check:
Feel free to ignore if none of these address your specific case.
fix(provider): add required field to object schemas for strict valida…
thdxr commentedon Mar 25, 2026
To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.