get_model_performance) and BigQuery’s INFORMATION_SCHEMA.JOBS, so there is no trigger script or artifact parsing to maintain: one agent, one Bolt schedule.
Prerequisites
- Slack connected (the agent posts the PR link and cost summary to
#finops). - An active BigQuery connection with permission to read job metadata (the agent calls
get_bigquery_query_performance_statsand queriesINFORMATION_SCHEMA.JOBS). - Bolt runs producing dbt™ artifacts, which power the dbt Discovery tools the agent uses to rank models by run time.
- Familiarity with programmable agents and running an agent with Bolt.
Steps
1
Create the agent
In the Agent app, open Agents, select New agent, and start from the Goal:Backstory:Model: leave Auto selected.Allowed tools (everything else is refused, see the Tools Reference):
warehouse-cost-optimizer template (or Start from scratch). Fill in the builder fields with the content below. See Build an agent in the UI for a tour of the builder.Name: bigquery-query-optimizerRole:get_model_performance,get_all_models,get_lineage,get_node_detailsget_bigquery_query_performance_statsrun_sql_queryread_file,write_file,search_files_and_directories,ripgrep_searchrun_terminal_commandpost_slack_message
#finops (or wherever your team routes cost alerts, updating the channel in the Goal to match).2
Deploy the agent
Select Deploy and choose where the agent lives: Just here saves it to the workspace and makes it live immediately, Open a pull request commits it to your repo as
.dinoai/agents/bigquery-query-optimizer.yml so it is governed as code. Both appear in the Bolt agent picker. See Creating Agents in the App.3
Run it from Bolt
On the Agents page, hover the agent card and select Schedule. This opens a new Bolt schedule with the Run Paradime DinoAI Agent command already added and the agent pre-selected. The command runs natively, so no API keys or environment variables are needed. Set the Task:A sensible cadence is weekdays at 8 AM (
0 8 * * 1-5), after overnight production models complete so the latest run data is available. See Run an agent with Bolt for the full walkthrough.On a run with costly models, the agent opens a PR titled
perf: optimise BigQuery cost — <models> and posts a cost summary with the PR link to #finops. When nothing exceeds the 10 GB threshold, it says so and exits cleanly, so scheduling it daily costs nothing on quiet days. If no PR appears, check the run transcript in the agent sessions panel: the most common cause is missing INFORMATION_SCHEMA.JOBS permissions on the BigQuery connection.How it works
The agent works through five phases in one session: it ranks models by recent execution time withget_model_performance (backed by your Bolt runs’ dbt™ artifacts), resolves each model’s recent job ID and bytes processed from INFORMATION_SCHEMA.JOBS, pulls the full query plan with get_bigquery_query_performance_stats, checks downstream usage with get_lineage, then rewrites the model files, opens the PR, and posts the summary. BigQuery is ranked by bytes processed because that is the direct driver of on-demand query cost. Anti-patterns it detects and fixes:
Prefer to pick the targets yourself? Pass BigQuery job IDs directly in the Bolt Task message (“Optimise these job IDs: …”) and the agent skips Phase 1 discovery. To orchestrate the run from outside Paradime (Airflow, a webhook), trigger it through the API with
triggerDinoaiAgentRun; see the API and SDK reference.Next steps
Query cost optimizer (Snowflake)
The same recipe for Snowflake, filtered by execution time and credits.
Run an agent with Bolt
Cron, run-on-merge, and Turbo CI triggers for this agent.
dbt Discovery tools
The model performance and lineage tools this agent uses.
Programmable Agents reference
The agent schema, tools, and API.