Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Python: [Bug]: InMemoryAgentFileStore permits a path to be both a file and a directory

Closed
#8,567 6 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@westey-m is already working on this.

Since Sep 21, 2026.

Assessment

This issue has not been assessed yet.

Description

harness python reproduced

Description

InMemoryAgentFileStore permits both Reports and Reports/q1.txt to exist. Consequently, list_children("") returns two entries named Reports, one reported as a file and one as a directory. A caller cannot tell which path to use, and this state cannot occur in FileSystemAgentFileStore.

This happens in either write order. write() checks only whether the exact file key exists; it does not reject a file ancestor or an existing descendant. Its case-insensitive key normalization means Reports and reports/q1.txt conflict as well.

Expected: Reject the second write without changing the existing content. A file path cannot also serve as a directory, regardless of casing.

Actual: Both writes succeed and the root listing contains a same-named file and directory.

Code Sample

import asyncio
from agent_framework import InMemoryAgentFileStore


async def main() -> None:
    store = InMemoryAgentFileStore()
    await store.write("Reports", "file")
    await store.write("Reports/q1.txt", "nested")
    print([(entry.name, entry.type) for entry in await store.list_children()])
    # [('Reports', 'directory'), ('Reports', 'file')]


asyncio.run(main())

The new regression test fails against the unmodified package (Failed: DID NOT RAISE NotADirectoryError) and passes against the local fix.

Error Messages / Stack Traces

None. The inconsistent state is accepted silently.

Package Versions

Source checkout at 999dda7970fe969c0901d524365ce34ecbda6227 (agent-framework-core version 1.18.0); the relevant write() implementation was also checked against the repository's current default branch on 2026-09-21. The public API reproduction and regression tests used this source checkout through an existing virtual environment, not a separately installed release package.

Python Version

Python 3.12.0 for the isolated source execution.

Additional Context

FileSystemAgentFileStore uses real filesystem paths, where a file cannot be the parent of another file and a nonempty directory cannot be replaced by a file. The in-memory store is used for tests and lightweight use, so matching this basic path invariant avoids testing a state the disk store cannot represent.

Local draft fix: reject a write if any ancestor is already a file or if the target path already has descendants. A focused regression test covers both write orders and verifies the existing content remains intact. The new test fails on the baseline and passes with the fix. The full test_harness_file_access.py file passes with the fix: 73 passed, 6 skipped. Ruff check, Ruff format check, py_compile, and git diff --check also pass. The reused virtual environment lacks pytest-timeout, causing an unrelated pytest configuration warning.

Searches of repository issues and PRs for InMemoryAgentFileStore conflict, file and directory same name, and file store path collision found no matching report or implementation on 2026-09-21.

Dominant language
Python
Stars
13.6k
Forks
2.3k
Avg merge
1d 14h
Merged PRs (30d)
451

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/agent-framework

All issues in microsoft/agent-framework

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.