Issue: Delayed Flow Logging in Interactive Mode After Upgrading CrewAI from 0.114.0 to 0.159.0

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., โ€œ:ocean: 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!

I think your best bet is to interact with CrewAIโ€™s own logger:

from crewai.utilities import Logger

my_logger = Logger(verbose=True)

my_logger.log(
    "info",
    "Interacting with CrewAI's logger...",
    color="yellow"
)
1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.