chore: add validation for chunk sizes and chunking methods#89
Merged
Mateusz-Switala merged 13 commits intoJul 6, 2026
Merged
Conversation
1f00377 to
3f9c2fc
Compare
Signed-off-by: Mateusz Switala <mswitala@redhat.com> Assisted-by: Claude Code
Signed-off-by: Mateusz Switala <mswitala@redhat.com>
Signed-off-by: Mateusz Switala <mswitala@redhat.com>
Signed-off-by: Mateusz Switala <mswitala@redhat.com> Assisted-by: Claude Code
Signed-off-by: Mateusz Switala <mswitala@redhat.com>
Signed-off-by: Mateusz Switala <mswitala@redhat.com> Assisted-by: Claude Code
Signed-off-by: Mateusz Switala <mswitala@redhat.com>
4a1841d to
43700f9
Compare
Signed-off-by: Mateusz Switala <mswitala@redhat.com> Assisted-by: Claude Code
filip-komarzyniec
approved these changes
Jul 6, 2026
Signed-off-by: Mateusz Switala <mswitala@redhat.com> Assisted-by: Claude Code
Signed-off-by: Mateusz Switala <mswitala@redhat.com> Assisted-by: Claude Code
Signed-off-by: Mateusz Switala <mswitala@redhat.com> Assisted-by: Claude Code
Signed-off-by: Mateusz Switala <mswitala@redhat.com> Assisted-by: Claude Code
Signed-off-by: Mateusz Switala <mswitala@redhat.com> Assisted-by: Claude Code
filip-komarzyniec
approved these changes
Jul 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Assisted-by: Claude Code
Description
Extends
prepare_search_space_with_ogxto accept optionalchunking_methodandchunk_sizeoverrides directly via the payload, and adds
chunk_sizesas a new parameter toprepare_search_space_report. Also lowers the minimum allowed chunk size to 128 tokens anddeduplicates any repeated values in the chunking inputs.
Motivation
The existing
prepare_search_space_with_ogxalways used platform-default chunking methods(
recursive,hybrid) and chunk sizes (512,1024,2048). Users running experiments onshorter documents or with a single chunking strategy had no way to constrain these dimensions
without post-processing the search space manually. This change exposes that control at the
preparation step, in the single function callers already use.
Changes
ai4rag/utils/constants.py— loweredChunkingConstraints.MIN_CHUNK_SIZEfrom512to128ai4rag/search_space/prepare/input_payload_types.py— added optionalchunking_methodsandchunk_sizesfields toAI4RAGConstraints; both are pydantic-validated (non-empty list,non-empty strings / positive integers respectively)
ai4rag/search_space/prepare/prepare_search_space.py_resolve_models_from_payload,_apply_language_detection,_build_model_paramsprepare_search_space_with_ogxto accept and validatechunking_methodsandchunk_sizesin the payload; when provided they override the platform defaults for thosedimensions; duplicate values are deduplicated with a warning
validated locally against
ChunkingConstraintsai4rag/search_space/prepare/__init__.py— removedprepare_search_space_custom(functionality merged into
prepare_search_space_with_ogx)ai4rag/components/optimization/search_space_preparation.pychunk_sizes: list[int] | None = Noneparameter toprepare_search_space_report_validate_chunking_methodsto validate values againstChunkingConstraints.METHODS,providing an early, clear error
prepare_search_space_reportnow passeschunking_methodsandchunk_sizesinto the payloadand calls
prepare_search_space_with_ogxTesting
prepare_search_space_with_ogxchunking_methodsandchunk_sizesTestValidateChunkSizes(11 tests) covering:None, valid list, single element,non-list, empty list, zero, negative, float, below-min, above-max, and exact boundary values
TestPrepareSearchSpaceReportChunkSizesValidation(3 tests) covering: non-list, emptylist, and non-positive integer
TestUnsupportedChunkingMethods— validation fires before any I/O so complexmocking is no longer needed
Checklist