Python: [Bug]: InMemoryAgentFileStore permits a path to be both a file and a directory
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
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/agent-framework
-
Python: raw-data content mappings lose annotations and attachment metadataPossibly taken @moonbox3 claimed this 3 days ago. Openpython triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
microsoft/agent-framework#8632 · 2 comments ·
Maintainers usually reply within 1 day
-
Python: Clarify when to use platformPossibly taken @eavanvalkenburg claimed this 2 days ago. Openpython triage
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
microsoft/agent-framework#8599 · 1 comment ·
Maintainers usually reply within 1 day
-
.NET compaction documentation
Difficulty 1/5 Under an hour Newbie friendliness 82/100
microsoft/agent-framework#4629 · 1 comment ·
Maintainers usually reply within 1 day
-
Python: [Bug]: A handoff autonomous turn limit of 0 silently becomes the default 50 turnsPossibly taken @eavanvalkenburg claimed this today. Openorchestration python reproduced
microsoft/agent-framework#8964 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
.NET: [Bug]: AddAGUIServer's JSON setup writes null optional fields (rejected by @ag-ui/client) and cannot serialize interruptsPossibly taken @javiercn claimed this today. Open.NET ag-ui hosting reproduced
microsoft/agent-framework#8962 · 2 comments · 1 assignee ·
Maintainers usually reply within 1 day
All issues in microsoft/agent-framework
Similar issues
-
tool-calling
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
vllm-project/vllm#59838 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
raullenchai/Rapid-MLX#4042 ·
Maintainers usually reply within 1 day
-
documentation
Difficulty 1/5 Under an hour Newbie friendliness 92/100
transitmatters/mbta-slow-zone-bot#70 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
litestar-org/advanced-alchemy#811 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day