Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/opencode/src/provider/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1432,6 +1432,15 @@ export function schema(model: Provider.Model, schema: JSONSchema7): JSONSchema7
}
*/

// Ensure `required` is always an array when `properties` is present.
// Strict JSON Schema validators (e.g. ajv used by some API gateways/proxies)
// reject schemas where `additionalProperties: false` is set but `required`
// is missing or null. This normalizes all object schemas to include an
// explicit (possibly empty) `required` array.
if (schema.type === "object" && schema.properties && !Array.isArray(schema.required)) {
schema.required = []
}

if (model.api.npm === "@ai-sdk/openai" || model.api.npm === "@ai-sdk/azure") {
schema = sanitizeOpenAISchema(schema) as JSONSchema7
// Codex also applies lossy compaction above 4 KB; defer that until OpenCode needs the same schema budget.
Expand Down
2 changes: 2 additions & 0 deletions packages/opencode/src/session/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export const resolve = Effect.fn("SessionTools.resolve")(function* (input: {
},
},
additionalProperties: false,
required: [],
}),
),
execute(args, opts) {
Expand Down Expand Up @@ -233,6 +234,7 @@ export const resolve = Effect.fn("SessionTools.resolve")(function* (input: {
},
},
additionalProperties: false,
required: [],
}),
),
execute(args, opts) {
Expand Down
Loading