#1060·marker

[BUG: Breaking] OllamaService sends incomplete JSON Schema to Ollama (missing $defs) causing structured output requests to fail

Author: b-thinkingCreated Jul 10, 2026Updated Sep 28, 2026
Labelsbug: breaking

Description

While testing the latest Marker (1.10.2) with a local Ollama server, I found that marker.services.ollama.OllamaService builds an incomplete JSON Schema before sending it to Ollama.

The service currently does:

python
schema = response_schema.model_json_schema()

format_schema = {
    "type": "object",
    "properties": schema["properties"],
    "required": schema["required"],
}

However, response_schema.model_json_schema() may contain $defs, and the generated schema frequently contains $ref references such as:

json
{
  "blocks": {
    "items": {
      "$ref": "#/$defs/BlockSchema"
    }
  }
}

Since $defs is discarded, the schema becomes invalid.


Result

Ollama rejects the request with:

HTTP 400

Field 'json_schema':
JSON schema conversion failed:

Error resolving ref #/$defs/BlockSchema

Expected behaviour

The complete schema generated by Pydantic should be sent to Ollama.

Replacing:

python
format_schema = {
    "type": "object",
    "properties": schema["properties"],
    "required": schema["required"],
}

with

python
format_schema = schema

solves the problem.


Environment

  • Marker 1.10.2
  • Python 3.11
  • Ollama (latest stable)
  • macOS
  • Apple Silicon (M4)

Notes

After applying this change, the JSON Schema is accepted correctly by Ollama.

The remaining failures are unrelated and are caused by sending images to text-only models (for example qwen3:14b), which appears to be a separate issue.