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
- Configure OpenCode with an OpenAI-compatible provider.
- Start a new session.
- Send a simple prompt:
- 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
Operating System
No response
Terminal
No response
Description
Summary
When using OpenCode with an OpenAI-compatible provider, requests fail before reaching the model with the following error:
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
Steps to Reproduce
Actual Result
OpenCode immediately returns:
No request reaches the model.
Expected Result
OpenCode should either:
The request should not fail before model execution.
Analysis
The error points to:
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
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
Operating System
No response
Terminal
No response