Skip to content

write_to_file truncates filenames at special characters before file extensions #10328

@Sonic-Ninja

Description

@Sonic-Ninja

Problem (one or two sentences)

The write_to_file tool truncates filenames when the filename includes certain characters before the extension (e.g., hyphens, capitalization/camel case, or hyphens in parent directory names). This results in files being created with incomplete names and/or missing file extensions.

Context (who is affected and when)

This prevents generating files that follow common naming conventions, especially in JS/TS ecosystems where the following are standard:

kebab-case (my-file.ts)

CamelCase/PascalCase (MyFile.ts)

snake_case (my_file.ts)

numeric prefixes + hyphens (09-testing.md)

In practice, it breaks scaffolding workflows and automation since file names become corrupted and missing extensions.

Reproduction steps

Pattern / Heuristics Observed

Truncation appears to occur at:

Hyphens (-) near the filename/extension boundary
worker-service.ts → worker-

Periods (.) with CamelCase filenames
WorkerService.ts → WorkerService.

Hyphens in directory segments near the filename
09-testing.md → 09

This suggests the path parsing may be incorrectly tokenizing on - or . (or performing unsafe sanitization) and failing to preserve the full basename + extension.

Files That Worked Correctly (Control Cases)

These appear to succeed because they use simple lowercase naming without special characters:

src/worker/types/index.ts ✅

terraform/shared/backend.tf ✅

Expected result

write_to_file should create files using the exact path and filename provided, including the complete base name and file extension.

Actual result

When the target filename contains specific characters before the extension, the created file name is truncated.

Variations tried (optional)

No response

App Version

3.37.1

API Provider (optional)

Amazon Bedrock

Model Used (optional)

Claude Sonnet 4.5 and Opus 4.5

Roo Code Task Links (optional)

No response

Relevant logs or errors (optional)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue/PR - TriageNew issue. Needs quick review to confirm validity and assign labels.bugSomething isn't working

    Type

    No type

    Projects

    Status

    Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions