Skip to main content
The MongoDB schema drift healer is a DinoAI agent for pipelines that land MongoDB collections in Snowflake (via Airbyte or similar) and flatten them with dbt™ staging models. When a document’s shape drifts, a renamed field, a flat value moved into a nested object, a type change, the staging model starts returning NULLs or failing outright. This agent inspects the raw VARIANT column to discover the new shape, patches the model with COALESCE-style fallbacks so both old and new documents keep working, and opens a PR with a full drift report.
Prerequisites
  • A Snowflake connection with read access to the raw landed collections (the agent samples the _AIRBYTE_DATA VARIANT column via run_sql_query).
  • A MongoDB connection (optional but recommended: lets the agent verify the drift against the source collection, not just the landed copy).
  • Slack connected if you trigger it through Bolt self-healing (the healing session threads into the configured channel).
  • Familiarity with programmable agents and Bolt self-healing.
Estimated time: 20 minutes.

Steps

1

Create the agent

In the Agent app, open Agents, select New agent, and choose Start from scratch. Fill in the builder fields below, leave Model on Auto, then select Deploy and choose Open a pull request: self-healing selects agents from .dinoai/agents/*.yml on the schedule’s git branch, so the definition must be merged there. See Build an agent in the UI for a tour of the builder.Name: mongo-dbt-healerRole:
Goal:
Backstory:
Allowed tools (everything else is refused, see the Tools Reference):
  • read_file, write_file, replace_in_file, search_files_and_directories, ripgrep_search
  • run_sql_query
  • run_terminal_command
  • list_bolt_schedules, get_bolt_run_logs
  • list_mongodb_collections, mongodb_collection_schema, mongodb_count, mongodb_aggregate, mongodb_find
The MongoDB tools are all read-only. They let the agent confirm the drift at the source (is the rename real in Mongo, or an ingestion artifact?) before patching the model. No Slack tool is needed when triggered by self-healing, because the healing session already threads into the configured channel.
2

Enable self-healing on the schedule

Point the Bolt schedule that runs your MongoDB staging models at this agent, from the UI or as YAML. See Set up self-healing for the walkthrough:
paradime_schedules.yml
self_healing.slack_channel must also appear in this schedule’s notifications.slack_channels, or the deployer rejects it. The agent threads into the existing failure notification, so that notification has to exist.
3

Watch the first heal

The next time a MongoDB shape change breaks the schedule, open the failure thread in your self-healing channel. You’ll see the session parse the error, sample the raw VARIANT data (recent vs oldest rows), post the drift report, and link the fix PR.
On a drift failure, the agent opens one PR on a heal/mongo-drift/<collection>-<yyyymmdd> branch containing the COALESCE-patched staging model, updated YAML, and a drift report quoting the original error, per-column change types, v1/v2 document counts, and before/after JSON samples. Both old and new documents produce non-null rows after the patch. Review the drift report, merge, and retry the Bolt run.

How it works

Schema drift in a document store rarely arrives as a clean cutover: for days or weeks the landed table contains a mix of v1 and v2 documents. That is why the agent’s core rule is additive patching: every changed field becomes a COALESCE(old_path, new_path) so the model works across the transition, and downstream column names never change even when the underlying path did. The count split in the drift report (how many rows match each shape) tells the reviewer when it will be safe to remove the v1 fallback later.

Next steps

Bolt pipeline healer

The general-purpose healer for failed dbt™ runs.

MongoDB schema drift triager

The Jira-driven variant: planned drift changes as tickets.

Set up self-healing

Enable self-healing on a Bolt schedule.

MongoDB tools reference

The read-only MongoDB tools this agent uses.