ITADN

fix: prevent infinite whitespace in grammar rules (fixes #93)

#95Pull Requestawanawana 创建于 2026-03-23
A
awanawanacommented
## Summary - Fixes the grammar bug causing infinite whitespace generation in function calling - Changes `ws ::= ([ \t\n]+)` to `ws ::= ([ \t\n]?)` to prevent token exhaustion ## Problem As reported in #93, the current whitespace rule allows unlimited consecutive whitespace: ``` ws ::= ([ \t\n]+) ``` At temperature 0.8, this causes ~10% of function calls to fail with endless `\t` repetition, producing invalid JSON. ## Solution Changed to: ``` ws ::= ([ \t\n]?) ``` This allows **zero or one** whitespace character: - Prevents infinite loops - Maintains JSON validity (whitespace is optional in JSON) - More permissive than `{1}` (exactly one) for edge cases where no whitespace is needed ## Testing - Based on the fix approach suggested by @michelonfrancoisSUMMIT in #93 - The `?` quantifier is slightly more flexible than `{1}` while still preventing the infinite loop ## Related Fixes #93 🤖 Generated with [Claude Code](https://claude.com/claude-code)
合并状态:未合并 1 条评论