What you will be able to do
- Choose an authoring framework once the agent pattern is fixed, knowing Databricks Agent Framework accepts LangChain, LangGraph, OpenAI, LlamaIndex or DSPy code
- Decide when DSPy's declarative, optimizable modules should replace hand-written prompt strings
- Give a LangChain agent tools of the right type: a local @tool function, a governed Unity Catalog function through UCFunctionToolkit, or a VectorSearchRetrieverTool over an AI Search index
- Add Genie and MCP servers as tools to a LangChain agent, and trace the whole app with mlflow.langchain.autolog()
Key concept
Framework-specific tool wrappers — Each Databricks capability (Unity Catalog functions, AI Search indexes, Genie, MCP servers) comes with a ready-made adapter for each major framework, mostly in databricks-langchain or the unitycatalog-* packages. Picking a tool for a LangChain agent means picking the right wrapper, not writing the logic again.
1.Pick the pattern first, then the framework
You can build a generative AI application in many libraries: LangChain, LangGraph, the OpenAI SDK, LlamaIndex, DSPy. Picking one too early ties you to a structure before you know what the application needs. The order that works is to decide the pattern first. That means a deterministic chain, a single tool-calling agent, or a multi-agent supervisor, as covered in Deterministic chain vs single agent vs multi-agent supervisor. The pattern then tells you which framework features matter. A fixed retrieve-augment-generate chain needs little more than a prompt template and a model client. A tool-calling agent needs a tool-binding API and a loop that stops.
On Databricks, the framework decision is less of a commitment than it looks. Custom agents can be written with any authoring library, and they get the same deployment, evaluation and MLflow Tracing integration whichever library you use. Custom Agents also don't care which pattern you choose. A team can ship a deterministic chain now and add tool calling later without moving to a different platform path.
The tools don't lock you in either. The same Unity Catalog function can be handed to a LangGraph, OpenAI, Anthropic or LlamaIndex agent, and each framework installs its own small adapter package. So choose a framework for its authoring style and the features your pattern needs, such as LangGraph's prebuilt create_react_agent for a tool-calling loop. Don't choose it because you think only one framework can reach your data.
| Framework | Installation command |
|---|---|
| LangGraph | %pip install --upgrade unitycatalog-langchain[databricks] databricks-langchain langgraph |
| OpenAI | %pip install --upgrade unitycatalog-openai[databricks] |
| Anthropic | %pip install --upgrade unitycatalog-anthropic[databricks] |
| LlamaIndex | %pip install --upgrade unitycatalog-llamaindex[databricks] llama-index-llms-openai |
Whatever framework you pick, give the agent only the tools it needs. An agent handed an unbounded set of APIs, or a pile of irrelevant context, has more chances to call the wrong tool and to hallucinate. Decide on your tool approach during design, alongside the pattern.
Checkpoint 1 of 8· Check yourself
A team is building a tool-calling agent on Databricks. Their engineers know LlamaIndex well, and they want the agent deployed, evaluated and traced with MLflow like the platform's other agents. Which statement is correct?
Custom agents on Databricks can be written with any authoring library, including LlamaIndex, and they get the same deployment and MLflow Tracing integration. Unity Catalog functions also have a LlamaIndex adapter (unitycatalog-llamaindex), so the framework is an authoring choice, not a platform requirement.
“Supports agents written with any authoring library, including LangGraph, LangChain, OpenAI, and LlamaIndex. Integrated with MLflow Tracing.”Source: docs.databricks.com
2.When DSPy beats hand-written prompts
DSPy takes a different approach from LangChain-style prompt templates. You don't write and tweak a prompt string. You declare what each step should do, and an optimizer works out how to prompt the model to do it well. DSPy can automate prompt engineering, and it can also orchestrate LLM fine-tuning.
DSPy is built from four parts:
- Signatures state a step's input and output in natural language, for example
question -> answer. - Modules carry out one text transformation, such as answering or summarizing. They replace hand-written prompts and can learn from examples.
- Programs connect modules into a pipeline.
- The compiler tunes a program's modules to meet a performance metric, either by generating better prompts or by fine-tuning the model.
That design tells you when DSPy wins. Reach for it when you can measure quality with a metric and have examples to learn from, and when hand-tuning prompts has turned into a cycle of small edits that fix one case and break another. Recompiling against the metric replaces that guesswork. It also helps when you change the underlying model, because the prompts are generated, not handcrafted for one model's quirks. A quick prototype with no evaluation data gains little from DSPy, because the compiler has nothing to optimize against.
You don't have to start over to adopt DSPy. Databricks publishes example notebooks that migrate existing LangChain model code to DSPy and then optimize it. DSPy programs can also act as agents in larger systems, for example as UC function-calling agents under a multi-agent orchestrator.
Checkpoint 2 of 8· Check yourself
Which of these projects would gain the most from moving to DSPy instead of continuing to hand-tune prompt templates?
DSPy's compiler tunes modules against a performance metric using examples, so it pays off when you can measure quality and hand-tuning has become trial and error. Without a metric or evaluation data, the compiler has nothing to optimize against. Fixed, hand-approved prompt wording also doesn't fit, because DSPy generates its prompts.
“It improves LM pipelines by adjusting modules to meet a performance metric, either by generating better prompts or fine-tuning models.”Source: docs.databricks.com
Sources3
3.Governed Unity Catalog function tools
A Unity Catalog function is the right tool when the agent has to run predefined logic: a lookup, a calculation, or a SQL query whose parameters the agent fills in. The logic sits in Unity Catalog, and Unity Catalog grants control it. To call a function, a user needs USE CATALOG and USE SCHEMA on its parent catalog and schema, plus EXECUTE on the function itself. Because the function is registered once, every agent and every framework that calls it reuses the same governed code.
For LangChain and LangGraph, the wrapper is UCFunctionToolkit, imported from the databricks-langchain package. Pass it the functions' full three-part names. Its .tools property then returns LangChain-compatible tools that call the registered functions directly, which you hand to the agent with everything else. databricks-sdk is a different package: it supplies the WorkspaceClient for general workspace calls, and it doesn't turn UC functions into LangChain tools.
from databricks_langchain import ChatDatabricks, UCFunctionToolkit
from langgraph.prebuilt import create_react_agent
toolkit = UCFunctionToolkit(function_names=[function_name], client=client)
agent = create_react_agent(
ChatDatabricks(endpoint="databricks-claude-sonnet-4-5"),
tools=toolkit.tools,
)Serverless compute is a common setup failure: a workspace with only a SQL warehouse can register functions but can't run them through the Function Client. The other common mistake is a design one. Suppose a team copies the body of a governed inventory-lookup function into a local @tool function because it seems quicker. The agent now runs code that no Unity Catalog grant protects, and two copies of the logic will drift apart. If the function already exists in Unity Catalog, wrap it. Don't re-implement it, publish it as an HTTP endpoint, or export its results to a table on a schedule.
Checkpoint 3 of 8· Check yourself
An inventory-lookup function is already registered in Unity Catalog, and only users with EXECUTE on it may run it. You are giving a LangGraph agent the same lookup capability. Which approach keeps the logic governed?
UCFunctionToolkit returns LangChain tools that call the registered function directly, so USE CATALOG, USE SCHEMA and EXECUTE still apply and every agent reuses one copy of the logic. A local @tool copy runs outside Unity Catalog grants and will drift from the original. databricks-sdk supplies WorkspaceClient and doesn't turn UC functions into LangChain tools.
“Tool support includes MCP servers and Unity Catalog Functions, both of which provide Unity Catalog-based governance.”Source: docs.databricks.com
Checkpoint 4 of 8· Exam question
Which Python package provides purpose-built LangChain tool wrappers for Unity Catalog functions, letting a governed UC function be surfaced directly as a LangChain-compatible tool for an agent?
Correct answer: A — databricks-langchain
- A. This package provides the LangChain integrations, including a toolkit that wraps Unity Catalog functions so they can be passed directly into a LangChain agent's tool list.
- B. This package is a client for running Spark workloads against a remote Databricks cluster from a local environment; it has nothing to do with wrapping UC functions as LangChain tools.
- C. This package is a general-purpose REST API client for managing Databricks workspace resources such as clusters and jobs, not a LangChain tool integration library.
- D. This package is used for managing feature tables and feature lookups in the Feature Store, which is unrelated to exposing UC functions as LangChain tools.
Checkpoint 5 of 8· Exam question
A team has already registered a Python function in Unity Catalog that looks up current inventory levels by SKU, and access to it is controlled through Unity Catalog grants. They want a LangChain agent to call this exact governed function as a tool, without re-implementing the lookup logic or bypassing UC access control. Which approach should they use?
Correct answer: A — Load the function through UCFunctionToolkit(function_names=["catalog.schema.inventory_lookup"]) and hand the resulting tools to the agent, so calls execute inside Unity Catalog.
- A.
UCFunctionToolkitturns a registered Unity Catalog function into LangChain tools. The agent then invokes the existing function itself, so there is no rewrite and execution stays in Unity Catalog under its grants. - B. A new
@toolthat queries the table re-implements the lookup in fresh code instead of calling the registered function. Access then depends on table grants, not the grants on the function the team already controls. - C. An endpoint with custom Python code is a second implementation of the lookup, so the agent never calls the registered function. Access is decided by endpoint permissions rather than Unity Catalog grants on that function.
- D. The agent would query precomputed results, not call the registered function. Those results go stale between scheduled runs, which breaks the need for current inventory levels, and access is governed by table grants instead of the function's.
4.Retriever tools over an AI Search index
Unstructured knowledge such as manuals, tickets or policies reaches an agent through a retriever tool over a vector index. On Databricks that index lives in AI Search, which was formerly called Vector Search, so exam questions may use either name. When the index already exists, the agent needs a tool that queries it, not a new retrieval system.
VectorSearchRetrieverTool is part of Databricks AI Bridge and ships in databricks-langchain. Point it at the index's three-part name and give it a tool_name and a tool_description. The model reads the description to decide when to search, so write it as an instruction ("Search Databricks documentation to answer product questions"), not as a label.
from databricks_langchain import VectorSearchRetrieverTool, ChatDatabricks
from langgraph.prebuilt import create_react_agent
vs_tool = VectorSearchRetrieverTool(
index_name="catalog.schema.my_databricks_docs_index",
tool_name="databricks_docs_retriever",
tool_description="Search Databricks documentation to answer product questions.",
)That minimal form works for an index with Databricks managed embeddings. A direct-access index, or a Delta Sync index with self-managed embeddings, also needs text_column and an embedding model, for example DatabricksEmbeddings. The tool also accepts num_results, columns, filters and query_type (ANN or HYBRID) to shape what comes back.
The older route is a SQL table function that wraps vector_search(), registered in Unity Catalog and loaded with UCFunctionToolkit. It is governed, discoverable, and automatically produces RETRIEVER spans in MLflow traces. Keep it for existing integrations rather than new agents. It also has two catches. SQL clients can truncate large rows, so long chunk columns need trimming with substring. And it inherits every limitation of vector_search().
Checkpoint 6 of 8· Fill the gap
The agent's model has to decide when to call this retriever. Which parameter carries the instruction it reads to make that decision?
from databricks_langchain import VectorSearchRetrieverTool, ChatDatabricks
from langgraph.prebuilt import create_react_agent
vs_tool = VectorSearchRetrieverTool(
index_name="catalog.schema.my_databricks_docs_index",
tool_name="databricks_docs_retriever",
? ="Search Databricks documentation to answer product questions.",
)The model reads tool_description to decide when to search, so it should be written as an instruction, not a label. text_column names the column to embed, and only direct-access or self-managed-embedding indexes need it. query_type selects ANN or HYBRID search, and filters limits which results come back.
Source: docs.databricks.comCheckpoint 7 of 8· Exam question
An engineering team already has a Mosaic AI Vector Search (AI Search) index over chunked support documents and wants to give a LangChain agent read-only access to that index as a callable retrieval tool, with minimal custom code and while keeping MLflow tracing on retrieval calls. Which option best satisfies this?
Correct answer: A — Instantiate VectorSearchRetrieverTool from databricks-langchain with the existing index name, then add it to the tools list the agent is built with.
- A.
VectorSearchRetrieverToolindatabricks-langchainis the purpose-built wrapper for querying an existing AI Search index as an agent tool. It is read-only and needs only a few lines of configuration. Its retrieval calls are traced by MLflow. - B.
UCFunctionToolkitcan expose a Unity Catalog function to an agent, but here the team would have to write and maintain a custom function that hand-builds REST requests to the index. That conflicts with the minimal-custom-code requirement, because a ready-made retriever tool already covers this case. - C. Copying the chunks into a Delta table and filtering them by keyword does not give the agent access to the existing index. It duplicates the data and drops vector similarity search. It also adds an export step that has to be kept in sync, which goes against the minimal-custom-code requirement.
- D. A local FAISS store with a hand-written retriever bypasses the AI Search index the team already built. It duplicates the embeddings and adds custom code to build and maintain. The existing index and the minimal-custom-code requirement both point to using the ready-made retriever tool instead.
Sources5
5.Local tools, Genie, MCP and tracing
The third tool type is a plain Python function decorated with LangChain's @tool. Choose it when the logic belongs to this one agent and needs no catalog governance, for example a helper that lists and reads files from a configured Unity Catalog volume. The function's docstring becomes the tool description the model sees. Because the code runs inside the agent, any safety checks are yours to write: the volume example rejects absolute paths and .. before it touches storage.
| Tool type | How you create it | Governance | Use when |
|---|---|---|---|
| Local Python function | @tool decorator from langchain_core.tools | Whatever the function's own code enforces | Agent-specific helper logic |
| Unity Catalog function | UCFunctionToolkit with three-part function names | Unity Catalog grants (EXECUTE) | Predefined logic to share across agents and frameworks |
| Retriever | VectorSearchRetrieverTool on an AI Search index | Access to the index's Unity Catalog securable | Searching unstructured documents |
For structured data, a Genie Agent answers natural-language questions about tables (see Genie as a subagent in multi-agent systems). In LangChain, you make it one more tool: wrap a GenieAgent from databricks_langchain.genie in an @tool function. The agent can then choose between the retriever for documents, a UC function for fixed logic, and Genie for questions about tables.
@tool
def ask_genie(question: str) -> str:
"""Ask the configured Genie Agent a question about its business data."""
response = genie.invoke({
"messages": [{"role": "user", "content": question}]
})
return response["messages"][-1].contentMCP gives tools to LangChain without tying them to any one framework. A managed MCP server exposes its tools once, and any framework can use them. In LangChain, DatabricksMultiServerMCPClient takes one or more DatabricksMCPServer URLs, and await mcp_client.get_tools() returns tools you pass to create_react_agent. The same client works for managed, external and custom servers. For anything that isn't predefined UC logic, Databricks recommends starting with MCPs.
Once the tools are wired up, a single call traces the whole app. mlflow.langchain.autolog() records LLM calls, tool usage and agent steps without any change to the chain or agent code, and LangGraph apps use the same call (see MLflow Tracing (autolog and spans)). On serverless compute it is not switched on for you, so put the call in the agent code explicitly.
Checkpoint 8 of 8· Match them up
An agent needs five capabilities. Match each LangChain tool approach to the job it suits best.
Tap a term, then the definition that fits it.
Local @tool functions suit logic that belongs to one agent and needs no catalog governance. UC functions hold shared predefined logic under Unity Catalog grants, retrievers search documents, and Genie handles questions about tables. One Databricks MCP client loads tools from managed, external and custom servers alike, and Databricks recommends starting with MCPs for anything that isn't predefined UC logic.
“Use Unity Catalog functions when your agent needs to run predefined logic, such as a SQL query whose parameters the agent supplies.”Source: docs.databricks.com
Practise it for real
Register a Unity Catalog Python function, give it to a LangGraph agent with UCFunctionToolkit, and trace the run.
1.In a Databricks notebook with serverless compute enabled, run %pip install --upgrade unitycatalog-langchain[databricks] databricks-langchain langgraph, then dbutils.library.restartPython() in a separate cell.
Why: The LangChain wrapper for UC functions ships in databricks-langchain, and the Function Client runs tools on serverless general compute.
You should see: The packages install and Python restarts without errors.
2.Use DatabricksFunctionClient().create_python_function to register add_numbers in a catalog and schema where you hold CREATE FUNCTION, then call execute_function on it with number_1=2.0 and number_2=3.0.
Why: Testing the function on its own first separates registration or permission problems from agent problems.
You should see: result.value prints 5.0.
3.Call mlflow.langchain.autolog(), build UCFunctionToolkit(function_names=[function_name], client=client), and pass toolkit.tools to create_react_agent with ChatDatabricks.
Why: Autolog has to be switched on explicitly on serverless, and the toolkit makes the governed function available as a LangChain tool.
You should see: The agent is created without errors.
4.Invoke the agent with "Use the tool to add 2.0 and 3.0." and open the trace in the MLflow UI.
Why: The trace shows whether the model actually called the UC tool or answered from memory.
You should see: The answer contains 5, and the trace shows the LLM call followed by a tool call to add_numbers.
Stuck? Get a nudge
If the tool call fails with a permission error, check that the calling identity has EXECUTE on the function and USE CATALOG / USE SCHEMA on its parents.
Sources
(8)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“Supports agents written with any authoring library, including LangGraph, LangChain, OpenAI, and LlamaIndex.”
↩︎ Pick the pattern first, then the framework“Supports agents written with any authoring library, including LangGraph, LangChain, OpenAI, and LlamaIndex.”
↩︎ Exam trap 1“Supports agents written with any authoring library, including LangGraph, LangChain, OpenAI, and LlamaIndex. Integrated with MLflow Tracing.”
↩︎ Checkpoint - 2.
“Custom Agents are agnostic to these design patterns, so you can start simple and evolve toward higher levels of automation and autonomy”
↩︎ Pick the pattern first, then the framework“Provide only the tools and context your agent requires, rather than an unbounded set of APIs or large irrelevant context.”
↩︎ Pick the pattern first, then the framework - 3.https://docs.databricks.com/aws/en/agents/dspyOfficial docs
“DSPy can automate prompt engineering and orchestrate LLM fine-tuning to improve performance.”
↩︎ When DSPy beats hand-written prompts“They replace traditional hand-written prompts and can learn from examples, making them more adaptable.”
↩︎ When DSPy beats hand-written prompts“It improves LM pipelines by adjusting modules to meet a performance metric, either by generating better prompts or fine-tuning models.”
↩︎ When DSPy beats hand-written prompts“These notebooks show how to migrate LangChain model code to DSPy and optimize it for better performance.”
↩︎ When DSPy beats hand-written prompts - 4.
“Use Unity Catalog functions when your agent needs to run predefined logic, such as a SQL query whose parameters the agent supplies.”
↩︎ Governed Unity Catalog function tools“calling an existing function requires EXECUTE on it”
↩︎ Governed Unity Catalog function tools“Each uses UCFunctionToolkit to call the function directly.”
↩︎ Governed Unity Catalog function tools“For other tools, start with MCPs.”
↩︎ Local tools, Genie, MCP and tracing“add it to an agent using your choice of framework”
↩︎ Key concept“Each uses UCFunctionToolkit to call the function directly.”
↩︎ Exam trap 2“The Function Client uses serverless general compute to run tools; a SQL warehouse alone is not sufficient.”
↩︎ Prediction“Use Unity Catalog functions when your agent needs to run predefined logic, such as a SQL query whose parameters the agent supplies.”
↩︎ Checkpoint - 5.
“from databricks.sdk import WorkspaceClient”
↩︎ Governed Unity Catalog function tools“AI Search was formerly Vector Search.”
↩︎ Retriever tools over an AI Search index“Use VectorSearchRetrieverTool from databricks-langchain or databricks-openai to expose an index as an agent tool.”
↩︎ Retriever tools over an AI Search index“you must configure the VectorSearchRetrieverTool and specify a custom embedding model and text column”
↩︎ Retriever tools over an AI Search index“This enables automatic tracing through MLflow by automatically generating RETRIEVER span types in MLflow logs.”
↩︎ Retriever tools over an AI Search index“For new Python agents, use AI Bridge. The following example is a reference for existing integrations.”
↩︎ Retriever tools over an AI Search index“Bind the tools to an LLM and run a tool-calling loop:”
↩︎ Local tools, Genie, MCP and tracing“For new Python agents, use AI Bridge. The following example is a reference for existing integrations.”
↩︎ Exam trap 3 - 6.
“Genie agents can be used in multi-agent systems to answer natural language queries about your structured data.”
↩︎ Local tools, Genie, MCP and tracing“Tool support includes MCP servers and Unity Catalog Functions, both of which provide Unity Catalog-based governance.”
↩︎ Checkpoint - 7.
“The same client works for managed, external (MCP Service), and custom server URLs”
↩︎ Local tools, Genie, MCP and tracing“The same client works for managed, external (MCP Service), and custom server URLs”
↩︎ Exam trap 4 - 8.
“mlflow.langchain.autolog() # LangGraph uses LangChain's autolog”
↩︎ Local tools, Genie, MCP and tracing“On serverless compute clusters, autologging for genAI tracing frameworks is not automatically enabled.”
↩︎ Local tools, Genie, MCP and tracing