Advanced Topics
What is Agent Bricks and why would you use it?
- Agent Bricks is Databricks tooling for developing and operating agents with governed data, tools, evaluation, tracing and deployment. Its goal is to reduce the engineering effort between a proof of concept and a reliable application.
- Enterprise challenges include domain-specific accuracy, limited labeled examples, hallucinations, data permissions, latency, cost, evaluation and ongoing monitoring.
- The high-level approach is to define a task and data sources, generate or assemble an agent, test it against representative questions, refine it with feedback, then deploy and monitor it.
- Automated evaluation and optimization can accelerate development, but do not guarantee correctness. Human review, access controls and realistic test cases remain essential.
- Important 2026 product update: Course materials describe four Agent Bricks templates. Some are now legacy: Databricks recommends Genie Agents for new low-code knowledge and multi-agent experiences, and the Agent Bricks CLI for new code-based agents. Verify workspace availability before following older UI screenshots.
Which Agent Bricks use cases should you understand?
- Information Extraction: Turn unstructured documents, text or images into structured fields, such as invoice line items or contract dates. Define a schema, inspect extracted values and evaluate against known examples. A newer Information Extraction experience is available.
- Knowledge Assistant (legacy): Answer questions grounded in enterprise documents, ideally with citations. For new low-code implementations, consult Genie Agents; a conventional RAG system remains an alternative when you need more control.
- Multi-Agent Supervisor (legacy): Route complex requests to specialist agents or tools and combine results. Newer recommendations are Genie Agents for low-code orchestration or a custom agent built with the Agent Bricks CLI.
- Custom LLM (legacy): Optimize a domain-specific text task such as classification, summarization or rewriting. For new implementations, Databricks recommends AI Functions, including
ai_query, for many such tasks. - Choose based on the output: structured fields → extraction; grounded answers → knowledge/RAG; coordinated tasks → multi-agent; repeatable text transformation → AI Functions/custom model.
How do you plan a production-quality agent?
- Define a narrow business task, users, acceptable data, expected output format and measurable success criteria before choosing tools.
- Assemble a representative evaluation dataset containing ordinary, ambiguous, out-of-scope, adversarial and permission-sensitive requests.
- Assess quality (correctness, faithfulness, citation usefulness), operations (latency, failure rate, throughput), cost (tokens, retrieval and serving) and safety (data leakage, prompt injection, unsafe actions).
- Use MLflow tracing to inspect retrieval, model calls, tool inputs/outputs and timing. Use human feedback and automated scorers to compare revisions.
- Govern source tables, vector indexes, registered models and tools through Unity Catalog where supported. Apply least-privilege permissions and review the effective identity used by serving endpoints.
- Test again after changing prompts, embeddings, chunking, retrieval parameters, model versions or tools; a good prototype result is not a production guarantee.
How do you prepare a Delta table for a RAG Vector Search index?
- A typical RAG workflow is source documents → clean/chunk text → Delta table → embedding/index → similarity retrieval → prompt context → LLM answer.
- Use the course catalog and schema,
dbacademy.get_started_genai, if they were created during the earlier setup lesson. - Each indexed row needs a unique, stable primary key and searchable text. For long documents, index appropriately sized chunks rather than an entire document in one row.
- For a standard Delta Sync index, enable Delta Change Data Feed (CDF) on the source table so changes can be synchronized.
CREATE TABLE IF NOT EXISTS dbacademy.get_started_genai.product_text (
product_id STRING,
product_text STRING
) USING DELTA;
ALTER TABLE dbacademy.get_started_genai.product_text
SET TBLPROPERTIES (delta.enableChangeDataFeed = true);
-- Inspect data and confirm the IDs are unique before indexing:
SELECT COUNT(*) AS rows, COUNT(DISTINCT product_id) AS unique_ids
FROM dbacademy.get_started_genai.product_text;- Important: Creating the empty table is only a schema example; populate it from the course’s product dataset before building an index. Do not assume
product_idandproduct_textare the actual source column names without inspecting the lab notebook. - Check the source with
DESCRIBE TABLEandSELECT * ... LIMIT 10; make sure text is not null and identifiers do not collide.
How do you create, synchronize and test a Vector Search index?
- Vector Search, now also documented as AI Search, stores searchable representations of text plus metadata. A Delta Sync Index tracks a Delta source table; a Direct Vector Access Index is maintained through API/SDK writes.
- In the UI, open Catalog Explorer → source Delta table → Create → Vector search index; select the endpoint, unique key, text/embedding column, embedding model and sync mode.
- Managed embeddings: Databricks converts a text column to vectors using the chosen embedding model. Self-managed embeddings: your source table already contains vectors of the required dimension.
- Triggered sync updates only when explicitly run or scheduled; it is not continuous. Other sync options depend on endpoint/index type and availability.
- Python SDK example for a standard endpoint with managed embeddings (names/model must be supported in your workspace):
from databricks.vector_search.client import VectorSearchClient
vsc = VectorSearchClient()
endpoint = "course-vector-search"
source = "dbacademy.get_started_genai.product_text"
index_name = "dbacademy.get_started_genai.product_embeddings"
# Create the endpoint only if one is not already provisioned.
# vsc.create_endpoint(name=endpoint, endpoint_type="STANDARD")
index = vsc.create_delta_sync_index(
endpoint_name=endpoint,
source_table_name=source,
index_name=index_name,
pipeline_type="TRIGGERED",
primary_key="product_id",
embedding_source_column="product_text",
embedding_model_endpoint_name="databricks-gte-large-en"
)- The embedding endpoint in the example is course-specific; check availability and replace it if unsupported. If setup already created
product_embeddings, reuse it rather than creating a duplicate. - Wait until the endpoint and index are ready, then retrieve and test:
index = vsc.get_index(endpoint_name=endpoint, index_name=index_name)
print(index.describe())
index.sync() # Triggered indexes: sync after source changes.
results = index.similarity_search(
query_text="wireless headphones",
columns=["product_id", "product_text"],
num_results=5
)
print(results)- Check that results are relevant and the expected text is returned. Retrieval quality depends on source quality, chunk size, embedding model and search settings.
- Provisioning may take 10–20 minutes or longer. Free Edition endpoint quotas and region restrictions can prevent creation; inspect existing resources first.
How do you assemble and test a basic RAG application?
- Retrieve: Search the index using the user’s question; extract text from the returned result rows.
- Augment: Insert only relevant retrieved passages into the model prompt, ideally with source identifiers.
- Generate: Ask the LLM to answer from those passages and to state when evidence is insufficient.
- Validate: Test questions whose answers are known, unrelated questions, and questions with conflicting or missing evidence.
- Conceptual application logic:
def answer_question(question):
hits = index.similarity_search(
query_text=question,
columns=["product_id", "product_text"],
num_results=5
)
passages = extract_text_and_ids(hits) # Implement for the SDK response format.
prompt = (
"Answer only from the context. Cite product IDs. "
"If the context is insufficient, say so.\n"
f"Context:\n{passages}\nQuestion: {question}"
)
return call_serving_model(prompt) # Implement with an available model endpoint.- This is pseudocode, not a runnable LangChain chain:
extract_text_and_idsandcall_serving_modelare intentionally placeholders because endpoint names and return schemas vary. - A prompt instruction alone cannot eliminate hallucinations. Inspect retrieved documents and generated answers; apply evaluation before deploying.
How do you log, register and deploy the RAG model?
- Package the complete retrieval-plus-generation application using a supported MLflow flavor or agent interface, including its dependencies and configuration.
- Log it to an MLflow experiment, test inference locally, and register it under a three-part Unity Catalog model name, for example
dbacademy.get_started_genai.product_rag_model. - The exact
mlflow.*.log_modelcall depends on whether the course uses LangChain,pyfunc, or an agent interface; use the corresponding notebook implementation rather than mixing their APIs. - Register the model version in Unity Catalog and check its signature, dependencies, artifacts and access permissions.
- Deploy through Serving → Create serving endpoint or the relevant Agent Framework deployment workflow, selecting the registered model version and workload configuration.
- Do not create a second endpoint if the setup notebook already deployed one. Free Edition may require Scale to zero, which reduces idle usage but adds a cold-start delay.
- Test the endpoint with a known question using its Query UI or API. Where supported, use SQL:
-- Replace with your actual deployed endpoint and supported request format.
SELECT ai_query(
'YOUR_SERVING_ENDPOINT',
'What products support wireless connectivity?'
) AS response;- Some agent endpoints require a structured request rather than a plain string; inspect the endpoint’s input schema and adapt
ai_queryaccordingly. - Review traces, latency, cost, retrieval evidence, and errors. Set permissions and usage controls before allowing other users to query the endpoint.
What should you do when the lab fails?
- Environment/dependencies: Use the course-specified serverless environment (Environment 4 where available), install notebook packages, and restart Python when instructed.
- Catalog or schema not found: Run setup first; verify
dbacademy.get_started_genaiexists and you have the required privileges. - CDF/index errors: Check that the source is a Delta table, CDF is enabled for a standard index, the key is unique, and the configured text/embedding column exists.
- Index not ready: Wait for provisioning and initial sync; inspect the index status before issuing similarity searches.
- Wrong embedding configuration: Match managed versus self-managed embeddings; for self-managed vectors, specify the correct vector column and dimension.
- Endpoint quota: Inspect Compute → Vector Search / AI Search and Serving. Reuse resources where possible; delete only resources you no longer need, since deletion can disrupt other labs.
- Model deployment errors: Check MLflow model dependencies, inference signature, Unity Catalog permissions, serving logs and whether external resources are accessible from the endpoint.
- Poor answers: Inspect retrieval results first, then prompt construction and generation. Add relevant examples to the evaluation dataset before adjusting the model.