Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .claude/settings.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
},
{
"type": "command",
"command": "if [ \"$MLFLOW_CLAUDE_TRACING_ENABLED\" = \"true\" ]; then mlflow autolog claude -u http://127.0.0.1:$MLFLOW_PORT -n $MLFLOW_EXPERIMENT_NAME; fi"
"command": "if [ \"$MLFLOW_CLAUDE_TRACING_ENABLED\" = \"true\" ]; then python3 -c \"import mlflow; client=mlflow.tracking.MlflowClient(tracking_uri='http://127.0.0.1:$MLFLOW_PORT'); exp=client.get_experiment_by_name('$MLFLOW_EXPERIMENT_NAME'); client.restore_experiment(exp.experiment_id) if exp and exp.lifecycle_stage == 'deleted' else None\" && mlflow autolog claude -u http://127.0.0.1:$MLFLOW_PORT -n $MLFLOW_EXPERIMENT_NAME; fi"
}
]
}
Expand Down
6 changes: 3 additions & 3 deletions docs/mlflow-tracing.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ Use `.claude/settings.example.json` and copy the MLflow-related keys/hook blocks
Required pieces:
- `MLFLOW_CLAUDE_TRACING_ENABLED`, `MLFLOW_PORT`, `MLFLOW_EXPERIMENT_NAME`
- `SessionStart` and `Stop` hooks

## 4) Enable autologging and verify
Note: Set MLFLOW_CLAUDE_TRACING_ENABLED to false to disable tracking
## 4) Start claude

```bash
mlflow autolog claude -u "http://127.0.0.1:$MLFLOW_PORT" -n "$MLFLOW_EXPERIMENT_NAME"
claude
```

Then run Claude and execute an RCA prompt. If configured correctly, traces appear in your MLflow UI.
2 changes: 1 addition & 1 deletion skills/root-cause-analysis/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ If any checks have `"status": "missing"` and `"configurable": true`, offer to he
},
{
"type": "command",
"command": "if [ \"$MLFLOW_CLAUDE_TRACING_ENABLED\" = \"true\" ]; then mlflow autolog claude -u http://127.0.0.1:$MLFLOW_PORT -n $MLFLOW_EXPERIMENT_NAME; fi"
"command": "if [ \"$MLFLOW_CLAUDE_TRACING_ENABLED\" = \"true\" ]; then python3 -c \"import mlflow; client=mlflow.tracking.MlflowClient(tracking_uri='http://127.0.0.1:$MLFLOW_PORT'); exp=client.get_experiment_by_name('$MLFLOW_EXPERIMENT_NAME'); client.restore_experiment(exp.experiment_id) if exp and exp.lifecycle_stage == 'deleted' else None\" && mlflow autolog claude -u http://127.0.0.1:$MLFLOW_PORT -n $MLFLOW_EXPERIMENT_NAME; fi"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

export MLFLOW_PORT=5000
export MLFLOW_EXPERIMENT_NAME="team's-exp"

echo "Expect failure with direct interpolation into single-quoted Python string:"
if python3 -c "exp='$MLFLOW_EXPERIMENT_NAME'; print(exp)" >/dev/null 2>&1; then
  echo "Unexpected: interpolation variant succeeded"
  exit 1
else
  echo "Confirmed: interpolation variant fails when value contains single quote"
fi

echo "Expect success when reading env var inside Python:"
python3 -c "import os; exp=os.environ['MLFLOW_EXPERIMENT_NAME']; print(exp)" >/dev/null
echo "Confirmed: env-based variant succeeds"

Repository: redhat-et/rhdp-rca-plugin

Length of output: 304


🏁 Script executed:

cd /tmp && git -C redhat-et/rhdp-rca-plugin ls-files | grep -i skill

Repository: redhat-et/rhdp-rca-plugin

Length of output: 147


🏁 Script executed:

head -90 /tmp/redhat-et/rhdp-rca-plugin/skills/root-cause-analysis/SKILL.md | tail -20

Repository: redhat-et/rhdp-rca-plugin

Length of output: 194


🏁 Script executed:

git ls-files | grep -i skill

Repository: redhat-et/rhdp-rca-plugin

Length of output: 2360


🏁 Script executed:

fd SKILL.md

Repository: redhat-et/rhdp-rca-plugin

Length of output: 423


🏁 Script executed:

wc -l skills/root-cause-analysis/SKILL.md

Repository: redhat-et/rhdp-rca-plugin

Length of output: 108


🏁 Script executed:

sed -n '75,95p' skills/root-cause-analysis/SKILL.md

Repository: redhat-et/rhdp-rca-plugin

Length of output: 1442


🏁 Script executed:

sed -n '84p' skills/root-cause-analysis/SKILL.md

Repository: redhat-et/rhdp-rca-plugin

Length of output: 515


Avoid shell interpolation inside the inline Python snippet.

$MLFLOW_EXPERIMENT_NAME is injected directly into a Python single-quoted string; names containing ' will break python3 -c and skip tracing setup. Read env vars inside Python using os.environ[] instead.

Proposed fix
-            "command": "if [ \"$MLFLOW_CLAUDE_TRACING_ENABLED\" = \"true\" ]; then python3 -c \"import mlflow; client=mlflow.tracking.MlflowClient(tracking_uri='http://127.0.0.1:$MLFLOW_PORT'); exp=client.get_experiment_by_name('$MLFLOW_EXPERIMENT_NAME'); client.restore_experiment(exp.experiment_id) if exp and exp.lifecycle_stage == 'deleted' else None\" && mlflow autolog claude -u http://127.0.0.1:$MLFLOW_PORT -n $MLFLOW_EXPERIMENT_NAME; fi"
+            "command": "if [ \"$MLFLOW_CLAUDE_TRACING_ENABLED\" = \"true\" ]; then python3 -c \"import os, mlflow; uri=f'http://127.0.0.1:{os.environ[\\\"MLFLOW_PORT\\\"]}'; client=mlflow.tracking.MlflowClient(tracking_uri=uri); exp=client.get_experiment_by_name(os.environ['MLFLOW_EXPERIMENT_NAME']); client.restore_experiment(exp.experiment_id) if exp and exp.lifecycle_stage == 'deleted' else None\" && mlflow autolog claude -u http://127.0.0.1:$MLFLOW_PORT -n $MLFLOW_EXPERIMENT_NAME; fi"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@skills/root-cause-analysis/SKILL.md` at line 84, The inline python call that
references $MLFLOW_EXPERIMENT_NAME inside a single-quoted Python string can
break if the name contains quotes; change the command so the Python snippet
reads environment variables itself (e.g., use
os.environ.get('MLFLOW_EXPERIMENT_NAME') and os.environ.get('MLFLOW_PORT'))
instead of interpolating shell vars into the Python code, and keep the
surrounding shell conditional (MLFLOW_CLAUDE_TRACING_ENABLED) and the subsequent
mlflow autolog claude call unchanged; update the python3 -c invocation to import
os, read MLFLOW_EXPERIMENT_NAME/MLFLOW_PORT from os.environ, and use those
values when creating MlflowClient and restoring the experiment.

}
]
}
Expand Down
Loading