mlflow/ai_commands/genai/analyze_experiment.md
Analyzes traces in an MLflow experiment for quality issues, performance problems, and patterns.
MCP: Skip to Section 1.2 (auth is pre-configured). Use MCP trace tools.
CLI: Start with Section 1.1 for auth setup. Use mlflow traces commands.
IMPORTANT: When you ask the user a question, you MUST WAIT for their response before continuing.
REQUIRED FIRST: Ask user "How do you want to authenticate to MLflow?"
Option 1: Local/Self-hosted MLflow
sqlite:////path/to/mlflow.dbpostgresql://user:password@host:port/databasemysql://user:password@host:port/databasefile:///path/to/mlruns or just /path/to/mlrunsmlflow.env) containing:
MLFLOW_TRACKING_URI=<provided_uri>
Option 2: Databricks
Ask which authentication method:
DATABRICKS_HOST and DATABRICKS_TOKENDATABRICKS_CONFIG_PROFILE nameAsk user to create an environment file (e.g., mlflow.env) containing:
# For PAT Auth:
MLFLOW_TRACKING_URI=databricks
DATABRICKS_HOST=<provided_host>
DATABRICKS_TOKEN=<provided_token>
# OR for Profile Auth:
MLFLOW_TRACKING_URI=databricks
DATABRICKS_CONFIG_PROFILE=<provided_profile>
Option 3: Environment Variables Already Set
uv run python -m mlflow experiments search --max-results 10--env-file flagAsk user for the path to their environment file (if using Options 1-2)
Test connection: uv run --env-file <env_file_path> python -m mlflow experiments search --max-results 5
If MLFLOW_EXPERIMENT_ID not already set, list available experiments and ask user to select one:
MLFLOW_EXPERIMENT_ID=<experiment_id> to environment fileSearch for traces (max_results=5) to verify:
Extract sample trace IDs for testing
Get one full trace by trace_id that has state OK to understand the data structure (errors might not have the structure)
NOTE: Use trace exploration tools - DO NOT use inline Python scripts during this phase
Show your thinking as you go: Always explain your hypothesis development process including:
Process traces in batches of 10, building and refining hypotheses with each batch:
After confirming ANY hypothesis (operational or quality): Track assessments for inclusion in final report:
1:1 Correspondence: Each assessment must correspond to ONE specific issue/hypothesis
Use snake_case names as assessment keys (e.g., overly_verbose, tool_failure, rate_limited, slow_response)
Track which traces exhibit each issue with detailed rationales
Document specifics like:
Error Analysis
Performance Problems (High Latency Analysis)
NOTE: Use trace exploration tools - DO NOT use inline Python scripts during this phase
Focus on response quality, not operational performance:
NOTE: Use trace exploration tools - DO NOT use inline Python scripts during this phase
Process successful traces to identify what's working well:
Successful Interactions
Effective Tool Usage
Quality Responses
experiment_analysis.md)