Skip to content

bug(core): cancelled file tools can still mutate files #8493

Description

@ryan-mt

What happened?

write_file and edit can still mutate the filesystem after their invocation has been cancelled. Both tools perform asynchronous preparation and edit-tracking work before the final write. If the abort signal fires while that work is pending, execution continues into the filesystem mutation.

Deterministic reproduction:

  1. Start a write_file or edit invocation with an AbortSignal.
  2. Delay the asynchronous edit-tracking step immediately before the write.
  3. Abort the signal while that step is pending.
  4. Resolve the delayed step.
  5. Observe that the target file is still created or modified.

What did you expect to happen?

Once cancellation is observed before the filesystem mutation begins, the invocation should reject as aborted and leave the target file unchanged.

Client information

Client Information
Qwen Code: 0.21.4
Platform: Windows 11
Node.js: v24.16.0
npm: 11.13.0

Login information

Not login-provider specific; reproduced with deterministic core tool tests.

Anything else we need to know?

The required guard belongs immediately before the first irreversible filesystem mutation, after asynchronous tracking/preparation has completed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    category/coreCore engine and logicpriority/P2Medium - Moderately impactful, noticeable problemscope/file-operationsFile system operationstype/bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions