[BUG: Breaking] OllamaService sends incomplete JSON Schema to Ollama (missing $defs) causing structured output requests to fail
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:
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:
{
"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/BlockSchemaExpected behaviour
The complete schema generated by Pydantic should be sent to Ollama.
Replacing:
format_schema = {
"type": "object",
"properties": schema["properties"],
"required": schema["required"],
}with
format_schema = schemasolves 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.
Source: datalab-to/marker