Skip to content

fix(storage): Files not creating in correct folder - #537

Merged
aiosfoundation merged 2 commits into
agiresearch:mainfrom
RyamL1221:bugfix/files-not-creating-in-correct-folder
Apr 13, 2026
Merged

aiosfoundation merged 2 commits into
agiresearch:mainfrom
RyamL1221:bugfix/files-not-creating-in-correct-folder

Conversation

@RyamL1221

Copy link
Copy Markdown
Collaborator

fix: resolve storage file creation writing to wrong directory

Problem

When an agent requests file creation through the AIOS storage system (e.g., create_file with file_path="hello_world.txt"), the file is created in the repository root (AIOS/) instead of the configured storage root (AIOS/root/).

Root Cause

Two issues in aios/storage/filesystem/lsfs.py:

  1. Positional argument mismatch in address_request(): The create_file branch called self.sto_create_file(file_path, collection_name) positionally, but the method signature is sto_create_file(self, file_name, file_path, collection_name=None). This caused file_path to be interpreted as file_name and the agent name to be interpreted as file_path.

  2. Relative paths not resolved against root_dir: Even after fixing the argument order, sto_create_file, sto_create_directory, and sto_write only prepend self.root_dir when file_path is None. When an agent provides a relative path like "hello_world.txt", it was used as-is — creating the file relative to the process working directory instead of under root/.

Changes

File: aios/storage/filesystem/lsfs.py

  • address_request() — switched the create_file branch from positional args to keyword args (file_name=, file_path=, collection_name=), consistent with all other operation branches. Also extracts file_name from params.
  • sto_create_file() — added elif not os.path.isabs(file_path) to join relative paths with self.root_dir.
  • sto_create_directory() — same relative path fix.
  • sto_write() — same relative path fix.

Before / After

Scenario Before After
create_file(file_path="hello.txt") Created at AIOS/hello.txt Created at AIOS/root/hello.txt
create_file(file_path="/tmp/hello.txt") Created at /tmp/hello.txt Created at /tmp/hello.txt (absolute paths unchanged)
write(file_path="notes.txt", ...) Wrote to AIOS/notes.txt Wrote to AIOS/root/notes.txt

Documentation

No documentation changes required. This is a bugfix to internal storage path resolution logic with no API surface changes.

Testing

Verified manually by running the AIOS kernel and requesting file creation — files now land in AIOS/root/ as expected.

@aiosfoundation
aiosfoundation merged commit 041d8d8 into agiresearch:main Apr 13, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants