You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue #1540 was closed after PR #1792, which made file locking cross-platform in praisonai-agents (praisonaiagents/session/store.py).
On Windows, the same class of failure still exists in the PraisonAI CLI package at:
src/praisonai/praisonai/cli/session/unified.py
Because unified.py performs a top-level import fcntl, any code path that imports praisonai.cli.sessioncrashes at import time on Windows. This blocks pytest collection for tests/unit/cli/test_unified_session.py and breaks CLI/TUI session persistence features that depend on UnifiedSessionStore.
This is a follow-up / incomplete fix for #1540, not a new unrelated bug.
Architecture — two session stores, one fixed, one not
PraisonAI currently has two parallel session persistence implementations. Only one received the #1540 fix.
flowchart TB
subgraph AgentsPkg["praisonai-agents (FIXED in #1792)"]
AS["praisonaiagents/session/store.py"]
AS --> FL["FileLock class"]
FL --> WIN1["Windows: msvcrt.locking"]
FL --> UNIX1["Unix: fcntl.flock (optional)"]
AS --> DSS["DefaultSessionStore"]
end
subgraph CLIPkg["praisonai CLI (NOT FIXED)"]
INIT["praisonai/cli/session/__init__.py"]
UNI["praisonai/cli/session/unified.py"]
INIT --> UNI
UNI --> FCNTL["import fcntl (line 12)"]
FCNTL --> CRASH["ModuleNotFoundError on Windows"]
UNI --> USS["UnifiedSessionStore.save/load"]
USS --> FCNTL2["fcntl.flock in save/load"]
end
subgraph Consumers["Broken import chain on Windows"]
TEST["tests/unit/cli/test_unified_session.py"]
MAIN["praisonai/cli/main.py (TUI / interactive)"]
TEST --> INIT
MAIN --> get_store["get_session_store()"]
get_store --> INIT
end
style CRASH fill:#8B0000,color:#fff
style FCNTL fill:#8B0000,color:#fff
style WIN1 fill:#2d6a4f,color:#fff
style UNIX1 fill:#2d6a4f,color:#fff
Loading
Failure flow (Windows)
sequenceDiagram
participant Dev as Developer (Windows)
participant Py as python -m pytest
participant Test as test_unified_session.py
participant Init as cli/session/__init__.py
participant Uni as cli/session/unified.py
participant OS as Windows Python 3.13
Dev->>Py: collect tests/unit/cli/test_unified_session.py
Py->>Test: import test module
Test->>Init: from praisonai.cli.session.unified import ...
Init->>Uni: load unified.py
Uni->>OS: import fcntl
OS-->>Uni: ModuleNotFoundError
Uni-->>Py: ImportError during collection
Py-->>Dev: ERROR: interrupted - 1 error during collection
Loading
Reproduction (verified on Windows)
Environment
Key
Value
OS
Windows 10/11
Python
3.13.2
Version
v4.6.52 (praisonai__version__ = "4.6.52")
Install
Editable: pip install -e src/praisonai
Working directory
src/praisonai (important — tests live under this package root)
Step 1 — Import fails (root cause)
cd C:\Users\DELL\Downloads\praisonai\src\praisonai
python -c "import praisonai.cli.session.unified"
Actual output:
Traceback (most recent call last):
File "<string>", line 1, in <module>
import praisonai.cli.session.unified
File ".../praisonai/cli/session/__init__.py", line 7, in <module>
from .unified import UnifiedSession, UnifiedSessionStore, get_session_store
File ".../praisonai/cli/session/unified.py", line 12, in <module>
import fcntl
ModuleNotFoundError: No module named 'fcntl'
Step 2 — Pytest collection fails
cd C:\Users\DELL\Downloads\praisonai\src\praisonai
python -m pytest tests/unit/cli/test_unified_session.py --collect-only -q
Actual output (abbreviated):
ImportError while importing test module '...\tests\unit\cli\test_unified_session.py'.
...
praisonai\cli\session\unified.py:12: in <module>
import fcntl
E ModuleNotFoundError: No module named 'fcntl'
!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
Step 3 — Agents package fix works (contrast)
cd C:\Users\DELL\Downloads\praisonai\src\praisonai-agents
python -m pytest tests/unit/session/test_session_store.py -k fcntl -q
Result:1 passed — confirms #1792 fix is valid only in praisonai-agents.
Common mistake (not this bug)
Running pytest from repo rootpraisonai/ without the src/praisonai prefix gives:
ERROR: file or directory not found: tests/unit/cli/test_unified_session.py
That is a wrong working directory, not evidence that #1540 is fixed.
# Line 12 — unconditional import; fails on Windows at import timeimportfcntl# Lines 146-150, 183-187 — direct fcntl usage in save/loadfcntl.flock(f.fileno(), fcntl.LOCK_EX)
fcntl.flock(f.fileno(), fcntl.LOCK_UN)
Recommendation: Reuse the same FileLock helper from praisonaiagents.session.storeor duplicate the same cross-platform pattern in unified.py (prefer reuse to avoid drift).
User impact
Area
Impact on Windows
tests/unit/cli/test_unified_session.py
Cannot collect or run
praisonai TUI / interactive session resume
main.py imports get_session_store() → may fail when session module loads
Issue #1540 appears closed on GitHub but CLI path still broken
Proposed fix
Remove top-level import fcntl from unified.py.
Use cross-platform locking consistent with praisonaiagents/session/store.py:
msvcrt on win32
optional fcntl on Unix
one-time warning if locking degraded
Add regression test under src/praisonai/tests/unit/cli/ that mocks or skips when needed, and verifies import praisonai.cli.session.unified succeeds without fcntl on Windows.
Summary
Issue #1540 was closed after PR #1792, which made file locking cross-platform in
praisonai-agents(praisonaiagents/session/store.py).On Windows, the same class of failure still exists in the PraisonAI CLI package at:
src/praisonai/praisonai/cli/session/unified.pyBecause
unified.pyperforms a top-levelimport fcntl, any code path that importspraisonai.cli.sessioncrashes at import time on Windows. This blocks pytest collection fortests/unit/cli/test_unified_session.pyand breaks CLI/TUI session persistence features that depend onUnifiedSessionStore.This is a follow-up / incomplete fix for #1540, not a new unrelated bug.
Background — what was reported and what was fixed
Original report (#1540)
ModuleNotFoundError: No module named 'fcntl'during pytest collection on WindowsWhat PR #1792 actually changed
Commit
bc73dd1d— "Issue #1540: Changes from Claude (#1792)" — modified only:src/praisonai-agents/praisonaiagents/session/store.pyfcntlimport,_HAS_FCNTL,msvcrton Windows, regression testssrc/praisonai-agents/tests/unit/session/test_session_store.pyNot modified:
src/praisonai/praisonai/cli/session/unified.pyimport fcntlat line 12src/praisonai/praisonai/cli/session/__init__.pyunified→ import failsGitHub state vs runtime state
praisonai-agentssession storepytest -k fcntlpassespraisonaiCLI unified sessionArchitecture — two session stores, one fixed, one not
PraisonAI currently has two parallel session persistence implementations. Only one received the #1540 fix.
flowchart TB subgraph AgentsPkg["praisonai-agents (FIXED in #1792)"] AS["praisonaiagents/session/store.py"] AS --> FL["FileLock class"] FL --> WIN1["Windows: msvcrt.locking"] FL --> UNIX1["Unix: fcntl.flock (optional)"] AS --> DSS["DefaultSessionStore"] end subgraph CLIPkg["praisonai CLI (NOT FIXED)"] INIT["praisonai/cli/session/__init__.py"] UNI["praisonai/cli/session/unified.py"] INIT --> UNI UNI --> FCNTL["import fcntl (line 12)"] FCNTL --> CRASH["ModuleNotFoundError on Windows"] UNI --> USS["UnifiedSessionStore.save/load"] USS --> FCNTL2["fcntl.flock in save/load"] end subgraph Consumers["Broken import chain on Windows"] TEST["tests/unit/cli/test_unified_session.py"] MAIN["praisonai/cli/main.py (TUI / interactive)"] TEST --> INIT MAIN --> get_store["get_session_store()"] get_store --> INIT end style CRASH fill:#8B0000,color:#fff style FCNTL fill:#8B0000,color:#fff style WIN1 fill:#2d6a4f,color:#fff style UNIX1 fill:#2d6a4f,color:#fffFailure flow (Windows)
sequenceDiagram participant Dev as Developer (Windows) participant Py as python -m pytest participant Test as test_unified_session.py participant Init as cli/session/__init__.py participant Uni as cli/session/unified.py participant OS as Windows Python 3.13 Dev->>Py: collect tests/unit/cli/test_unified_session.py Py->>Test: import test module Test->>Init: from praisonai.cli.session.unified import ... Init->>Uni: load unified.py Uni->>OS: import fcntl OS-->>Uni: ModuleNotFoundError Uni-->>Py: ImportError during collection Py-->>Dev: ERROR: interrupted - 1 error during collectionReproduction (verified on Windows)
Environment
praisonai__version__ = "4.6.52")pip install -e src/praisonaisrc/praisonai(important — tests live under this package root)Step 1 — Import fails (root cause)
Actual output:
Step 2 — Pytest collection fails
Actual output (abbreviated):
Step 3 — Agents package fix works (contrast)
Result:
1 passed— confirms #1792 fix is valid only inpraisonai-agents.Common mistake (not this bug)
Running pytest from repo root
praisonai/without thesrc/praisonaiprefix gives:ERROR: file or directory not found: tests/unit/cli/test_unified_session.pyThat is a wrong working directory, not evidence that #1540 is fixed.
Code comparison
Broken —
praisonai/cli/session/unified.py(v4.6.52)Fixed pattern —
praisonaiagents/session/store.py(#1792)Recommendation: Reuse the same
FileLockhelper frompraisonaiagents.session.storeor duplicate the same cross-platform pattern inunified.py(prefer reuse to avoid drift).User impact
tests/unit/cli/test_unified_session.pypraisonaiTUI / interactive session resumemain.pyimportsget_session_store()→ may fail when session module loadspraisonaipackageProposed fix
import fcntlfromunified.py.praisonaiagents/session/store.py:msvcrtonwin32fcntlon Unixsrc/praisonai/tests/unit/cli/that mocks or skips when needed, and verifiesimport praisonai.cli.session.unifiedsucceeds withoutfcntlon Windows.Acceptance criteria
python -c "import praisonai.cli.session.unified"succeeds on Windows withoutfcntlinstalledpytest tests/unit/cli/test_unified_session.py --collect-onlycollects tests with zero import errors on WindowsUnifiedSessionStore.save()/load()still provide exclusive/shared locking on Unix (no regression)msvcrt(or sharedFileLockclass)praisonai-agentssession store tests remain greenVerification
Manual verification on Windows:
unified.py:12: import fcntl→ModuleNotFoundErrorpraisonai-agentsfcntl regression testLabels (suggested)
bug,windows,documentation(optional — if tracking partial #1540 closure)References
bc73dd1d)