Skip to content

speed up cli commands and startup times#3991

Closed
lorenzejay wants to merge 1 commit into
mainfrom
lorenze/lazy-loading-module-imports-cli
Closed

speed up cli commands and startup times#3991
lorenzejay wants to merge 1 commit into
mainfrom
lorenze/lazy-loading-module-imports-cli

Conversation

@lorenzejay

@lorenzejay lorenzejay commented Nov 28, 2025

Copy link
Copy Markdown
Collaborator

Note

Convert package and CLI to lazy-load heavy modules, minimizing import overhead and speeding up command startup.

  • Core (crewai/__init__.py):
    • Introduce lazy attribute access via __getattr__ to defer imports of Agent, Crew, Flow, LLM, etc.
    • Move Telemetry imports inside _track_install and _track_install_async to avoid eager import costs.
    • Keep public API via __all__ while reducing import-time work.
  • CLI (crewai/cli/cli.py):
    • Replace top-level imports with on-demand imports inside command handlers (e.g., create, train, replay, deploy, tool, flow, triggers, org, enterprise, config).
    • Update uv wrapper to import utils lazily and construct env at runtime.

Written by Cursor Bugbot for commit 8e175f7. This will update automatically on new commits. Configure here.

@lorenzejay lorenzejay marked this pull request as draft November 28, 2025 21:06
@github-actions

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open for 45 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants