| 4.1 Code a chain using a pyfunc model with pre- and post-processing | A pyfunc model is MLflow's generic Python model wrapper. You write a class whose predict method runs your chain, so you can add steps before the model call (pre-processing) and after it (post-processing). | A chain must clean the user text before the model call and format the reply as a short JSON object afterward, and be served as one unit. | Write a class based on mlflow.pyfunc.PythonModel. The predict method is required and holds cleaning, the chain call and formatting. load_context loads extra files once at startup, and predict_stream supports streaming. Log it with MLflow so it can be registered and served. | Doing the cleaning in the client application means every client must repeat it and the served model behaves differently from the tested one. |
| 4.2 Control access to resources from model serving endpoints | A served agent calls other resources (a model endpoint, a search index, a function). You decide whose permissions it uses and declare which resources it needs. | A deployed agent must read a search index and call a model endpoint, and the platform team wants least privilege. | Declare the resources when logging the model, using resource classes such as DatabricksServingEndpoint, DatabricksVectorSearchIndex and DatabricksFunction. Databricks then provisions short-lived credentials for the endpoint's service principal limited to those resources. For per-user data access, use on-behalf-of-user authentication instead. | Embedding a personal access token in the code works, but ties access to one person and bypasses managed credentials. Runner-up wins when: On-behalf-of-user wins when each user must see only the data they are entitled to. |
| 4.3 Code a simple chain according to requirements | A simple chain is a short sequence of a prompt, a model call and a parser, built to match requirements such as the input and the output shape. | A requirement says: take a customer question, add a store policy snippet, call a chat model, and return plain text. | Build the chain in that order: a prompt template with a slot for the policy snippet, the chat model (ChatDatabricks), and a string output parser. Keep to the listed steps; extra parts the requirement did not ask for add risk. | Adding an agent loop or a retriever the requirement did not mention is over-building. |
| 4.4 Choose the basic elements needed to create a RAG application: model flavor, embedding model, retriever, dependencies, input examples, model signature | To package a retrieval app you need to choose and record: the model flavor (how MLflow saves it), the embedding model, the retriever, its Python dependencies, example inputs and the model signature that describes inputs and outputs. | A team logs a retrieval chain and gets an error on registration, because the model has no declared input and output format. | Add a signature, since new model versions in Unity Catalog must have one. Provide an input example, which lets MLflow infer it. List pip requirements so the serving environment can rebuild, and declare the retriever's index as a resource. | Skipping the signature to 'move faster' fails at registration in Unity Catalog. |
| 4.5 Register the model to Unity Catalog using MLflow | Registering saves the logged model as a versioned asset in Unity Catalog, where it can be governed and promoted between environments. | A team wants a development, staging and production path for a chain and asks how to mark which version is live. | Register with mlflow.set_registry_uri('databricks-uc') and a three-level name (catalog.schema.model). Stages are not supported for models in Unity Catalog; use aliases such as a Champion alias, and use separate catalogs or names per environment. | Moving a version to a 'Production' stage is the legacy workspace registry pattern and is not available here. |
| 4.6 Create and query a Vector Search index | A search index stores embeddings so that text can be found by meaning. The guide calls the product Vector Search; current docs call it AI Search. You create an endpoint to host it and then an index on a source table. | A team has a Delta table of chunks and wants to create an index and query it with a filter. | Create a search endpoint, then a Delta Sync index on the table, and query it by text or vector. Filters on a standard endpoint are a dictionary, for example {"title": ["Ares", "Athena"]}; on a storage-optimized endpoint they are a SQL-like string such as "language = 'en'". | Using the dictionary filter style on a storage-optimized endpoint fails because the syntax differs by endpoint type. |
| 4.7 Identify how to serve an LLM application that leverages Foundation Model APIs | Foundation Model APIs host open and partner models for you. You serve an application that uses them by calling a Databricks-hosted endpoint instead of running your own GPU. | A prototype with low, uneven traffic needs a hosted chat model with no infrastructure to manage. | Call a pay-per-token Foundation Model API endpoint, which is the easiest start. Provisioned throughput is recommended for production with steady or high traffic, because it reserves capacity and gives predictable latency. A priority tier exists for latency-sensitive pay-per-token use at higher cost. | Provisioning dedicated capacity for a small prototype pays for idle capacity. Runner-up wins when: Provisioned throughput wins when traffic is steady and high, or latency guarantees are required. |
| 4.8 Explain the key concepts and components of Mosaic AI Vector Search | The key parts are: an endpoint (the compute that hosts the index), the index itself, a sync mode (how it follows the source), and an embedding model that is either managed by Databricks or supplied by you. | A team has no embedding pipeline and wants the index to keep itself current as the table changes. | Use a Delta Sync index with Databricks-computed embeddings: the index follows the table and generates vectors for you. Use self-managed embeddings when you already hold vectors; that choice cannot be switched later. Direct Vector Access means you update the index yourself through the API, on standard endpoints only. | Direct Vector Access gives control but makes you responsible for every update. Runner-up wins when: Direct Vector Access wins when updates arrive as events from an application, not as table changes. |
| 4.9 Identify batch inference workloads and apply ai_query() appropriately | ai_query() is a SQL function that calls a model endpoint for each row. It suits batch jobs, such as scoring a whole table overnight. | A retailer must summarize two million product reviews once a night from a table. | Use ai_query in a SQL query or job against the table. It works on Databricks SQL and Databricks Runtime 15.4 LTS and above, and not on Classic SQL warehouses. Interactive per-user requests belong on a serving endpoint instead. | Looping a REST call per row from a notebook is slower to build and harder to scale and retry. Runner-up wins when: A real-time serving endpoint wins when users wait for each reply. |
| 4.10 Configure vector search for a particular solution based on number of embeddings, update frequency, latency, and cost requirements | Search settings should match the workload: how many vectors, how often they change, how fast queries must be, and what it costs. | A team expects 600 million vectors at 768 dimensions, with updates nightly and relaxed latency. | That is beyond what a standard endpoint holds (about 320 million vectors at 768 dimensions), so choose storage-optimized, which holds over a billion vectors and indexes faster. Queries add roughly 250 ms, and continuous sync is not supported, so a nightly triggered sync fits. | Standard is the default choice and the only type for high queries per second, but the vector count here exceeds it. Runner-up wins when: Standard wins when the count fits and the app needs high query throughput or low latency. |
| 4.11 Configure a persistent datastore to store and retrieve intermediate memory or structured information | A persistent datastore holds memory or structured data between requests, such as a conversation history or a user profile, because the model itself keeps nothing. | A support agent must remember earlier turns of a conversation across separate requests. | Store the conversation state in a persistent store such as Lakebase, a Databricks-managed Postgres database, keyed by a conversation id, and load it at the start of each request. Declare it as a resource (DatabricksLakebase) so the endpoint may use it. | Keeping memory in a Python variable inside the endpoint loses it when the replica restarts or another replica serves the next request. |
| 4.12 Apply CI/CD best practices such as updating a Vector Search index, promoting prompts across environments, and testing individual components of an agent | CI/CD means automated testing and promotion. For an agent, that covers refreshing the index, moving prompts between environments, and testing each component on its own. | A team wants every merge to test the retriever and the prompt separately, then promote what passes to production. | Test components individually, such as a unit test on the retriever and a scorer run on the prompt, then deploy the same code across environments with bundles. Promote prompts by registry alias, and refresh the index with a job that syncs after the source table updates. | Only testing the whole agent end to end hides which part broke. |
| 4.13 Integrate managed, external, and custom MCP servers based on a given application requirements | MCP, the Model Context Protocol, is a standard way to expose tools to agents. Databricks offers managed servers, lets you register external ones, and lets you host your own custom server. | An agent needs to query a Genie space and also call a partner SaaS tool exposed over MCP. | Use a managed MCP endpoint for the Databricks side (Genie, search, SQL, Unity Catalog functions) and register the partner server as an external MCP server through a Unity Catalog connection. Managed MCP endpoints are Public Preview and an admin must enable them. Host a custom server on Apps when no managed or external option exists. | Writing a custom server for something already offered as managed duplicates work you must then maintain. Runner-up wins when: A custom MCP server wins when you need tool logic that no managed or external server provides. |
| 4.14 Apply prompt version control and manage prompt lifecycle | Prompt version control stores each prompt edit as a numbered version, with aliases pointing to the live one, so changes can be reviewed and rolled back. | A prompt change made the agent worse in production, and the team wants to return to the earlier text fast. | Keep prompts in the MLflow Prompt Registry, which is Beta and needs mlflow[databricks]>=3.1.0. Point a production alias at a version; to roll back, repoint the alias, with no code change. | Prompts hard-coded as strings in source mean a rollback needs a code release. |
| 4.15 Develop an appropriate interactive user facing interface for an agent usage scenario (Apps, Slack, Teams, etc.) | Users need a front end for the agent. Databricks Apps hosts a web app next to your data, and chat tools such as Slack and Microsoft Teams reach people where they already work. | A sales team wants to talk to an agent inside the chat tool they already use all day. | Connect the agent to Teams or Slack, since the best interface is the one users already have open. Choose Databricks Apps when you need a custom web interface, such as a review screen, hosted under workspace governance. | Building a new web app for a team that lives in chat adds a place they must remember to visit. |