Skip to content

fix(copilot): 调高无限空白检测阈值 20 → 500#2647

Open
NiuBlibing wants to merge 1 commit into
farion1231:mainfrom
NiuBlibing:fix/copilot-whitespace-threshold
Open

fix(copilot): 调高无限空白检测阈值 20 → 500#2647
NiuBlibing wants to merge 1 commit into
farion1231:mainfrom
NiuBlibing:fix/copilot-whitespace-threshold

Conversation

@NiuBlibing
Copy link
Copy Markdown

Summary

  • INFINITE_WHITESPACE_THRESHOLD20 调高到 500,避免误伤包含缩进代码的合法 tool call。
  • 阈值 20 太激进:write_file / edit_file 写入 4~8 层缩进的 Python/YAML/Rust/Markdown 代码时,单段连续空白(含 \n \t)轻松超过 20,导致整个 tool call 被静默丢弃。
  • 真实的 "infinite whitespace bug" 会持续输出数百~数千个空白,500 仍能可靠兜底,同时大幅降低误判。

详见 #2646

Test plan

  • 用 Copilot 路由触发一次 write_file,写入 8 层缩进的 YAML 或嵌套 Python 函数,确认 tool call 不再被中止、日志不再出现 检测到无限空白 bug
  • 回归现有用例(普通对话 / 短工具调用),确认无影响。

🤖 Generated with Claude Code

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 farion1231#2646

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@HeasonNn
Copy link
Copy Markdown

HeasonNn commented May 9, 2026

deepseekv4 pro调用工具时候也遇到这个问题了,很有用的fix!

@NiuBlibing
Copy link
Copy Markdown
Author

@farion1231 Hi, Could you help to review this pr?

@farion1231
Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@farion1231
Copy link
Copy Markdown
Owner

@codex review
@claude review

@claude
Copy link
Copy Markdown

claude Bot commented May 12, 2026

Claude finished @farion1231's task in 42s —— View job


Review

  • Load tools
  • Read changed file and surrounding context
  • Analyze the threshold change for correctness
  • Post review

LGTM.

One-line change at src-tauri/src/proxy/providers/streaming.rs:100 raises INFINITE_WHITESPACE_THRESHOLD from 20 to 500. The detection loop at lines 414–420 walks every char of each arguments delta and only resets consecutive_whitespace on a non-whitespace char — so a JSON-encoded write_file/edit_file payload containing deeply nested indented code (with \n + many spaces/tabs between non-whitespace tokens) can easily cross 20 and get falsely aborted. The PR's rationale matches the code: 500 is comfortably above any realistic indentation run while still catching the runaway-whitespace pathology, which emits orders of magnitude more.

No correctness, cross-platform, or security concerns introduced by this change.
· fix/copilot-whitespace-threshold

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@NiuBlibing
Copy link
Copy Markdown
Author

@farion1231 Hi, Is there anything that I need to change? Hope the fix can be merged.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants