-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Fix: Add CREWAI_DISABLE_EMOJIS environment variable to disable emojis in logs #3063
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
…s in logs - Add environment variable CREWAI_DISABLE_EMOJIS to control emoji usage - Create comprehensive emoji-to-text mapping for runtime compatibility - Implement _get_icon() helper method in ConsoleFormatter - Replace all hardcoded emojis with dynamic icon selection - Add comprehensive test suite covering all emoji disable scenarios - Maintain backward compatibility (emojis enabled by default) - Fixes issue #3062 for Azure Functions and similar runtime environments Co-Authored-By: João <joao@crewai.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Disclaimer: This review was made by a crew of AI Agents. Code Review Comment: Emoji Handling EnhancementSummaryThis pull request successfully implements an environment variable-controlled emoji disable feature for the CrewAI console formatter, effectively addressing compatibility issues in environments that lack support for emoji display. The changes are well documented and maintain backward compatibility, which is commendable. Positive Aspects
Issues and Recommendations1. Environment Variable NamingIssue: The naming of the environment variable is somewhat ambiguous.
2. Simplification of Boolean ConversionIssue: The boolean conversion logic can be streamlined for better readability. def _parse_bool_env(val: str) -> bool:
return val.lower() in ("true", "1", "yes") if val else False
self.disable_emojis = _parse_bool_env(os.getenv("CREWAI_DISABLE_EMOJIS", "")) 3. EMOJI_MAP PlacementIssue: The emoji map is currently defined within the class, consuming memory unnecessarily for each instance. DEFAULT_EMOJI_MAP = {...}
class ConsoleFormatter:
def __init__(self):
self.emoji_map = DEFAULT_EMOJI_MAP.copy() 4. Type HintingIssue: Several methods lack type hints which could enhance clarity. def _get_icon(self, emoji: str) -> str: 5. Error Handling for Invalid EmojisIssue: The fallback for unrecognized emojis can result in empty strings or unclear responses. if emoji not in self.EMOJI_MAP:
return f"[ICON:{emoji.encode('ascii', 'ignore').decode('ascii') or 'UNKNOWN'}]" 6. Configuration ValidationIssue: There is currently no validation checking the completeness of the emoji mapping. 7. Performance OptimizationIssue: String operations in frequently called methods could be optimized. self.icon_cache = {emoji: text for emoji, text in self.EMOJI_MAP.items()} Security Considerations
Testing Suggestions
Documentation Enhancements
ConclusionOverall, the implementation is well-executed and extensively tested. Only minor improvements related to code organization and error handling are recommended. Addressing these suggestions will enhance the maintainability and robustness of the feature, ensuring it remains functional across different environments. Thank you for your effort in enhancing the usability of the console formatter! |
- Move EMOJI_MAP to module level as DEFAULT_EMOJI_MAP for memory efficiency - Add _parse_bool_env() helper function for cleaner boolean conversion - Implement performance optimization with icon caching - Improve error handling for unknown emojis with better fallback format - Update tests to work with new module structure - All functionality preserved and tests passing Addresses feedback from PR review #3063 Co-Authored-By: João <joao@crewai.com>
- Remove unused typing.Union import from console_formatter.py - Remove unused pytest and rich.text.Text imports from test file - All emoji disable functionality preserved and tests passing - Addresses CI lint failures in PR #3063 Co-Authored-By: João <joao@crewai.com>
Fix: Add CREWAI_DISABLE_EMOJIS environment variable to disable emojis in logs
Summary
This PR implements a solution to disable emojis in CrewAI logs for runtime environments like Azure Functions that have issues with emoji output. It adds a flexible configuration mechanism through the
CREWAI_DISABLE_EMOJIS
environment variable.Fixes #3062
Problem
Runtime environments like Azure Functions have issues with emoji output in logs, causing display problems and potential encoding issues. Users needed a way to disable emojis while maintaining all logging functionality.
Solution
CREWAI_DISABLE_EMOJIS
environment variable to control emoji usage_get_icon()
helper method inConsoleFormatter
for dynamic icon selectionUsage Examples
Default Behavior (Emojis Enabled)
Disable Emojis for Azure Functions
Environment Variable Options
The environment variable accepts various truthy values:
CREWAI_DISABLE_EMOJIS=true
CREWAI_DISABLE_EMOJIS=1
CREWAI_DISABLE_EMOJIS=yes
Any other value (including empty string) keeps emojis enabled.
Emoji Mapping
All emojis are mapped to clear, descriptive text alternatives:
[DONE]
[FAILED]
[CREW]
[TASK]
[TOOL]
[THINKING]
Testing
What I Actually Checked
What I Did Not Check
Files Changed
src/crewai/utilities/events/utils/console_formatter.py
- Core implementationtests/utilities/events/utils/test_console_formatter_emoji_disable.py
- Comprehensive test suitetests/utilities/events/utils/__init__.py
- Test directory initializationReviewer Checklist
Please verify:
CREWAI_DISABLE_EMOJIS=true
properly disables emojis in logsLink to Devin run: https://app.devin.ai/sessions/88c27c9e7bfa4f51b790cf037ece8418
Requested by: João (joao@crewai.com)