Skip to content

Reject non-progressing embedding chunk windows before entering the splitter #139

Description

@anxkhn

Programmatic users selecting a smaller embedding context window can hang before any provider request and exhaust process memory. Default Tier 2 callers use a safe 512/64 window, so ordinary default CLI scans are not affected.

At src/skillevaluator/embedding/client.py:299:

EmbeddingClient.embed_chunked exposes chunk_size and overlap at lines 169-188. _split_into_chunks multiplies both by four at lines 253-254 without validating their relationship. _fixed_size_chunks loops while start < len(text) at line 294 and advances with 'start += max_chars - overlap_chars' at line 299. For chunk_size=64 and the default overlap=64, any section longer than 256 characters repeatedly appends the identical first chunk and never advances. With overlap greater than chunk_size, start moves backwards and the loop still cannot terminate. Existing tests/embedding/test_client.py:214-243 only cover a positive stride. This is an unambiguous source trace, not an executed test.

Proposed fix

Validate positive integer chunk_size and nonnegative integer overlap smaller than chunk_size at the shared splitter entry before content-length branches or provider construction. Raise a consistent configuration exception instead of silently clamping. Add parameterized boundary regressions and a bounded public-method regression in tests/embedding/test_client.py, including short and empty inputs so invalid configuration is not content-dependent. Keep the normal overlapping-window output tests. Record the user-visible change in CHANGELOG.md.

How to see it

Call EmbeddingClient().embed_chunked('x' * 257, chunk_size=64), leaving the public default overlap unchanged. The current code sets max_chars=overlap_chars=256, then repeatedly appends 256 characters with start fixed at zero. Expected behavior is an immediate configuration error explaining that overlap must be smaller than chunk_size. Also cover overlap greater than the window, zero or negative window sizes, and negative overlap. Do not run the hanging case unbounded. A regression can invoke the public method in a subprocess with a short timeout, expecting a normal configuration-error exit and no client construction.

If this looks right I can push fix/embedding-window-progress on anxkhn/skillevaluator instead of opening a pull request first.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions