Bug: Concurrent file writes from different sessions not serialized — workspace file corruption
Author: hamb1yCreated Jul 6, 2026Updated Sep 28, 2026
Summary
File tools (ReadFileTool, WriteFileTool, EditFileTool) do not acquire any file-level lock before writing. Two concurrent agent turns in different sessions can write to the same file simultaneously, causing data corruption or interleaved writes.
Affected Code
nanobot/agent/tools/filesystem.py:43-101— no file-level locking in any toolnanobot/agent/tools/apply_patch.py:268-284— multi-step atomic write pattern vulnerable to concurrent modification
Suggested Fix
- Add
fcntl.flock()or a workspace-level file lock manager - At minimum, serialize writes per-file within the same workspace
Source: HKUDS/nanobot