@failure_hook captures the exception and stack trace and hands it to the agent, which posts a triage summary, applies the minimal fix on a new branch, and opens one pull request per failed run.
Prerequisites
- GitHub connected so the healer can create branches and open PRs against the workspace repository.
- Slack connected so the healer can post its triage summary and progress.
- A Paradime API endpoint, key, and secret with
DinoAI agent APIcapabilities enabled (Workspace Settings, API; requires Admin access). Keys are workspace-scoped: generate the key from the workspace whose connected repository contains your.dinoai/agents/folder, because the agent always runs in the workspace that issued the key. - Familiarity with programmable agents.
Steps
1
Create the agent
Build the healer in the Agent UI: fill in the builder fields below, leave Model on Auto, then select Deploy and choose Open a pull request so the definition lands at Goal:Backstory:Allowed tools:
.dinoai/agents/dagster-pipeline-healer.yml. (Prefer working as code? That file is the full definition, and you can author or edit it by hand from then on.)Name: dagster-pipeline-healerRole:read_file, search_files_and_directories, ripgrep_search, run_sql_query, run_terminal_commandOutput: Slack channel #dagster-dinoai-self-healingAdapt the error-to-file mapping in step 3 of the Goal to your own repository layout. The mapping is what lets the agent go from a stack trace to the right file without exploring the whole repo.
2
Add the failure hook
The hook fires in-process the moment an op fails: no sensor polling, no daemon dependency. Create Then attach the hook to your jobs at definition time:Finally, set the three environment variables wherever your Dagster code runs,
dagster_project/hooks.py:dagster_project/hooks.py
dagster_project/jobs.py
dagster dev locally or your deployment’s environment configuration in production:The hook is a graceful no-op when the env vars are unset: it logs a warning and returns. Local development without credentials never fails a run because of the hook, and the original op failure is always surfaced normally in Dagster either way.
3
Test it end-to-end
Verify the loop with a deliberate, controlled failure. Two rules make or break the test:This parses fine, Dagster loads, and the model fails in the warehouse with
- The break must be a runtime error, not a parse error. A typo’d
ref()breaks dbt parsing, which breaks Dagster’s code-location load itself. The run dies with “Could not load job definition” before any op starts, and the hook never fires. Instead, reference a column that doesn’t exist in the source table:
Unrecognized name: grand_prix_sponsor, a real op failure that fires the hook.- The break must be pushed to the branch your Paradime workspace tracks. The agent clones the remote repository, so a local-only break fires the hook but the agent finds healthy code and has nothing to fix.
- Dagster event log: right after
STEP_FAILUREyou’ll see the dispatch confirmation,Triggered DinoAI agent 'dagster-pipeline-healer' … Result: ok=True agent_session_id='…' status='queued' - Slack:
#dagster-dinoai-self-healingreceives the triage summary, then progress updates - GitHub: the fix PR appears a few minutes later, citing the exact error string
Each failed run produces exactly one PR that heals the pipeline, with every distinct error documented (the verbatim error string, the file changed, and the fix applied). Merge the PR to close the loop. If a session fails immediately with no messages, the API key likely belongs to the wrong workspace, because
trigger_run always runs the agent in the workspace that issued the key. A long-running dagster dev process keeps the environment variables it started with, so restart it after rotating or switching keys.How it works
The hook fires in-process the moment an op fails and dispatches the failure fire-and-forget: it returns immediately, so the Dagster run’s teardown is never blocked by the agent session. A typical healing run completes in 2 to 6 minutes from step failure to open PR. The agent posts a triage summary before touching any code, maps each error to its source file, then creates one branch and opens a single PR itemizing every distinct error.Next steps
Bolt pipeline healer
The same pattern driven by Bolt self-healing.
Pipeline incident commander
Multi-agent triage from Airflow failures.
Build an agent in the UI
Create this agent visually instead of by hand.
Programmable Agents reference
The agent YAML schema and tools.