-
Notifications
You must be signed in to change notification settings - Fork 5.4k
fix: add Flow verbose parameter to disable output #3933
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Add verbose parameter to Flow class to control console output and logging. Previously, flow events were always printed regardless of verbosity settings. Changes: - Add verbose: bool = False parameter to Flow.__init__ - Gate _log_flow_event to only print/log when verbose=True - Fix print_panel to respect verbose even when is_flow=True - Update event listeners to check Flow.verbose flag - Add comprehensive tests for verbose functionality - Update documentation with verbose parameter usage Fixes crewAIInc#3826
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is being reviewed by Cursor Bugbot
Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| tree = self.formatter.create_flow_tree(event.flow_name, str(source.flow_id)) | ||
| self.formatter.current_flow_tree = tree | ||
| finally: | ||
| self.formatter.verbose = original_verbose |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Race condition in concurrent flow verbose handling
The flow event handlers temporarily modify the shared singleton self.formatter.verbose without thread synchronization. When multiple flows run concurrently, one handler can save the verbose value while another handler has already modified it, causing the wrong value to be restored. This results in flows incorrectly inheriting verbose settings from other concurrent flows. The EventListener is a singleton with a shared formatter instance, but the verbose flag manipulation lacks the thread safety that _crew_tree_lock provides for other operations.
Additional Locations (2)
- Wrap verbose flag manipulation with _crew_tree_lock in all flow event handlers to prevent race conditions in concurrent flows - Fix tracing parameter to respect tracing=False and always disable when explicitly False - Only check environment settings when tracing=None (default behavior)
… tracing approach - Keep verbose parameter from fix/flow-verbosity-control branch - Use main branch's tracing approach with should_enable_tracing and set_tracing_enabled - Add missing tracing utility functions (has_user_declined_tracing, should_enable_tracing, set_tracing_enabled) - Ensure tracing=False properly disables tracing as documented
…plementation - Replace global variable approach with ContextVar for thread-safe context-aware tracing - Add ContextVar-based should_enable_tracing, set_tracing_enabled, reset_tracing_enabled, is_tracing_enabled_in_context - Update mark_first_execution_done to accept user_consented parameter - Update mark_first_execution_completed to match main branch signature - Update is_tracing_enabled to check has_user_declined_tracing first - Remove duplicate implementations from fix/flow-verbosity-control branch
| # If user has explicitly declined tracing, never enable it | ||
| if has_user_declined_tracing(): | ||
| return False | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: User consent not recorded in first execution confirmation
The function calls mark_first_execution_done() before prompting the user and doesn't pass the user's consent response. This means trace_consent is always recorded as False regardless of whether the user confirms or declines tracing. The user's response from click.confirm() needs to be captured and passed to mark_first_execution_done(user_consented=response) after the prompt.
- Move is_tracing_enabled() to after has_user_declined_tracing() to match main branch structure - Move user data functions (_user_data_file, _load_user_data, _save_user_data, has_user_declined_tracing) to right after is_tracing_enabled_in_context() - Ensure function order matches main branch exactly to resolve merge conflicts
Add verbose parameter to Flow class to control console output and logging. Previously, flow events were always printed regardless of verbosity settings.
Changes:
Fixes #3826
Note
Adds
Flow(verbose=False)to silence flow output by default and centralizes tracing enablement; updates listeners/formatter to respect verbosity, expands tracing utils, and documents/tests the behavior.lib/crewai/src/crewai/flow/flow.py):verbose: bool = FalsetoFlow.__init__and gate_log_flow_eventand flow logs byself.verbose.tracingdefault toNone; determine viashould_enable_tracing()and set context withset_tracing_enabled(); always set upTraceCollectionListener; simplify batch finalization.lib/crewai/src/crewai/events/event_listener.py: Flow event handlers temporarily setConsoleFormatter.verbosefromsource.verbose.lib/crewai/src/crewai/events/utils/console_formatter.py: All flow/crew/task/method printing functions (e.g.,print_panel,start_flow,update_flow_status,update_method_status) now no-op whenverboseis false.lib/crewai/src/crewai/events/listeners/tracing/utils.py):ContextVar):set_tracing_enabled,reset_tracing_enabled,is_tracing_enabled_in_context.should_enable_tracing()with precedence (override -> env -> user consent); persist consent via updated user data helpers; update first-execution markers to storetrace_consent.should_auto_collect_first_time_traces()logic to respect declines/context.docs/en/concepts/flows.mdx):@persistand difference betweenverboseandtracing.lib/crewai/tests/test_flow_verbose.pycovering defaults, logging behavior, formatter gating, and independence fromtracing/persistence.Written by Cursor Bugbot for commit 1abb455. This will update automatically on new commits. Configure here.