diff options
| author | Aiden Cline <[email protected]> | 2025-12-01 16:19:10 -0600 |
|---|---|---|
| committer | Aiden Cline <[email protected]> | 2025-12-01 16:19:10 -0600 |
| commit | 0331931f562239abf3adaebfb18539adf6665359 (patch) | |
| tree | d551e659256fd3a362a6f9cfce54bbad55d1b101 /packages | |
| parent | 01e2c9cc21c5a0a5d23928cab7b3100c4d6f79a1 (diff) | |
| download | opencode-0331931f562239abf3adaebfb18539adf6665359.tar.gz opencode-0331931f562239abf3adaebfb18539adf6665359.zip | |
fix: sanitize more invalid schema cases for gemini models
Diffstat (limited to 'packages')
| -rw-r--r-- | packages/opencode/src/provider/transform.ts | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/packages/opencode/src/provider/transform.ts b/packages/opencode/src/provider/transform.ts index 5ea3e0c31..abe269d5d 100644 --- a/packages/opencode/src/provider/transform.ts +++ b/packages/opencode/src/provider/transform.ts @@ -275,13 +275,13 @@ export namespace ProviderTransform { // Convert integer enums to string enums for Google/Gemini if (providerID === "google" || modelID.includes("gemini")) { - const convertIntEnumsToStrings = (obj: any): any => { + const sanitizeGemini = (obj: any): any => { if (obj === null || typeof obj !== "object") { return obj } if (Array.isArray(obj)) { - return obj.map(convertIntEnumsToStrings) + return obj.map(sanitizeGemini) } const result: any = {} @@ -294,15 +294,21 @@ export namespace ProviderTransform { result.type = "string" } } else if (typeof value === "object" && value !== null) { - result[key] = convertIntEnumsToStrings(value) + result[key] = sanitizeGemini(value) } else { result[key] = value } } + + // Filter required array to only include fields that exist in properties + if (result.type === "object" && result.properties && Array.isArray(result.required)) { + result.required = result.required.filter((field: any) => field in result.properties) + } + return result } - schema = convertIntEnumsToStrings(schema) + schema = sanitizeGemini(schema) } return schema |
