Hi CrewAI team and community,
Iโm encountering an issue where flow execution tree is printed after the actual output and interactive prompts in my CrewAI flow. This happens in interactive mode, where I need to collect user inputs before proceeding to later methods in the flow. The logs appear delayed or batched at the end of steps, making the console output feel out of order and hard to follow during execution.
I recently upgraded from version 0.114.0
to 0.159.0
because I was getting telemetry-related errors in the older version (see topic). The upgrade fixed that, but now Iโm facing this logging issue, which is hindering my project progress.
As this is for my capstone projectโa CLI application for migrating legacy applications โI rely on smooth interactive flows to gather user inputs (e.g., migration preferences, codebase paths) before ingestion and code generation stages. The delayed logs make debugging and user experience confusing, as I can not see what I am entering as input.
Hereโs an example of the console output when running crewai run
:
๐ Starting Legacy Migration Flow with Code Generation
๐ฏ Interactive mode: True
โก Max concurrent files: 5
โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ Flow Execution โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ โ
โ Starting Flow Execution โ
โ Name: LegacyMigrationFlow โ
โ ID: 141f78ed-2b97-4523-8f76-09dda8de9123 โ
โ Tool Args: โ
โ โ
โ โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
Flow started with ID: 141f78ed-2b97-4523-8f76-09dda8de9123
๐ Flow: LegacyMigrationFlow
=== LEGACY MIGRATION ASSISTANT ===
๐ Hello! I specialize in migrating outdated PHP applications to Next.js.
I can help you modernize your legacy codebase efficiently.
Do you want to migrate from PHP to Next.js? (yes/no):
๐ Flow: LegacyMigrationFlow
ID: 141f78ed-2b97-4523-8f76-09dda8de9123
โโโ ๐ง Starting Flow...
โโโ ๐ Running: chatbot_greeting
As you can see, the interactive prompt (โDo you want to migrateโฆโ ) and task outputs appear first, while the flow logs (e.g., โ Flow: LegacyMigrationFlowโ, completed steps) are printed afterward, often in batches.
Relevant Code Snippet:
This is my flow start() method:
import logging
import json
import time
from datetime import datetime
from typing import Dict, Optional
from pathlib import Path
from mobelite_legacy.models import *
from mobelite_legacy.utils.chatbot_utils import *
from mobelite_legacy.crews import ConfigurationExtractionCrew, ConversationAnalysisCrew, ConfigurationSummaryCrew, MigrationGuideCrew
# ======================================================================================
# GLOBAL CONFIGURATION & INITIALIZATION
# ======================================================================================
### Initialize Logging ###
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
)
logger = logging.getLogger(__name__)
# State Setup
chatbot_state = ChatbotState()
set_chatbot_state(chatbot_state)
if chatbot_state is None:
raise RuntimeError("chatbot_state is not initialized. Call set_chatbot_state() first.")
# Session Configuration
session_id = "terminal_session"
# Safety Constants
MAX_CONVERSATION_TURNS = 15 # Prevent infinite conversation loops
MAX_RETRY_ATTEMPTS = 3 # Max retries for failed operations
# ======================================================================================
# CORE FLOW FUNCTIONS
# ======================================================================================
def chatbot_greeting(flow_instance):
"""Chatbot introduces itself and specialization"""
print("\n=== LEGACY MIGRATION ASSISTANT ===")
print("๐ Hello! I specialize in migrating outdated PHP applications to Next.js.")
print("I can help you modernize your legacy codebase efficiently.")
flow_instance.state.current_stage = MigrationStage.GREETING
# If not in interactive mode, skip interaction and set default migration path
if not flow_instance.interactive_mode:
flow_instance.state.migration_type = "default_migration_path"
return "default_migration_path"
try:
# Ask user for migration path preference (default or custom)
response = input("\nDo you want to migrate from PHP to Next.js? (yes/no): ").lower().strip()
flow_instance.state.migration_route_selection = response
except EOFError:
print_warning("\nNo input provided.")
Iโve tried configuring logging for real-time output and modifying the ConsoleFormatter.print
method to bypass live updates, but a core fix or workaround would be greatly appreciated. This is urgent for my capstone deadlineโany immediate help or pointers to similar issues would be fantastic!
Thanks in advance!