Conversation
Contributor
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="tests/test_kb_helper_cleaning_fallback.py" line_range="18-28" />
<code_context>
+ helper = object.__new__(KBHelper)
+ helper.chunker = RecursiveCharacterChunker()
+
+ chunks = await helper._clean_and_rechunk_content(
+ content="x" * 1000,
+ url="https://example.invalid/document",
+ enable_cleaning=True,
+ cleaning_provider_id=None,
+ chunk_size=128,
+ chunk_overlap=16,
+ )
+
+ assert len(chunks) > 1
+ assert max(len(chunk) for chunk in chunks) == 128
+
+
</code_context>
<issue_to_address>
**issue (testing):** Both regression tests pass when the fallback ignores `chunk_overlap`, because they assert only that chunks have the requested maximum size and never verify overlap between adjacent chunks. The tests therefore do not protect the second half of the forwarding fix.
**Suggested fix:** Assert that adjacent chunks share the requested overlap, for example by checking `chunks[0][-16:] == chunks[1][:16]` for the test input.
</issue_to_address>Sourcery assessment
Approval pending. 1 finding to address first.
Blocking findings: tests/test_kb_helper_cleaning_fallback.py:28
Comment on lines
+18
to
+28
| chunks = await helper._clean_and_rechunk_content( | ||
| content="x" * 1000, | ||
| url="https://example.invalid/document", | ||
| enable_cleaning=True, | ||
| cleaning_provider_id=None, | ||
| chunk_size=128, | ||
| chunk_overlap=16, | ||
| ) | ||
|
|
||
| assert len(chunks) > 1 | ||
| assert max(len(chunk) for chunk in chunks) == 128 |
Contributor
There was a problem hiding this comment.
issue (testing): Both regression tests pass when the fallback ignores chunk_overlap, because they assert only that chunks have the requested maximum size and never verify overlap between adjacent chunks. The tests therefore do not protect the second half of the forwarding fix.
Suggested fix: Assert that adjacent chunks share the requested overlap, for example by checking chunks[0][-16:] == chunks[1][:16] for the test input.
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.
Modifications
_clean_and_rechunk_content()now forward the caller-providedchunk_sizeandchunk_overlapvalues.Test Results
uv run pytest tests/test_kb_helper_cleaning_fallback.py -qfailed before the fix; both fallback branches produced 500-character chunks when 128/16 was requested.2 passed.uv run ruff format astrbot/core/knowledge_base/kb_helper.py tests/test_kb_helper_cleaning_fallback.pycompleted; focuseduv run ruff check ...passed.Checklist
Summary by Sourcery
Preserve URL fallback chunk parameters when content cleaning cannot be performed.
Bug Fixes:
Tests: