Skip to content

feat(api): support convert-side chunking - #833

Merged
edeandrea merged 3 commits into
docling-project:mainfrom
edeandrea:feat/convert-side-chunking
Dec 1, 2026
Merged

edeandrea merged 3 commits into
docling-project:mainfrom
edeandrea:feat/convert-side-chunking

Conversation

@edeandrea

Copy link
Copy Markdown
Contributor

Summary

Docling Serve's ConvertDocumentsOptions exposes chunking_preset and chunking_options, letting the convert endpoints chunk a document in the same pass that converts it, instead of converting and then sending the result back to /chunk. Mapping these two request properties on their own would be inert, so this PR lands them together with the two other pieces needed to make the feature usable:

  • OutputFormat.CHUNKS — the trigger the server requires in to_formats to activate chunking. Appended at the end of the enum (along with the five values added in feat(api): add missing OutputFormat values #828) to preserve the ordinal position of the existing constants.
  • ConvertDocumentOptions.chunkingPreset / chunkingOptions — the chunker configuration, reusing the existing ChunkerOptions sealed type whose chunker discriminator already matches the server's oneOf.
  • A new ChunkedConvertDocumentResponse (ResponseType.CHUNKED) for the in-body response shape, reusing the chunk API's Chunk and Document types since the server's ChunkedDocumentResult is structurally identical. The Jackson 2/3 convert response deserializers now check for chunks before documents, since a chunked response also carries a documents field and would otherwise be misrouted to PreSignedUrlConvertResponse.
  • ArtifactType.CHUNKS, so the presigned-target path (where the chunks file comes back as a chunks artifact) deserializes instead of throwing on an unrecognized enum constant.

Closes #821. Related to #822.

Test plan

  • ./gradlew --no-daemon :docling-serve-api:test — new unit tests for ConvertDocumentOptions, ChunkedConvertDocumentResponse, and ArtifactRef
  • ./gradlew --no-daemon :docling-serve-client:test — new WireMock-based regression test (shouldConvertSourceWithInBodyTargetAndChunkingSuccessfully) for both Jackson 2 and Jackson 3 clients, covering the chunks-before-documents dispatch fix
  • ./gradlew --no-daemon spotlessCheck

Assisted-By: Claude Code noreply@anthropic.com

ConvertDocumentsOptions exposes chunking_preset and chunking_options,
letting the convert endpoints chunk a document in the same pass that
converts it, instead of converting and then sending the result back
to /chunk. Mapping these two request properties alone would be inert,
so this change lands them together with the two other pieces needed
to make the feature usable:

* OutputFormat.CHUNKS, the trigger the server requires in to_formats
  to activate chunking, appended at the end of the enum to preserve
  the ordinal position of the existing constants.
* A new ChunkedConvertDocumentResponse (ResponseType.CHUNKED) for the
  in-body shape, reusing the chunk API's Chunk and Document types
  since the server's ChunkedDocumentResult is structurally identical.
  The Jackson 2/3 convert response deserializers now check for
  "chunks" before "documents", since a chunked response also carries
  a "documents" field and would otherwise be misrouted to
  PreSignedUrlConvertResponse.
* ArtifactType.CHUNKS, so the presigned-target path (where the chunks
  file comes back as a "chunks" artifact) deserializes instead of
  throwing on an unrecognized enum constant.

Related to docling-project#821, docling-project#822.

Assisted-By: Claude Code <noreply@anthropic.com>
Signed-off-by: Eric Deandrea <eric.deandrea@ibm.com>
Copilot AI balanced review requested due to automatic review settings December 1, 2026 20:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Empty chunk lists omit the chunks discriminator during serialization, breaking response round-trips, while documentation also overstates inline-chunk support and uses an unregistered preset example.

3 open issues
What changed in this PR

Adds Java API support for requesting chunking during document conversion, avoiding a separate /chunk request where supported by the server. This complements the output-format additions in #828 and addresses #821.

Changes:

  • Adds chunking options and CHUNKS output/artifact enum values.
  • Introduces a chunked convert response and updates both Jackson deserializers to recognize it.
  • Adds model tests, client regression coverage, and release documentation.
File Description
docs/​src/​doc/​docs/​whats-new.md Documents convert-side chunking and its API additions.
docling-serve/​docling-serve-client/​src/​test/​java/​ai/​docling/​serve/​client/​AbstractDoclingServeClientTests.java Adds shared client coverage for chunked response dispatch.
docling-serve/​docling-serve-api/​src/​test/​java/​ai/​docling/​serve/​api/​convert/​response/​ConvertDocumentResponseTests.java Tests chunked response fields and defaults.
docling-serve/​docling-serve-api/​src/​test/​java/​ai/​docling/​serve/​api/​convert/​response/​ArtifactRefTests.java Tests the chunks artifact type.
docling-serve/​docling-serve-api/​src/​test/​java/​ai/​docling/​serve/​api/​convert/​request/​options/​ConvertDocumentOptionsTests.java Tests chunking options, defaults, and builder copying.
docling-serve/​docling-serve-api/​src/​main/​java/​ai/​docling/​serve/​api/​serialization/​Jackson3ConvertDocumentResponseDeserializer.java Checks for chunks before presigned documents in Jackson 3.
docling-serve/​docling-serve-api/​src/​main/​java/​ai/​docling/​serve/​api/​serialization/​Jackson2ConvertDocumentResponseDeserializer.java Checks for chunks before presigned documents in Jackson 2.
docling-serve/​docling-serve-api/​src/​main/​java/​ai/​docling/​serve/​api/​convert/​response/​ResponseType.java Adds the CHUNKED response category.
docling-serve/​docling-serve-api/​src/​main/​java/​ai/​docling/​serve/​api/​convert/​response/​ConvertDocumentResponse.java Permits the new chunked response subtype.
docling-serve/​docling-serve-api/​src/​main/​java/​ai/​docling/​serve/​api/​convert/​response/​ChunkedConvertDocumentResponse.java Models chunks, converted documents, and processing time.
docling-serve/​docling-serve-api/​src/​main/​java/​ai/​docling/​serve/​api/​convert/​response/​ArtifactType.java Maps the chunks artifact value.
docling-serve/​docling-serve-api/​src/​main/​java/​ai/​docling/​serve/​api/​convert/​request/​options/​OutputFormat.java Adds CHUNKS and restores the original six constants’ positions.
docling-serve/​docling-serve-api/​src/​main/​java/​ai/​docling/​serve/​api/​convert/​request/​options/​ConvertDocumentOptions.java Adds chunking preset and configuration properties.

Review effort: Balanced

Comment thread docs/src/doc/docs/whats-new.md Resolved
@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

:java_duke: JaCoCo coverage report

Overall Project 54.55% 🟢

There is no coverage information present for the Files changed

@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
TestsPassed ✅SkippedFailed
Gradle Test Results (all modules & JDKs)2508 ran2508 passed0 skipped0 failed
TestResult
No test annotations available

@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown

HTML test reports are available as workflow artifacts (zipped HTML).

• Download: Artifacts for this run

…erver

Verified against a live docling-serve v1.41.0 container: when "chunks"
is requested in to_formats together with a single-document InBodyTarget,
the server silently omits chunk output entirely and returns a plain
in-body document response instead. The {chunks, documents,
processing_time} shape modeled by ChunkedConvertDocumentResponse is
actually the response shape of the dedicated /chunk endpoints, not
anything /convert/source ever returns, so the chunks-before-documents
dispatch fix in both Jackson deserializers was never reachable from a
real server response.

The presigned-target chunking support (ArtifactType.CHUNKS,
chunkingPreset/chunkingOptions on ConvertDocumentOptions) is unaffected
and was confirmed against the same container to behave as implemented.

Also corrects the chunkingPreset javadoc/test example: "hybrid" and
"hierarchical" are the chunker discriminator used by ChunkerOptions,
not registered chunking_preset ids.

Related to docling-project#821, docling-project#822.

Assisted-By: Claude Code <noreply@anthropic.com>
Signed-off-by: Eric Deandrea <eric.deandrea@ibm.com>
Copilot AI balanced review requested due to automatic review settings December 1, 2026 20:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The chunking documentation incorrectly excludes ZIP output support for both chunkingPreset and chunkingOptions and needs correction while retaining the single-document in-body warning.

1 open issue
3 resolved since last review

Review effort: Balanced

The previous javadoc/whats-new.md fix overcorrected: chunk output is
dropped only for a single-document InBodyTarget. Docling Serve also
writes a *.chunks.jsonl file into the ZIP archive for ZipTarget and
multi-document InBodyTarget requests, confirmed against the same
docling-serve v1.41.0 container used to verify the earlier fix.

Related to docling-project#821, docling-project#822.

Assisted-By: Claude Code <noreply@anthropic.com>
Signed-off-by: Eric Deandrea <eric.deandrea@ibm.com>
Copilot AI balanced review requested due to automatic review settings December 1, 2026 20:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are identified for the convert-side chunking changes.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@edeandrea
edeandrea enabled auto-merge (squash) December 1, 2026 20:42
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown

HTML test reports are available as workflow artifacts (zipped HTML).

• Download: Artifacts for this run

@edeandrea
edeandrea merged commit faaa1eb into docling-project:main Dec 1, 2026
28 checks passed
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown

HTML test reports are available as workflow artifacts (zipped HTML).

• Download: Artifacts for this run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Improvement] Support convert-side chunking (chunking_preset / chunking_options)

2 participants