Skip to content

fix(cli): honor --provider flag in create_crew() and fix loop variable shadow#5721

Open
Beandon13 wants to merge 1 commit intocrewAIInc:mainfrom
Beandon13:fix/crewai-5270-provider-param-shadowed
Open

fix(cli): honor --provider flag in create_crew() and fix loop variable shadow#5721
Beandon13 wants to merge 1 commit intocrewAIInc:mainfrom
Beandon13:fix/crewai-5270-provider-param-shadowed

Conversation

@Beandon13
Copy link
Copy Markdown

Summary

  • The for provider, env_keys in ENV_VARS.items() loop was silently overwriting the provider function parameter, making the --provider CLI flag a no-op
  • The function always fell through to the interactive select_provider() prompt regardless of whether --provider openai was passed
  • Renamed the loop variable to env_provider (eliminating the shadow) and added an early-out path that uses the supplied provider directly when it is non-None

Closes #5270

Testing

pytest lib/crewai/tests/cli/test_create_crew.py::test_provider_param_skips_interactive_selection -v
PASSED lib/crewai/tests/cli/test_create_crew.py::test_provider_param_skips_interactive_selection

…e shadow

The for-loop `for provider, env_keys in ENV_VARS.items()` was shadowing
the `provider` function parameter, and the rest of the function always
called `select_provider()` interactively regardless of whether `--provider`
was supplied on the CLI.

Two changes:
1. Rename the loop variable to `env_provider` so the original `provider`
   parameter is no longer overwritten.
2. When `provider` is non-None (passed via --provider), skip the interactive
   provider-selection loop and use it directly as `selected_provider`.

Closes crewAIInc#5270

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Beandon13
Copy link
Copy Markdown
Author

Heads-up: this PR overlaps with open #5272 (and similarly-scoped closed #5401, #5274) on the loop-variable rename. The new behavior here on top of the rename is honoring the --provider flag end-to-end — without this PR, even after the rename, crewai create --provider openai still drops into the interactive select_provider() prompt. Happy to:

Either way the rename overlap is acknowledged.

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.

[BUG] create_crew() loop variable shadows provider function parameter

1 participant