Skip to content

Write tool JSON parsing error with large files and special characters #11630

Closed

Description

@rizwankce

Bug Description

The Write tool consistently fails with JSON parsing errors when writing files that contain:

  1. Large content (>~1000 characters)
  2. Special characters (quotes, newlines, backticks)
  3. Code blocks with nested structures

Error Messages

Common errors encountered:

  • JSON Parse error: Unterminated string
  • Invalid input for tool write: JSON parsing failed
  • JSON Parse error: Expected ']'

Reproduction Steps

  1. Try to write a Rust file with ~200+ lines using the Write tool
  2. Content includes code with quotes, backticks, or special characters
  3. Error occurs consistently

Example that fails:

/// Fixed-point arithmetic module (16.16 format)
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Fixed(i32);

impl Fixed {
    const FRACTIONAL_BITS: i32 = 16;
    // ... more code with quotes and special chars
}

Workaround

Using bash with heredoc works reliably:

cat > /path/to/file.rs << 'EOF'
// Large file content here
// With any special characters
EOF

Environment

  • Platform: macOS (darwin)
  • Model: kimi-k2.5-free
  • Working with: Rust code files, Markdown documentation

Impact

  • Must use bash workarounds for any substantial file writes
  • Breaks flow when editing multiple files
  • Limits ability to use Write tool effectively

Suggested Fix

Either:

  1. Increase JSON string size limits
  2. Better escaping for special characters
  3. Alternative write method for large files
  4. Document the limitation and recommend bash for large files

Activity

  1. github-actions commented on Feb 1, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if none of these address your specific case.

  2. github-actions commented on Apr 3, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions