Skip to content

Bug: Invalid JSON Schema Generated Due to Unsupported Regex Lookaround in fileKey Pattern On GPT 5.5 #31996

Closed as duplicate

Description

@fresp

Description

Summary

When using OpenCode with an OpenAI-compatible provider, requests fail before reaching the model with the following error:

Invalid JSON schema: regex lookaround is not supported.
Found at $.properties.fileKey.pattern

This appears to be caused by OpenCode generating a JSON Schema containing a regex pattern with lookaround assertions ((?=...), (?!...), (?<=...), or (?<!...)).

Many JSON Schema validators used by OpenAI-compatible providers do not support regex lookarounds, causing schema validation to fail before inference begins.


Environment

  • OpenCode Version: Latest
  • Provider: OpenAI-compatible API
  • Model: GPT-5.5
  • OS: Linux

Steps to Reproduce

  1. Configure OpenCode with an OpenAI-compatible provider.
  2. Start a new session.
  3. Send a simple prompt:
hai
  1. Observe the response.

Actual Result

OpenCode immediately returns:

Invalid JSON schema: regex lookaround is not supported.
Found at $.properties.fileKey.pattern

No request reaches the model.


Expected Result

OpenCode should either:

  • Generate a JSON Schema compatible with common Structured Output validators, or
  • Detect unsupported schema features and gracefully fall back to a non-structured-output mode.

The request should not fail before model execution.


Analysis

The error points to:

$.properties.fileKey.pattern

which suggests OpenCode is generating a schema similar to:

{
  "type": "object",
  "properties": {
    "fileKey": {
      "type": "string",
      "pattern": "..."
    }
  }
}

The generated regex appears to contain lookaround assertions.

While lookarounds are supported by some regex engines, they are not universally supported by JSON Schema validators used by OpenAI-compatible APIs and structured output implementations.

As a result, schema validation fails before the request can be processed by the model.


Suggested Fix

  • Avoid generating regex patterns that rely on lookaround assertions.
  • Replace lookaround-based validation with schema-compatible alternatives.
  • Add a fallback path when structured output schema validation fails.
  • Consider validating generated schemas against common OpenAI-compatible implementations before sending requests.

Additional Context

The issue is reproducible with a simple prompt and appears unrelated to the model itself.

Based on the error message, the failure occurs during schema validation rather than inference.

This may affect any OpenAI-compatible provider that enforces JSON Schema validation and does not support regex lookaround syntax.

Plugins

No response

OpenCode version

1.17.4

Steps to reproduce

No response

Screenshot and/or share link

Image

Operating System

No response

Terminal

No response

Activity

  1. github-actions commented on Jun 12, 2026

    @github-actions
    Contributor

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • The issue appears to contain AI-generated content (long structured sections like Summary, Analysis, Suggested Fix, Additional Context are a hallmark of AI-generated walls of text, which are not acceptable)
    • Required fields from the bug report template ("Steps to reproduce", "Operating System", "Terminal") were left as _No response_ placeholder text — please fill these in with real information about your environment and how to reproduce the issue

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.


    This issue might be a duplicate of existing issues. Please check:

    If you believe this was flagged incorrectly, please let a maintainer know.

  2. dkornilove commented on Jun 12, 2026

    @dkornilove

    started to experience after update to 1.17.4.

    upd: not really depends on version, looks like some changes on openai side

  3. mattbdc commented on Jun 12, 2026

    @mattbdc

    It works if you downgrade model to 5.4. It seems an issue with 5.5.

  4. grummans commented on Jun 12, 2026

    @grummans

    @fresp are you using Figma MCP? I have tested, only Figma MCP cause that error.
    I think Figma has change the way they handle MCP request.
    Update: I tested with another model in Opencode Go (Figma MCP enabled) -> still work
    Maybe the issue only cause with GPTs-model when Figma mcp enabled

  5. github-actions commented on Jun 12, 2026

    @github-actions
    Contributor

    This issue has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

    Feel free to open a new issue that follows our issue templates.

  6. nicobao commented on Jun 12, 2026

    @nicobao

    why the heck is this closed?

  7. mattbdc commented on Jun 12, 2026

    @mattbdc

    Their insanity AI decided that a 200+line bug report with positive engagement wasn’t sufficient.

  8. nicobao commented on Jun 12, 2026

    @nicobao

    I just tried:

    • yes it's related to Figma MCP
    • yes it's related to GPT 5.5.

    Why?

    • if i have Figma MCP enabled AND GPT 5.5 i get the error, a bit randomly (or i dont know why), but once it first appeared on a session I cannot get rid of it The session becomes completely unusable. Probably some shit in the context that is unreadable, I have no idea.
    • when i face the above situation and my session is unusable, and i change model from 5.5 to 5.4, it suddenly starts to work again
    • when i face the above situation and my session is unusable with model 5.5, and i disable Figma MCP, it suddenly starts to work again
    • when i face the above situation and my session is unusable, and i solved it with one of the two above solutions, and then i try to go back to 5.5 with Figma MCP enabled, I get the unusable session again with the same error.
  9. mattbdc commented on Jun 12, 2026

    @mattbdc

    Can confirm figma mcp too

  10. kunickiaj commented on Jun 12, 2026

    @kunickiaj

    Patch to fix #30552

  11. santos1982rj commented on Jun 12, 2026

    @santos1982rj

    Eu estava com o mesmo problema, mas no meu caso, foi o Resend MCP. Precisei desabilitar

  12. rekram1-node commented on Jun 16, 2026

    @rekram1-node
    Collaborator

    will fix tday

  13. matheuseabra commented on Jul 27, 2026

    @matheuseabra

    I'm havinng this error with dokploy-mcp itself, with gpt-5.6 when I disable it in opencode, it works.

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