Context
This issue tracks a documentation-impact review for MervinPraison/PraisonAI#1546 — merged to main on 2026-04-24.
What changed in the SDK
1. src/praisonai/praisonai/inc/models.py
Added a defensive helper _is_module_available() that wraps importlib.util.find_spec() in a try/except to handle missing parent packages gracefully.
Before:
OPENAI_AVAILABLE = importlib.util.find_spec("openai") is not None
GOOGLE_GENAI_AVAILABLE = importlib.util.find_spec("google.generativeai") is not None
ANTHROPIC_AVAILABLE = importlib.util.find_spec("anthropic") is not None
COHERE_AVAILABLE = importlib.util.find_spec("cohere") is not None
After:
def _is_module_available(module_name: str) -> bool:
"""Safely check if a module spec is importable.
Guards against missing parent packages (e.g. `google.generativeai`
when the `google` namespace is absent) so test collection in a
base install does not fail.
"""
try:
return importlib.util.find_spec(module_name) is not None
except (ImportError, AttributeError, ValueError):
return False
OPENAI_AVAILABLE = _is_module_available("openai")
GOOGLE_GENAI_AVAILABLE = _is_module_available("google.generativeai")
ANTHROPIC_AVAILABLE = _is_module_available("anthropic")
COHERE_AVAILABLE = _is_module_available("cohere")
Public surface: The module-level booleans (OPENAI_AVAILABLE, GOOGLE_GENAI_AVAILABLE, ANTHROPIC_AVAILABLE, COHERE_AVAILABLE) remain unchanged in name, type, and meaning.
2. src/praisonai/praisonai/ui/_aiui_datastore.py
PraisonAISessionDataStore was refactored from a direct BaseDataStore subclass (with eager top-level imports) into a factory class that builds its implementation lazily via __new__.
- Top-level imports of
praisonaiui.datastore.BaseDataStore and praisonaiagents.session.* were removed.
- A module-private
_build_impl_cls() builds and caches an implementation class on first instantiation.
PraisonAISessionDataStore.__new__ now returns a configured instance of the lazily-built implementation.
- The
ImportError messages ("praisonaiui is required for PraisonAISessionDataStore. Install with: pip install 'praisonai[ui]'" and "praisonaiagents is required for ... Install with: pip install praisonaiagents") are preserved, but fire at instantiation time instead of import time.
Public surface:
- Class name:
PraisonAISessionDataStore — unchanged
- Constructor signature:
PraisonAISessionDataStore(store: Optional[SessionStoreProtocol] = None) — unchanged
- All async methods (
list_sessions, get_session, create_session, delete_session, add_message, get_messages) — unchanged
- Installation requirement (
pip install 'praisonai[ui]') — unchanged
- One subtle internal improvement:
super().__init__() is now properly called on BaseDataStore, replacing a prior runtime __bases__ pattern. Not user-visible.
Documentation-impact analysis
Per the PraisonAIDocs agent instructions (user-focused, non-developer-friendly, agent-centric, progressive disclosure), this PR is reviewed against the following checks:
| Check |
Result |
| Does it add a new user-facing feature? |
❌ No |
| Does it change any public import path? |
❌ No |
| Does it change any public class / function signature? |
❌ No |
| Does it add / change / remove configuration options? |
❌ No |
| Does it add / change / remove CLI flags? |
❌ No |
| Does it change installation extras or required packages? |
❌ No (same praisonai[ui] extra) |
| Does it alter user-visible error messages? |
❌ No (same text, later timing) |
| Does it change any example a user would copy-paste? |
❌ No |
Conclusion
No new documentation pages are required and no existing documentation pages need content updates.
This is a pure internal resilience fix — it only affects how Python resolves optional dependencies at test-collection / module-load time. End users of PraisonAI's public docs (who follow the Quick Start, install praisonai[ui], and call PraisonAISessionDataStore(...)) see zero behavior change.
Reference folders checked under MervinPraison/PraisonAIDocs:
praisonai/ui/_aiui_datastore.py (synced mirror) — reflects SDK, not user docs
praisonai/inc/models.py (synced mirror) — reflects SDK, not user docs
No .mdx pages under docs/features/, docs/guides/, or docs/tools/ reference PraisonAISessionDataStore or the internal OPENAI_AVAILABLE/GOOGLE_GENAI_AVAILABLE booleans in a way that would be invalidated by this PR.
Optional (low-priority) enhancements
If a future docs pass wants to proactively capture the spirit of this fix for users, these are the only places it could surface — all are optional and not required by this PR:
-
Installation / Getting Started troubleshooting note (optional):
A one-liner under an existing troubleshooting or installation page clarifying that the base pip install praisonai install now allows pytest --collect-only to succeed even without optional provider SDKs (openai, anthropic, cohere, google-generativeai) or praisonai[ui]. This is a developer-oriented note, not a user-feature note.
-
UI / Session store page (if one exists or is later added):
Add a <Note> callout clarifying that the praisonaiui and praisonaiagents packages are required only when PraisonAISessionDataStore() is actually instantiated — not at import time. Again, marginal value for end users.
Neither enhancement is blocking. If no dedicated page exists today for PraisonAISessionDataStore, creating one solely for this PR would contradict the guidance in AGENTS.md ("NEVER create placeholder content or stub pages").
Recommended action for the implementing agent
Recommendation: Close this issue with no documentation changes.
If the implementing agent disagrees and wants to add the optional troubleshooting note above:
- Target folder:
docs/features/ (or an existing troubleshooting/installation page if one is present — do not create docs/concepts/ content).
- Keep the addition to a single short
<Note> / <Tip> callout.
- Do not create a new page dedicated to this fix.
- Do not modify
docs/concepts/ (human-approved only per AGENTS.md §1.8).
- Do not modify auto-generated
docs/js/ or docs/rust/ sections.
- Verify that any imports referenced in examples still use the friendly form (
from praisonaiagents import ...) per AGENTS.md §6.1.
References
Context
This issue tracks a documentation-impact review for MervinPraison/PraisonAI#1546 — merged to
mainon 2026-04-24.fix: prevent test collection failures from optional modules9b2c0f904bb114f597e2a265efb01568f81f2b73src/praisonai/praisonai/inc/models.py,src/praisonai/praisonai/ui/_aiui_datastore.py)What changed in the SDK
1.
src/praisonai/praisonai/inc/models.pyAdded a defensive helper
_is_module_available()that wrapsimportlib.util.find_spec()in atry/exceptto handle missing parent packages gracefully.Before:
After:
Public surface: The module-level booleans (
OPENAI_AVAILABLE,GOOGLE_GENAI_AVAILABLE,ANTHROPIC_AVAILABLE,COHERE_AVAILABLE) remain unchanged in name, type, and meaning.2.
src/praisonai/praisonai/ui/_aiui_datastore.pyPraisonAISessionDataStorewas refactored from a directBaseDataStoresubclass (with eager top-level imports) into a factory class that builds its implementation lazily via__new__.praisonaiui.datastore.BaseDataStoreandpraisonaiagents.session.*were removed._build_impl_cls()builds and caches an implementation class on first instantiation.PraisonAISessionDataStore.__new__now returns a configured instance of the lazily-built implementation.ImportErrormessages ("praisonaiui is required for PraisonAISessionDataStore. Install with: pip install 'praisonai[ui]'"and"praisonaiagents is required for ... Install with: pip install praisonaiagents") are preserved, but fire at instantiation time instead of import time.Public surface:
PraisonAISessionDataStore— unchangedPraisonAISessionDataStore(store: Optional[SessionStoreProtocol] = None)— unchangedlist_sessions,get_session,create_session,delete_session,add_message,get_messages) — unchangedpip install 'praisonai[ui]') — unchangedsuper().__init__()is now properly called onBaseDataStore, replacing a prior runtime__bases__pattern. Not user-visible.Documentation-impact analysis
Per the PraisonAIDocs agent instructions (user-focused, non-developer-friendly, agent-centric, progressive disclosure), this PR is reviewed against the following checks:
praisonai[ui]extra)Conclusion
No new documentation pages are required and no existing documentation pages need content updates.
This is a pure internal resilience fix — it only affects how Python resolves optional dependencies at test-collection / module-load time. End users of PraisonAI's public docs (who follow the Quick Start, install
praisonai[ui], and callPraisonAISessionDataStore(...)) see zero behavior change.Reference folders checked under
MervinPraison/PraisonAIDocs:praisonai/ui/_aiui_datastore.py(synced mirror) — reflects SDK, not user docspraisonai/inc/models.py(synced mirror) — reflects SDK, not user docsNo
.mdxpages underdocs/features/,docs/guides/, ordocs/tools/referencePraisonAISessionDataStoreor the internalOPENAI_AVAILABLE/GOOGLE_GENAI_AVAILABLEbooleans in a way that would be invalidated by this PR.Optional (low-priority) enhancements
If a future docs pass wants to proactively capture the spirit of this fix for users, these are the only places it could surface — all are optional and not required by this PR:
Installation / Getting Started troubleshooting note (optional):
A one-liner under an existing troubleshooting or installation page clarifying that the base
pip install praisonaiinstall now allowspytest --collect-onlyto succeed even without optional provider SDKs (openai,anthropic,cohere,google-generativeai) orpraisonai[ui]. This is a developer-oriented note, not a user-feature note.UI / Session store page (if one exists or is later added):
Add a
<Note>callout clarifying that thepraisonaiuiandpraisonaiagentspackages are required only whenPraisonAISessionDataStore()is actually instantiated — not at import time. Again, marginal value for end users.Neither enhancement is blocking. If no dedicated page exists today for
PraisonAISessionDataStore, creating one solely for this PR would contradict the guidance in AGENTS.md ("NEVER create placeholder content or stub pages").Recommended action for the implementing agent
Recommendation: Close this issue with no documentation changes.
If the implementing agent disagrees and wants to add the optional troubleshooting note above:
docs/features/(or an existing troubleshooting/installation page if one is present — do not createdocs/concepts/content).<Note>/<Tip>callout.docs/concepts/(human-approved only per AGENTS.md §1.8).docs/js/ordocs/rust/sections.from praisonaiagents import ...) per AGENTS.md §6.1.References
AGENTS.mdin this repo