Best Architecture for Building a Custom Agent in Databricks?

Vamsi3757
New Contributor III

Hi Everyone,

I'm building a Databricks cost optimization agent and would appreciate some guidance on the recommended architecture.

My current design consists of the following functions:

  1. Retrieve the last N job runs along with cost, DBU usage, runtime, cluster configuration, and worker information.
  2. Read and analyze Spark event logs from Compute Log Delivery stored in a Unity Catalog Volume.
  3. Combine historical run metrics and Spark event metrics into a consolidated dataset for analysis.

My goal is for a user to ask questions such as:

"Analyze job_id <job_id> and recommend cost optimizations."

The agent would analyze up to the last 50 runs (or however many runs have logs available), evaluate cost, utilization, shuffle, spills, executor usage, memory, etc., and then generate optimization recommendations.

My functions are currently implemented as Python functions and are not Unity Catalog Functions. Given this use case:

  • Is it better to build this using Agent Framework (Code Your Own Agent)?
  • Should I convert some or all of these functions into UC Functions?
  • Would a Genie Space, Agent Framework, or Databricks Apps be the recommended architecture for this type of cost optimization agent?

I'm interested in understanding Databricks best practices for building an agent that needs to orchestrate Python logic, inspect Spark event logs, and generate recommendations using an LLM.

Thanks in advance for any recommendations or design suggestions.