mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-24 21:30:17 +08:00
fix(copilot): 调高无限空白检测阈值 20 → 500 (#2647)
* fix(copilot): raise infinite-whitespace threshold from 20 to 500 The previous threshold of 20 falsely aborted legitimate tool calls whose arguments contain indented code (write_file / edit_file with 4-8 levels of indentation in Python / YAML / Rust / Markdown easily exceed 20 consecutive whitespace chars, especially when newlines are counted). The real infinite-whitespace bug emits hundreds to thousands of consecutive whitespace characters, so 500 keeps the safety net while drastically reducing false positives. Refs #2646 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * docs: clarify whitespace threshold comment --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: Jason <farion1231@gmail.com>
This commit is contained in:
@@ -90,14 +90,14 @@ struct ToolBlockState {
|
||||
started: bool,
|
||||
pending_args: String,
|
||||
/// 连续空白字符计数 — 用于检测 Copilot 无限换行 bug
|
||||
/// 当 function call 参数中出现连续 20+ 空白字符时,强制终止流
|
||||
/// 当 function call 参数中的连续空白字符达到阈值时,强制终止流
|
||||
consecutive_whitespace: usize,
|
||||
/// 是否已因无限空白 bug 被中止
|
||||
aborted: bool,
|
||||
}
|
||||
|
||||
/// 无限空白 bug 的连续空白字符阈值
|
||||
const INFINITE_WHITESPACE_THRESHOLD: usize = 20;
|
||||
const INFINITE_WHITESPACE_THRESHOLD: usize = 500;
|
||||
|
||||
fn build_anthropic_usage_json(usage: &Usage) -> Value {
|
||||
let mut usage_json = json!({
|
||||
|
||||
Reference in New Issue
Block a user