← All articles

Building an AI Agent That Fixes Data Pipeline Failures Without Paging an Engineer

KashEdge AI · Updated · 7 min read

Most pipeline alerts that wake engineers up are not new problems. They are the same handful of failures with the same well-known fixes, applied by a tired person at 3am. For a US delivery-tech company we built a multi-agent system that handles those failures itself. This article explains what it does, how it is put together and the guardrails that make it safe to let an agent touch production.

The problem: repeat failures with known fixes

The client runs its data pipelines on Dagster, with PostgreSQL logical replication (change data capture) feeding downstream systems. Two failure types kept paging the on-call engineer: jobs dying from out-of-memory errors, and PostgreSQL replication slots getting stuck. Both had runbooks. Neither needed human judgement most of the time, just someone to follow the steps.

What the agent does

  • Watches Dagster for failed runs and replication alerts.

  • Uses an LLM to read the failure logs and decide which known failure it is looking at.

  • For an out-of-memory failure: scales up the job’s compute and restarts it.

  • For a stuck replication slot: stops the affected job, removes the stuck slot and starts a partial refresh of the affected data.

  • Records every action so the team can see what the agent did, in Grafana.

Why an LLM, and where it stops

Failure logs are messy. The same out-of-memory error can surface as a killed container, a Python MemoryError or a bare non-zero exit code, depending on where it happened. Writing regex rules for every variant is brittle. An LLM is good at reading a stack trace and saying which known category it belongs to.

The important design choice is that the LLM chooses, it does not improvise. Each remediation is ordinary, tested code with fixed steps and limits. The model picks which runbook applies; it never writes shell commands or SQL on the fly. If the failure does not match a known category with confidence, the agent hands it to a human like any normal alert.

How the system is structured

We built it as a multi-agent graph in LangGraph. LangGraph models the workflow as explicit steps and transitions, which suits operations work: you can see exactly which path an incident took, retry a step, and add a human-approval step where needed.

  • Monitoring: picks up failed runs and alerts from Dagster.

  • Triage: the LLM reads the logs and run metadata and classifies the failure.

  • Remediation: one tool per known failure type, each a deterministic runbook.

  • Reporting: writes what happened and why to the dashboards the team already uses.

The replication-slot fix, explained

A PostgreSQL logical replication slot keeps write-ahead log (WAL) on the database until the consumer confirms it has read it. If the CDC consumer stalls, the slot stops advancing and WAL piles up, which can fill the database disk. Restarting the consumer is not always enough when the slot itself is stuck.

The fix is to stop the consuming job, drop the stuck slot, recreate it, and then re-sync the data that changed in the meantime, because dropping a slot discards the changes it was holding. That last step is why the agent starts a partial refresh rather than simply restarting: it puts the warehouse back in a consistent state without a full reload.

Guardrails we recommend for any ops agent

  • Allowlist actions: the agent can only call the remediation tools you give it.

  • Hard limits in code: maximum compute size, maximum retries per job, cool-down periods.

  • Escalate anything unknown or low-confidence to a person, with the agent’s diagnosis attached.

  • Log every decision and action where the team already looks, such as Grafana or Slack.

  • Start in suggest-only mode, compare its decisions with what the on-call engineer did, then switch on automatic fixes one failure type at a time.

Where to start in your own stack

Pull the last few months of on-call incidents and count them by cause. The top two or three repeat failures with written runbooks are your first candidates. The pattern works with Airflow, Dagster or Prefect, since all three expose run status and logs through APIs or failure hooks.

Frequently asked questions

Is it safe to let an AI agent fix production data pipelines?

It is when the LLM only classifies the failure and the fixes are fixed, tested code with hard limits. Unknown or low-confidence failures should still go to a human, and every action should be logged.

Does this work with Airflow instead of Dagster?

Yes. The agent needs run status, logs and a way to trigger actions. Airflow provides these through failure callbacks and its REST API, as do Dagster and Prefect.

Why use LangGraph for an operations agent?

LangGraph makes the workflow explicit: each step and transition is defined, so you can trace what the agent did, retry steps and insert human approval. That predictability matters more in operations than open-ended agent behaviour.

Related

Planning a data or AI project?

Tell us what you are building and we'll give you a straight answer on approach, effort and cost.

Start a Project