Skip to content

Azure Model o4-mini error Invalid schema edit #290

Closed

Description

@blubbelgum

Problem

i've got error schema when using model o4-mini, but for other model like GPT-4.1 has no issue so far.

Image

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 shutdown

Hotfix

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
}

Image

Activity

  1. divakaivan commented on Jun 21, 2025

    @divakaivan

    how do you see these logs?

  2. blubbelgum commented on Jun 21, 2025

    @blubbelgum
    Author

    how do you see these logs?

    opencode run "hello" --print-logs use --print-logs

  3. self-assigned this
    on Jun 22, 2025
  4. rekram1-node commented on Dec 28, 2025

    @rekram1-node
    Contributor

    [automated] Closing due to 90+ days of inactivity. Feel free to reopen if you still need this!

  5. added a commit that references this issue on Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions