From Oops to Ops: Smart Task Failure Diagnosis with OpenAI
summary
An experimental Airflow extension uses OpenAI to diagnose task failures by invoking an assistant on a failure callback, packaging DAG code, stack snippets and BigQuery SQL, uploading files to a file search tool, running GPT‑4o‑mini and returning structured JSON that it writes diagnosis to logs and Slack. It identifies concrete causes (missing dataset, partition field typo, SQL type mismatch, bad API id), suggests fixes and rewrites SQL, costs ~ $0.02 per GPT‑4 call (mini is a fraction of a cent), and fails to go deeper when tracebacks are discarded and assistants are created per callback.
AI-written summary · about
chapters (11)
- 0:00Introduction and background
- 1:04Airflow and Gen AI overview
- 2:09Airflow task failure diagnosis concept
- 3:32Implementation with OpenAI platform
- 6:23Building context for diagnosis
- 7:27Assistant configuration details
- 8:31Prompt engineering best practices
- 9:37File upload and thread setup
- 10:39Processing and output of diagnosis
- 11:00Live demo examples
- 16:41Summary and future considerations
