Databricks GenAI: Chain Components, Agent Tools and Agent Bricks
Chain components, tools and Agent Bricks are the building blocks you choose when you design a Databricks generative AI application: a chain is an ordered set of components (retriever, prompt template, model, output parser) that turns a required input into a required output, tools are the functions and retrievers an agent calls to gather knowledge or take actions, and Agent Bricks is the low-code way to build common agents — Knowledge Assistant, Information Extraction and the Multiagent Supervisor — without writing that pipeline yourself. This lesson covers the three Section 1 skills that sit after prompt design: selecting chain components for a given input and output, defining and ordering tools for multi-stage reasoning, and deciding how and when to use Agent Bricks. Prompt wording, model task choice and response formats in depth belong to the sibling lesson on prompt design and model task selection.
On this page10 sections
- Which chain components turn a given input into the required output?
- How do you match the prompt and output to a chat model?
- How does the chain's input shape what gets retrieved?
- When should you use a fixed chain, a router or a tool-calling agent?
- How does an agent decide which tool to call?
- Which tool type fits each kind of knowledge or action?
- How do you order tools for multi-stage reasoning?
- How do you make action tools safe?
- Which Agent Bricks agent fits the problem?
- When should you choose Agent Bricks over a custom agent, and how do experts improve it?
- Select and order chain components — retriever, prompt template, chat model, output parser — so a chain turns the stated input into the stated output, and leave out components the input does not need.
- Match the model interface with chat prompt templates and structured outputs, and build facts such as sources in code rather than trusting the model to generate them.
- Shape retrieval from the chain's input: rewrite follow-up questions into standalone queries and pass structured fields such as tenant or tier to the retriever as metadata filters.
- Choose between a fixed chain, a router and a tool-calling agent from how much the steps vary and what cost and latency allow.
- Define tools the model can select correctly, pick the right tool type for each knowledge source or action, order dependent calls and parallelize independent ones.
- Guarantee safe actions by enforcing preconditions, least privilege and idempotency inside the tool rather than in the prompt.
- Decide when Knowledge Assistant, Information Extraction or a Multiagent Supervisor fits, how experts improve them, and when a custom Agent Framework agent is needed instead.
Which chain components turn a given input into the required output?
Pick chain components by tracing the data: start from what arrives (a question string, a JSON payload, a whole document, a conversation) and end at what the consumer needs (plain text, a list, a typed record). Each component exists to close one gap between the two, and they run in the order the data needs them.
| Component | What it does | Needed when… |
|---|---|---|
| Retriever | Searches an index (Mosaic AI Vector Search) and returns the most relevant chunks with their metadata | The answer depends on knowledge the model lacks or that changes, and it is too large to send whole |
| Prompt template | Combines the input (and retrieved passages, history, instructions) into the prompt | Almost always — it is how variable input reaches the model |
| Chat model | Generates the response (for example a Foundation Model APIs endpoint) | Always |
| Output parser | Turns the model's reply into the shape the consumer needs: a string, a list, or a JSON/typed object | Always; the parser type is chosen from the required output |
| Memory / chat history | Carries earlier turns into later ones | Only for multi-turn conversations |
A typical RAG chain therefore runs retriever → prompt template → chat model → output parser. A retriever after the model, or a template after the model, breaks the flow: the model would answer before seeing the passages. The parser at the end follows the consumer: a string parser for text shown to a person, a list parser when a downstream system loads separate entries, a JSON or structured parser when code reads named fields.
Leave out what the input does not need
Fewer components mean lower latency and fewer failure points. If the whole input — one meeting transcript, one contract — always fits in the model's context window, put it straight into the prompt template: a retriever over its chunks adds a search call and can drop relevant parts it does not return. Memory is for state across turns, not for holding a single document.
Retrieval keeps answers current; fine-tuning does not
When source documents change every few weeks, retrieval at query time reflects the latest indexed text immediately. Fine-tuning bakes in a snapshot of the documents and would have to be repeated on every change, so it is the wrong tool for freshness. Fine-tuning changes style or task behaviour; retrieval supplies facts.
How do you match the prompt and output to a chat model?
Chat models take a list of role-tagged messages (system, user, assistant), so use a chat prompt template: fixed behaviour instructions go in the system message, the variable input in the user message. Foundation Model APIs chat endpoints use this chat-completions format. A string template, or a chat template that folds the instructions into the user message, still runs, but the standing instructions then reach the model as part of the user's turn rather than as system guidance.
Structured output when code reads the result
When a downstream job loads fields (category, priority, product) into a table, format failures — a sentence before the data, a misspelled key — are an output-side problem. Few-shot examples, a larger model or memory make the right format more likely; only structured output fixes it. On Foundation Model APIs, set response_format to a JSON schema (json_schema) so the reply must match named fields and types, then parse it into a typed object. json_object mode only guarantees valid JSON, not your schema.
- Optional values: a field declared as a required string must be filled with a string, so the model invents one when the value is absent. Declare a field that may be missing as a type list such as
["string", "null"]and tell the model to return null when the value is absent; it then loads as NULL. - Unsupported keywords: Foundation Model APIs structured outputs do not support JSON Schema keywords such as
patternoranyOf; validate formats in code.
A schema guarantees shape, not truth
Structured output makes the reply parseable; it does not make the values correct. If an app must show the source URLs of documents actually used, do not ask the model to write them — it can invent plausible URLs that still pass the schema. The retriever already returns each chunk with its metadata, so carry the retrieved documents forward alongside generation and build the sources list in code from that metadata. Any fix that still has the model produce the sources, however strictly instructed, lowers the error rate without guaranteeing it.
How does the chain's input shape what gets retrieved?
The retriever only sees what the chain passes it, so two input situations need explicit handling: follow-up messages in a conversation, and structured fields that decide which documents are allowed.
Rewrite follow-ups into standalone queries
A follow-up such as 'how long does that take?' carries no topic on its own. The chat model may see the whole history, but if the retriever embeds only the latest message it searches for nothing useful. A history-aware query rewrite (condense) step takes the chat history plus the latest message and uses an LLM call to produce a standalone question, which replaces the raw message as the retrieval query.
| Option | Effect on follow-ups |
|---|---|
| Rewrite step (history + latest message → standalone query) | Fixes the query itself; handles long, topic-changing conversations; costs one extra LLM call |
| Embed the whole conversation as one string | The longer and more varied the conversation, the less the embedding reflects the current question |
| Retrieve more chunks (higher k) | Searches more widely with the same empty query |
| Rerank the results | Reorders results of the same poor query |
| Reorder history and passages in the prompt | Changes what the generator sees, not what is retrieved |
Because the rewrite is an extra model call, run it only when earlier turns exist. The first message of a conversation has no history to resolve, so send it straight to retrieval; common history-aware retriever helpers behave this way when the history is empty. The rewrite step does not need the previous turn's documents or the answer model's system prompt.
Pass structured fields to the retriever as filters
When a request carries a field that decides which documents are allowed — tenant_id, plan tier, product_line — pass it to the Vector Search query as a metadata filter on the matching column. Filtering happens inside the search, so disallowed chunks never reach the prompt. Putting the field in the prompt, appending it to the query text, reranking, or scrubbing the answer afterwards all let the wrong content into the pipeline and then try to suppress it — they reduce leaks but do not eliminate them.
The filter column must exist in the index. For a Delta Sync index created with columns_to_sync limited to the ID and text, the column is missing, and the synced columns cannot be changed on an existing index: rebuild the index with the column included, then pass the filter. (Current Databricks documentation has started calling Vector Search 'AI Search'; the exam guide keeps the Vector Search name.)
When should you use a fixed chain, a router or a tool-calling agent?
Use a fixed chain when every request goes through the same steps in the same order, a tool-calling agent when requests need different sources or actions and the model must decide, and a router in front when most traffic is simple and only some needs the agent.
| Design | Fits when… | Trade-off |
|---|---|---|
| Sequential chain | Steps are known in advance (summarize, then translate) | Predictable cost and latency, easy step-by-step debugging; cannot adapt to varied requests |
| Tool-calling agent | Some requests need one source, some another, some both, some none | Calls only what each request needs; each request pays the model's planning loop and behaviour is less predictable |
| Router + chain/agent | Traffic is skewed: most requests are simple, a minority need tools or multi-step reasoning | A cheap classification step (small model) sends simple requests to a RAG chain and the rest to the agent |
A fixed chain that calls every source on every request either pays for slow lookups it does not need or, if it skips a source, misses requests that need it. The reverse mistake is wrapping a fixed two-step workflow in an agent or a multi-agent supervisor, which adds latency and unpredictability for flexibility nobody uses.
For skewed workloads, the cost lives in the agent's planning loop: a large model decides what to do on every request. Instructions inside the agent ('answer FAQs with one retrieval') still run that loop, and shrinking the agent's model puts the complex cases at risk. Only a step in front of the agent keeps simple requests away from it.
How does an agent decide which tool to call?
An agent's model sees each tool only as a name, a description and a parameter schema, and it chooses tools by matching the request to those definitions. Write them for the model: what the tool returns, when to use it, and what each parameter expects.
- Unity Catalog function tools: the function name, the function
COMMENTand each parameter'sCOMMENTbecome the tool definition. An opaque, abbreviated name with no comments gives the model no reason to connect it to a question, so it answers from its own knowledge. Only the function's own metadata becomes the tool definition; documentation kept anywhere else, such as on the underlying table, does not reach the model. - Vector Search retriever tools: give each one a distinct
tool_nameand atool_descriptionof the content it covers. Two retrievers created with only an index name look nearly identical to the model, so it picks between them almost at random — even though each index returns good results when queried directly. - Parameter formats: state the expected format in the parameter comment (for example an ISO date in YYYY-MM-DD form).
- Facts the model cannot know: a relative value such as 'last Tuesday' can only be resolved against today's date, so supply the current date in the system prompt.
When the wrong tool is chosen, fixes that act after the choice — reranking, more results, a larger context window, more max_tokens, retrying with the same argument — do not help. Pasting a function's code into the prompt does not either; the description is the interface.
Which tool type fits each kind of knowledge or action?
Choose the tool type from the shape of the data and the question: exact lookups by key need a deterministic query, unstructured text needs semantic retrieval, open-ended analysis over tables needs generated SQL, and actions need a narrow tool that performs one operation.
| Need | Tool type | Why not the alternatives |
|---|---|---|
| Exact current record by ID (order status, ticket row, warranty date) | Unity Catalog function with the key as a parameter, querying the live table | Similarity search ranks near-misses and indexed copies can be stale |
| Guidance in unstructured text (policies, runbooks, manuals) | Vector Search retriever tool over the chunked documents | Keyword matching in a function misses passages worded differently from the question |
| Open-ended analytical questions over tables (revenue by region and quarter) | A Genie space added to the agent as a tool | A fixed-parameter function cannot anticipate every combination; retrieval cannot compute aggregates |
| A state-changing action (update an address, issue a refund) | A purpose-built action tool that calls the owning service (see the safeguards section) | Generic SQL or API executors let the model compose any operation |
One agent often needs several types at once — a function for the ticket status and a retriever for the runbooks. Swapping them gives near-miss tickets and missed runbooks. Turning documents into tables with extraction is a different job, not a retrieval tool.
How do you order tools for multi-stage reasoning?
Order tool calls by their data dependencies: a call that needs another call's output must wait for it; calls that share no inputs can run in parallel; and knowledge-gathering calls run before any irreversible action.
- Dependent chain: an email in the session yields a
customer_id, the customer ID yields open orders and the latestorder_id, and only then can an order-level tool run. Calling a tool before its input exists fails. - Knowledge before action: when an action has a condition ('cancel if still within the window'), look up the policy before the side-effecting call. Checking afterwards cannot undo it.
- Parallel where independent: two store counts and a policy search share no inputs, so request them together; models that support parallel tool calls can request several in one step, and total latency becomes roughly the slowest call rather than the sum.
- Mixed plans: run the shared prerequisite first (get the customer ID), then fan out the calls that each need only that ID (tickets and invoices together), then generate.
Running everything in parallel breaks dependencies; running everything in sequence wastes time; splitting a request across turns adds a round trip for no gain.
How do you make action tools safe?
Make the tool itself enforce the rules. An agent's tool choices come from the model, so prompt rules, tool descriptions and tool-list order influence behaviour but never guarantee it — a user who insists can still steer the model.
Preconditions inside the tool
If a refund must never be issued for an ineligible order, put the eligibility check inside issue_refund so it refuses whenever the check fails. A system prompt rule, a description saying 'use after the check' or listing the check first all raise the success rate; only enforcement in code makes it a guarantee.
Narrow tools, least privilege
A tool that runs any SQL statement, or passes any model-written request to an API, makes the security boundary depend on the model. Replace it with purpose-built tools that encode the allowed operation: a function that reads one customer's orders, and a tool that calls only the service's address-update endpoint. Table-level MODIFY grants are broader than one permitted change, and a prompt rule is not enforcement.
Unity Catalog SQL and Python functions are suited to reads and computation, not to writing Delta tables, so state changes go through the owning service's API — for example a Unity Catalog function that calls the endpoint through a Unity Catalog HTTP connection — or through a tool defined in the agent's own code.
Idempotency for retries
A timeout does not mean the action failed: the payment may have gone through, so a blind retry pays twice. Retries are still needed for genuine failures, so removing them is not the answer. Make the tool idempotent: key it on an identifier unique to each requested action and return the already-recorded result instead of acting again. The key must identify the request, not just the object acted on, so a later, separate legitimate action on the same object is still possible.
Which Agent Bricks agent fits the problem?
Agent Bricks builds common agents from a configuration — sources, descriptions, instructions and examples — instead of code. The exam guide names three, and each fits one shape of problem:
| Agent | Use it for | Output |
|---|---|---|
| Knowledge Assistant | Conversational Q&A over documents, with the source shown | Answers with citations, one question at a time |
| Information Extraction | The same fields from every document, loaded into a table, refreshed as documents arrive | Structured records (JSON per document) in a table |
| Multiagent Supervisor (Supervisor Agent) | One chat entry point over several existing agents or tools, routing each request or part of it | Answers assembled from the subagents |
Product status: Databricks documentation now labels Knowledge Assistant and Supervisor Agent as legacy offerings and points new low-code work to Genie Agents and coded multi-agent work to the Agent Bricks CLI; Information Extraction has a newer version. The March 2026 exam guide still names all three, and their use-case fit is what the exam tests.
Knowledge Assistant
Knowledge sources can be files in a Unity Catalog volume, a Unity Catalog table with a file content column, or a Vector Search index, and one assistant can hold several sources. If all users may read every collection, one assistant with several sources is simpler than several assistants under a supervisor. File-based sources do not update on their own: after files are added, run a Sync (incremental — for example, newly added files are processed without reprocessing the rest); index-based sources follow their index automatically. It is the wrong shape for exact, live lookups such as one account's orders.
Information Extraction
Define a schema of output fields; the field names, types and especially descriptions are what the agent relies on to know what to extract. When a vaguely named field picks up the wrong value — for example, one of several similar dates in a document — write a description that defines it precisely and says what it is not. Run it ad hoc over a volume or a table with a text column, or deploy it as a pipeline that processes new data on a schedule. PDFs are converted first (the documented workflow uses ai_parse_document to build a text table). A hand-written ai_query prompt can do the same job, but keeps the field definitions in code that engineers maintain.
Multiagent Supervisor
The supervisor coordinates subagents such as Genie spaces, Knowledge Assistant endpoints, model serving endpoints and Unity Catalog functions. It routes using the description of each subagent, so misrouting between subagents that each work well alone is fixed with detailed, distinct descriptions. It respects end-user access: it uses only the subagents the user can access, steers away from the others, and ends the conversation only when the user can access none. Nothing runs under the creator's identity. Folding one data type into another agent (tables into a Knowledge Assistant, manuals into Genie) loses what made each agent good; the supervisor adds routing instead.
When should you choose Agent Bricks over a custom agent, and how do experts improve it?
Choose Agent Bricks when the use case is standard — retrieve and answer with citations, extract fields, route between agents — and has no custom logic; choose a custom agent written in Python with Mosaic AI Agent Framework, logged with MLflow and served on Databricks when every request must run custom code, apply filters computed by internal logic, or return a fixed output contract.
| Situation | Better fit |
|---|---|
| A hand-coded RAG chatbot with no logic beyond retrieve-and-answer, where the team spends its time on parsing, chunking and evaluation code | Knowledge Assistant: less to maintain, built-in expert feedback |
| A mandatory external call after every search, per-matter access filters from internal code, a fixed JSON contract for another system | Custom Agent Framework agent; MLflow tracing and evaluation still apply |
Adding feedback tooling to a hand-coded chain improves how expert input is collected, but leaves the team maintaining the same pipeline code. Agent Bricks agents are steered through sources, descriptions, instructions and examples; those shape behaviour but cannot inject arbitrary code into retrieval.
Improving quality with subject-matter experts
Agent Bricks is designed so the people who know what a good answer looks like improve the agent without engineering work. In Knowledge Assistant, experts add example questions (common or poorly answered ones) and attach guidelines describing what a good answer contains; saved guidelines take effect right away. In Information Extraction, they refine field descriptions in the UI. To edit these, experts need CAN MANAGE permission on the agent itself; permission to query the agent or to read its source data is not permission to change it.
When retrieval is fine and only company conventions are missing, the fix is examples and guidelines, not fine-tuning, a bigger embedding model, rewriting the source documents or adding more of them.
Tip. Questions are scenarios that open with a Generative AI Engineer and a concrete requirement — an input and output shape, documents that change, a follow-up that retrieves poorly, content a customer must never see, skewed traffic, a tool the agent ignores, a refund that must never be duplicated, experts who do not code — followed by a one-line question about which chain components, design, tool, call order or Agent Bricks agent fits. Wrong options are usually real techniques that miss one stated constraint, often the difference between influencing behaviour and guaranteeing it, or between least effort and more configuration. A few items ask you to select two answers, and some name Unity Catalog function comments, retriever tool settings, response_format or Delta Sync index columns.
- Trace the data to pick chain components: retriever → prompt template → chat model → output parser, with the parser chosen from the required output (string, list, typed object).
- Skip the retriever when the whole input fits in the context window, and use retrieval, not fine-tuning, to keep answers current with changing documents.
- Use a chat prompt template with a system message for fixed instructions; use a JSON-schema response format when code reads the output, with nullable fields as a type list such as string and null.
- A schema guarantees shape, not truth: build sources from retrieved-chunk metadata in code.
- Rewrite follow-ups into standalone queries from history plus the latest message, and skip the rewrite on the first turn.
- Request fields that decide which documents are allowed belong in retriever metadata filters; the filter column must be synced into the index.
- Fixed steps call for a chain, varied requests for a tool-calling agent, and skewed traffic for a cheap router in front of the agent.
- Tool names, function and parameter comments and retriever descriptions are what the model reads to choose tools; supply facts like today's date in the prompt.
- Order tools by dependencies, gather knowledge before actions, parallelize independent calls; enforce preconditions, least privilege and idempotency inside action tools.
- Knowledge Assistant answers from documents with citations, Information Extraction fills tables from documents, the Multiagent Supervisor routes by subagent descriptions under end-user access; custom logic calls for an Agent Framework agent.
Frequently asked questions
In what order do the components of a Databricks RAG chain run?
A RAG chain runs a retriever first, which searches a Vector Search index for chunks relevant to the input, then a prompt template that combines the input with those chunks, then the chat model, and finally an output parser that turns the reply into the required shape such as a string, a list or a typed JSON object. If the whole input already fits in the model's context window, the retriever can be left out.
Why does an agent ignore a Unity Catalog function tool?
An agent chooses tools from their names, descriptions and parameter definitions. For a Unity Catalog function, those come from the function name, the function COMMENT and the parameter COMMENTs, so an opaque name with no comments gives the model no reason to call it. Rename the function descriptively and document what it returns, when to use it and the format each parameter expects.
How do you stop a RAG chain from returning another tenant's documents?
Pass the request's tenant ID to the retriever as a metadata filter on the tenant column of the Vector Search index, so other tenants' chunks are excluded inside the search and never reach the prompt. The column must be among the index's synced columns. Prompt instructions, reranking or scrubbing the answer afterwards reduce leaks but do not guarantee exclusion.
When should you use a tool-calling agent instead of a chain?
Use a tool-calling agent when requests vary — some need one source, some another, some several or none — and the model should decide which tools to call. Use a fixed sequential chain when every request goes through the same steps, because it is cheaper, faster and easier to debug. When most traffic is simple, put a small-model router in front of the agent so simple requests skip its planning loop.
How do you guarantee an agent never takes a forbidden action?
Enforce the rule inside the action tool: the tool checks its precondition and refuses when it fails, accepts only the narrow operation it was built for, and is idempotent on the request ID so retries after timeouts do not repeat the action. Prompt rules, tool descriptions and tool order only influence the model and cannot guarantee its behaviour.
What is the difference between Knowledge Assistant and Information Extraction in Agent Bricks?
Knowledge Assistant is a chatbot that answers questions one at a time from documents in Unity Catalog volumes, tables or Vector Search indexes and cites its sources. Information Extraction pulls the same schema of fields out of every document and writes them to a table, in batch or on a schedule. Use Knowledge Assistant when people ask open questions and Information Extraction when analysts need structured data they can query with SQL.
How does the Agent Bricks Multiagent Supervisor decide which subagent answers?
The Multiagent Supervisor, also called Supervisor Agent, delegates each request or part of a request using the description written for each subagent, such as a Genie space or a Knowledge Assistant endpoint. Detailed, distinct descriptions fix misrouting. It only uses subagents the current user has access to and ends the conversation if the user can access none of them.
Are Knowledge Assistant and Supervisor Agent still current?
Databricks documentation now labels Knowledge Assistant and Supervisor Agent as legacy offerings, recommending Genie Agents for new low-code agents and the Agent Bricks CLI for coded multi-agent systems, and Information Extraction has a newer version. The March 2026 Generative AI Engineer Associate exam guide still names Knowledge Assistant, Multiagent Supervisor and Information Extraction, so learn which problem each solves.
Source
This lesson covers the "Design Applications" domain of the official Databricks GenAI exam guide. Vendors revise their guides — check the source for the current version.
Sign up free to mark lessons complete, bookmark topics and track your exam readiness.