Skip to content

fix(crew): make smallestai.atoms.crew export its public API (lazy) - #119

Merged
abhishekmishragithub merged 3 commits into
mainfrom
fix-crew-init-lazy-exports
Sep 15, 2026
Merged

abhishekmishragithub merged 3 commits into
mainfrom
fix-crew-init-lazy-exports

Conversation

@abhishekmishragithub

Copy link
Copy Markdown
Collaborator

Why

A customer hit ImportError on from smallestai.atoms.crew import AtomsCrewApp (smallestai 5.12.0). crew/__init__.py was docstring-only — it exported nothing, even though the docstring advertised that exact import. Only the submodule path smallestai.atoms.crew.server worked. Our own docs (overview.mdx) used the broken short path too (fixed in docs #451).

Fix

Add a PEP 562 __getattr__ that lazily imports the public symbols from their submodules:
AtomsCrewApp, CrewSession, OutputCrewNode, BackgroundCrewNode, OpenAIClient, function_tool, ToolRegistry.

Lazy on purpose: server imports fastapi/uvicorn, so an eager from .server import ... would make import smallestai.atoms.crew require those deps. With __getattr__, the package imports with no extra deps and each symbol resolves on first access. A TYPE_CHECKING block preserves type-checker/IDE resolution. The .server submodule paths keep working.

Verified

  • import smallestai.atoms.crew succeeds without eagerly importing fastapi.
  • from smallestai.atoms.crew import AtomsCrewApp (the customer's failing line) resolves.
  • __all__/__dir__ populated; unknown attribute raises AttributeError.
  • crew/** is .fernignored, so this survives SDK regeneration.

crew/__init__.py was docstring-only, so 'from smallestai.atoms.crew import
AtomsCrewApp' raised ImportError (customer-reported) even though the docstring
advertised that path. Add a PEP 562 __getattr__ that lazily imports the public
symbols (AtomsCrewApp, CrewSession, OutputCrewNode, BackgroundCrewNode,
OpenAIClient, function_tool, ToolRegistry) from their submodules. Lazy so
importing the package doesn't eagerly pull crew runtime deps (fastapi/uvicorn);
the .server submodule paths still work. TYPE_CHECKING block keeps type/IDE
resolution. Verified: package import needs no fastapi; short import resolves.
@crim-app

crim-app Bot commented Sep 15, 2026

Copy link
Copy Markdown

crim doesn't review pull requests automatically here.

Comment crim review on this pull request whenever you want a review.

Executes 'from smallestai.atoms.crew import AtomsCrewApp, CrewSession, ...' so the
exact ImportError a customer hit can't silently come back. Lives in tests/custom
(fernignored), runs in the SDK test CI.
@abhishekmishragithub
abhishekmishragithub merged commit 54f52ce into main Sep 15, 2026
5 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.

1 participant