Repository navigation
Azure Model o4-mini error Invalid schema edit #290
Copy link
Copy link
Closed
Description
Problem
i've got error schema when using model o4-mini, but for other model like GPT-4.1 has no issue so far.
INFO 2025-06-21T13:10:18 +1ms service=bus type=storage.write publishing
INFO 2025-06-21T13:10:18 +0ms service=app name=config registering service
INFO 2025-06-21T13:10:18 +2ms service=config $schema=https://opencode.ai/config.json loaded
INFO 2025-06-21T13:10:18 +0ms service=bus type=session.updated publishing
█▀▀█ █▀▀█ █▀▀ █▀▀▄ █▀▀ █▀▀█ █▀▀▄ █▀▀
█░░█ █░░█ █▀▀ █░░█ █░░ █░░█ █░░█ █▀▀
▀▀▀▀ █▀▀▀ ▀▀▀ ▀ ▀ ▀▀▀ ▀▀▀▀ ▀▀▀ ▀▀▀
> hi
INFO 2025-06-21T13:10:18 +1ms service=app name=provider registering service
INFO 2025-06-21T13:10:18 +1ms service=models.dev refreshing
INFO 2025-06-21T13:10:18 +1ms service=provider init
INFO 2025-06-21T13:10:18 +1ms service=provider providerID=azure found
INFO 2025-06-21T13:10:18 +0ms service=provider providerID=openai found
@ azure/o4-mini
INFO 2025-06-21T13:10:18 +1ms service=bus type=message.part.updated subscribing
INFO 2025-06-21T13:10:18 +3ms service=session session=ses_86d63855fffeyji3DPzRwtBZSt chatting
INFO 2025-06-21T13:10:18 +1ms service=provider providerID=azure modelID=o4-mini getModel
INFO 2025-06-21T13:10:18 +1ms service=provider status=started providerID=azure getSDK
INFO 2025-06-21T13:10:18 +24ms service=provider status=completed duration=24 providerID=azure getSDK
INFO 2025-06-21T13:10:18 +0ms service=provider providerID=azure modelID=o4-mini found
INFO 2025-06-21T13:10:18 +2ms service=session sessionID=ses_86d63855fffeyji3DPzRwtBZSt locking
INFO 2025-06-21T13:10:18 +7ms service=bus type=storage.write publishing
INFO 2025-06-21T13:10:18 +0ms service=bus type=message.updated publishing
INFO 2025-06-21T13:10:18 +3ms service=bus type=storage.write publishing
INFO 2025-06-21T13:10:18 +0ms service=bus type=message.updated publishing
INFO 2025-06-21T13:10:18 +0ms service=app name=mcp registering service
ERROR 2025-06-21T13:10:19 +1933ms service=session error=AI_APICallError: Invalid schema for function 'edit': In context=('properties', 'replaceAll'), schema must have a 'type' key. callback error
INFO 2025-06-21T13:10:19 +0ms service=bus type=session.error publishing
INFO 2025-06-21T13:10:19 +1ms service=session session=ses_86d63855fffeyji3DPzRwtBZSt type=error part
INFO 2025-06-21T13:10:19 +0ms service=session session=ses_86d63855fffeyji3DPzRwtBZSt type=error unhandled
INFO 2025-06-21T13:10:20 +1ms service=bus type=storage.write publishing
INFO 2025-06-21T13:10:20 +0ms service=bus type=message.updated publishing
INFO 2025-06-21T13:10:20 +0ms service=session sessionID=ses_86d63855fffeyji3DPzRwtBZSt unlocking
INFO 2025-06-21T13:10:20 +0ms service=app name=session shutdown
INFO 2025-06-21T13:10:20 +0ms service=app name=mcp shutdownHotfix
so, for now the solution i use is Modified the optionalToNullable function in packages/opencode/src/provider/provider.ts to completely remove optional fields from the schema when using Azure/OpenAI providers, rather than trying to make them nullable.
function optionalToNullable(schema: z.ZodTypeAny): z.ZodTypeAny {
if (schema instanceof z.ZodObject) {
const shape = schema.shape
const newShape: Record<string, z.ZodTypeAny> = {}
for (const [key, value] of Object.entries(shape)) {
const zodValue = value as z.ZodTypeAny
if (zodValue instanceof z.ZodOptional) {
// For OpenAI/Azure compatibility, completely remove optional fields
// from the schema to avoid validation errors about required arrays
continue // <- This removes optional fields entirely
} else {
newShape[key] = optionalToNullable(zodValue)
}
}
return z.object(newShape)
}
// ... rest of function
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels


Activity
divakaivan commentedon Jun 21, 2025
how do you see these logs?
blubbelgum commentedon Jun 21, 2025
opencode run "hello" --print-logsuse --print-logsrekram1-node commentedon Dec 28, 2025
[automated] Closing due to 90+ days of inactivity. Feel free to reopen if you still need this!
Merge pull request anomalyco#290 from nocodemf/add-evos-operational-s…