Open
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdjusts special-block protection and system-format cleaning logic so that LLM-specific reply split markers like [SPLIT] are preserved when split_mode is 'llm', avoiding them being re-protected or stripped by generic cleanup. Flow diagram for filter_system_format_content cleaning with LLM split_modeflowchart TD
A[Start filter_system_format_content] --> B[Input content]
B --> C[Apply system format specific cleanup]
C --> D{Is split_mode llm?}
D -->|Yes| F[Skip generic [.*?] removal to preserve markers like [SPLIT]]
D -->|No| E[Remove all patterns matching [.*?] using regex]
E --> F
F --> G[Remove @<...> patterns using regex]
G --> H[Return cleaned_content]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- Consider extracting the
[SPLIT]marker into a shared constant or intoresponse_splitterconfig instead of hardcoding the string inprotect_special_blocks, so the split token stays consistent across the codebase. - The condition
if "__SPECIAL_" in match or global_config.response_splitter.split_mode == "llm" and match == "[SPLIT]":relies on operator precedence; adding parentheses or assigning intermediate booleans would improve readability and reduce the chance of future mistakes when editing this logic.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider extracting the `[SPLIT]` marker into a shared constant or into `response_splitter` config instead of hardcoding the string in `protect_special_blocks`, so the split token stays consistent across the codebase.
- The condition `if "__SPECIAL_" in match or global_config.response_splitter.split_mode == "llm" and match == "[SPLIT]":` relies on operator precedence; adding parentheses or assigning intermediate booleans would improve readability and reduce the chance of future mistakes when editing this logic.
## Individual Comments
### Comment 1
<location> `src/chat/utils/utils.py:967` </location>
<code_context>
# 在处理完回复格式后,再清理其他简单的格式
# 新增:移除所有残余的 [...] 格式,例如 [at=...] 等
- cleaned_content = re.sub(r"\[.*?\]", "", cleaned_content)
+ if global_config.response_splitter.split_mode != "llm":
+ cleaned_content = re.sub(r"\[.*?\]", "", cleaned_content)
# 移除@格式:@<xxx>
</code_context>
<issue_to_address>
**question (bug_risk):** Guarding the bracket-stripping on `split_mode` is correct but may hide unexpected formats in LLM mode.
Because we now skip `"[... ]"` cleanup when `split_mode == "llm"`, any other bracketed control sequences (not just the splitter markers) will appear in the final output. If you only need to retain the splitter markers, consider narrowing the condition or regex so that only those specific patterns are preserved, while other bracketed metadata is still stripped.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
6786d4f to
1a8f7e2
Compare
1a8f7e2 to
9bdcdfe
Compare
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.

Summary by Sourcery
Preserve LLM response splitter markers when protecting and cleaning chat content.
New Features:
Bug Fixes: