What you will be able to do
- Explain what a Genie space (Genie Agent) gives a multi-agent system that a document retriever does not
- List the prerequisites for calling the Genie Conversation API, including what makes a Genie space well curated
- Order the Conversation API calls for a new question: start a conversation, poll the message, then fetch the query result
- Connect an agent to one Genie space through its managed MCP server, and say what that server does not do
- Add a Genie space as a subagent under a Supervisor Agent or a custom orchestrator on Databricks Apps, with the right permissions
Key concept
Genie as a natural-language SQL tool — A Genie space (now called a Genie Agent) takes a plain-language question, writes and runs SQL against a curated set of Unity Catalog tables, and returns the result. A multi-agent system treats it as the one tool that answers questions about structured data.
1.What a Genie space adds to a multi-agent system
A multi-agent system usually needs two kinds of knowledge, and they take different tools. Policy documents, manuals and FAQs are unstructured text, so a RAG agent retrieves chunks of them. Questions like "what were total sales last month?" live in tables, and the answer has to be computed by a query. A Genie space handles that second kind. The standard pattern combines a RAG agent over documents with a Genie agent over structured data, so users get answers from both sources through one entry point.
Genie's job is to turn a question into SQL. Nobody, whether the user or the calling agent, writes the query. The agent sends plain language, Genie writes the SQL and runs it against the space's tables, and the result comes back. Unity Catalog permissions are enforced on every request, so an agent can only see rows its caller is allowed to see. A vector search retriever works the opposite way: it never generates SQL. It returns stored text chunks that resemble the query. Neither tool can stand in for the other.
Genie Agents were formerly known as Genie Spaces. Exam questions, API paths such as /api/2.0/genie/spaces, and config keys such as genie_space and space_id still use the old name. Treat the two names as the same object. A Genie space is deliberately narrow: it holds up to 50 Unity Catalog tables, views or metric views that Genie keeps in context. Data analysts curate it with example SQL queries, SQL expressions for business terms, and text instructions written in the organisation's own vocabulary.
| Aspect | Genie space (Genie Agent) | RAG / retriever subagent |
|---|---|---|
| Data it reaches | Structured data in Unity Catalog tables | Unstructured documents |
| What it does with a question | Writes and runs SQL, returns the result | Retrieves relevant document content |
| Typical question | Metrics, totals, rankings, comparisons | Policies, procedures, documentation lookups |
Checkpoint 1 of 9· Check yourself
A support assistant built as a multi-agent system has to answer two kinds of question: "What were total sales by region last quarter?" and "What does our returns policy say about damaged items?" Which design fits these two questions?
Sales totals live in tables and must be computed by a query, so they go to Genie. Genie turns the plain-language question into SQL itself, so the caller never writes the query. Policy text is unstructured, so a RAG retriever fetches the relevant chunks. Neither tool can replace the other.
“combine a RAG agent that queries unstructured documents with a Genie agent that queries structured data”Source: docs.databricks.com
Checkpoint 2 of 9· Exam question
In the context of enabling multi-agent systems to retrieve data, what best describes what a Genie space (Genie Agent) provides compared to a vector search retriever tool?
Correct answer: A — A Genie space answers natural-language questions over governed tables by generating and running SQL, while a vector search retriever finds similar text chunks.
- A. This is correct because Genie spaces are designed for natural-language querying of structured tabular data by generating and running SQL, while vector search retrievers perform embedding-based similarity search over unstructured text chunks — the two serve distinct retrieval needs in a multi-agent system.
- B. This is incorrect because vector search retrievers do not generate or execute SQL at all; they return nearest-neighbor text chunks based on embedding similarity, which is a fundamentally different retrieval mechanism.
- C. This is incorrect because it reverses the two tools' actual roles: it is the vector search retriever that stores and searches embeddings, not the Genie space, which instead works with structured tables via SQL.
- D. This is incorrect because Genie spaces and vector search indexes are separate products serving different data modalities (structured tables versus embedded unstructured content) and are not interchangeable names for the same feature.
2.Before calling the Genie API: access and a well-curated space
The Genie API comes in three families. Chat mode APIs (the Conversation API) let an application or agent ask questions in stateful conversations, ask follow-ups, and retrieve the generated SQL, query results and visualizations. Agent mode APIs stream reasoning and SQL results and return final reports with citations. Management APIs create, configure and deploy Genie spaces across workspaces for CI/CD. A multi-agent system that retrieves data mostly uses the Chat mode APIs. You can call them over REST or through the Databricks SDKs.
A caller needs three things in place:
- A workspace with the Databricks SQL entitlement.
- At least CAN USE on a SQL pro or serverless SQL warehouse, because Genie runs its SQL on that warehouse.
- An authentication method: OAuth for users (U2M) when a person with a browser is present, or a service principal with OAuth M2M when browser sign-in is not possible. The service principal itself needs access to the data and the warehouse.
You also need the space ID, which is on the Genie space's Settings tab or available from the List Genie Agents API.
A correct integration can still return wrong answers. Genie gets all of its context from the space, so an incomplete or untested space produces bad SQL no matter how clean your API code is. A well-curated space has four properties:
- Well-annotated data: clear, descriptive table and column comments in Unity Catalog, since Genie reads that metadata.
- User tested: someone has asked the questions real users will ask, and used the results to write and refine example SQL.
- Company-specific context: instructions, example SQL and functions, with at least five tested example SQL queries.
- Benchmarks: at least five benchmark questions based on what users are expected to ask, used to measure accuracy.
Instructions carry business meaning that table metadata cannot. In the Create Genie Agent example, one text instruction defines "last month" as the previous calendar month rather than the last 30 days. Without it, two agents asking the same question could get different totals.
\"text_instructions\":[{\"id\":\"01f0b37c378e1c91\",\"content\":[\"When calculating revenue, sum the order_amount column. When asked about 'last month', use the previous calendar month (not the last 30 days). Round all monetary values to 2 decimal places.\"]}]Checkpoint 3 of 9· Check yourself
An orchestrator's calls to the Genie Conversation API succeed, and Genie returns SQL results. But when users ask for "revenue last month", the totals don't match the finance team's figures. The space has bare table names, no comments, no instructions and no example SQL. What is the most effective fix?
Genie gets all of its context from the space. An uncurated space produces wrong SQL even when the API integration is correct. Instructions, annotated metadata, tested example SQL and benchmarks fix that. The warehouse type and the authentication method only affect whether the call runs, not what the SQL means.
“If the agent is incomplete or untested, users might still receive incorrect results even with a correct API integration.”Source: docs.databricks.com
Checkpoint 4 of 9· Check yourself
A scheduled agent runs overnight with no person present and has to query a Genie space through the Chat mode APIs. Which setup lets its calls succeed?
No one is there to sign in through a browser, so the agent uses a service principal with OAuth M2M. The service principal needs its own access to the data, plus at least CAN USE on a pro or serverless SQL warehouse, because Genie runs its SQL there.
“Service principals must have permissions to access the required data and SQL warehouses.”Source: docs.databricks.com
Sources4
3.The Conversation API flow: start, poll, fetch the result
A custom agent that calls Genie directly, without Agent Bricks, makes three calls in a fixed order. The operation names below are the same in the REST API, the SDKs and the databricks genie CLI group, and they all sit under /api/2.0/genie/spaces/{space_id}.
- Start a conversation. A brand-new question goes to
start-conversationfor the space, with the question text as the content. Genie creates the conversation and its first message together and returns a conversation ID and a message ID. The endpoint for posting a follow-up into an existing conversation cannot be used for a first question, because it needs a conversation ID you don't have yet. - Poll the message. Call
get-messagewith the space, conversation and message IDs until the status is conclusive: COMPLETED, FAILED or CANCELLED. Poll every 1 to 5 seconds and back off exponentially to at most one minute between polls. After about 10 minutes, stop and return a timeout. - Fetch the rows. When the message has a query attachment, call
get-message-attachment-query-resultwith its attachment ID to get the tabular result, then hand it back to the orchestrating agent.
databricks genie get-message abc123 conv456 msg789Some shortcuts look reasonable and fail. Sending the question to the SQL Statement API skips Genie entirely: nothing interprets the language, so no SQL is generated. Calling start-conversation again with the same text does not return the previous result. It opens a second conversation. Deleting a conversation removes it and never forces a result.
Follow-ups reuse the conversation ID so Genie keeps the earlier context. That works within one session, but start a new conversation for each user session, because reusing a thread across sessions can lower accuracy through unintended context reuse. A space allows at most 200,000 conversations, so list old ones via GET /api/2.0/genie/spaces/{space_id}/conversations and clean them up. The API also does not retry failed requests for you. Add your own queuing with exponential backoff, and log requests and responses so you can debug and track costs.
Checkpoint 5 of 9· Put it in order
A custom agent, built without Agent Bricks, gets a brand-new user question about sales data and must answer it through the Genie Conversation API. Put its calls in the order they must happen.
- 1.When the message has a query attachment and its status is EXECUTING_QUERY or COMPLETED, call get-message-attachment-query-result with the attachment ID
- 2.Poll get-message with the space, conversation and message IDs, backing off exponentially between polls
- 3.Hand the tabular result back to the orchestrating agent
- 4.Call start-conversation on the space with the question text to receive a conversation ID and a message ID
A first question has no conversation ID yet, so it must go to start-conversation. Genie works asynchronously, so the agent polls the message until a query attachment exists. Only then can it fetch the rows and return them to the orchestrator.
“AI Bridge handles requests, polling, and query results through the Genie API.”Source: docs.databricks.com
Checkpoint 6 of 9· Exam question
A developer is writing a custom Python agent that does not use Agent Bricks and needs to programmatically ask a brand-new question against a Genie space with space_id=abc123 for the very first time in a session. Which API call should the agent issue first to obtain a conversation ID and message ID?
Correct answer: A — POST /api/2.0/genie/spaces/abc123/start-conversation, sending the question text in the request body to begin the thread.
- A. This is correct because the start-conversation endpoint on a Genie space is the documented call for beginning a new conversation thread; it returns the conversation ID and message ID needed for any follow-up calls.
- B. This is incorrect because the messages endpoint requires an existing
conversation_idin its path and is used to continue a conversation that has already been started, not to create the first one. - C. This is incorrect because that endpoint is a GET request used to poll the status of a previously created message, not to submit a new natural-language question.
- D. This is incorrect because the SQL Statement Execution API runs literal SQL text; it has no natural-language understanding and does not interact with Genie space conversation state.
Checkpoint 7 of 9· Exam question
An agent has already sent a message to a Genie space and received a message_id. It now needs to obtain the tabular result of the query Genie generated so it can pass the rows back to the orchestrating agent. What is the correct sequence to follow?
Correct answer: A — Poll GET .../messages/{message_id} until the status is conclusive (such as completed), then call GET .../messages/{message_id}/query-result/{attachment_id} to fetch the rows.
- A. This is correct because message processing is asynchronous: the agent must poll the message endpoint until a conclusive status is reached before the generated SQL's results become retrievable via the query-result endpoint keyed by attachment ID.
- B. This is incorrect because SQL generation and execution take time and are not guaranteed to finish synchronously; fetching the query result before processing completes will not reliably return the finished rows.
- C. This is incorrect because deleting a conversation removes it rather than finalizing it, and starting a brand-new conversation discards the in-progress question instead of retrieving its results.
- D. This is incorrect because repeatedly calling start-conversation creates a new conversation thread each time rather than checking the status of the message that was already submitted.
4.Connecting an agent through the Genie MCP server
With the managed MCP server, you don't write the start-poll-fetch loop. Each Genie space gets a pre-configured MCP URL, and an MCP-capable agent sees Genie as a tool. To set it up, create the Genie space, share it with the users or service principals that need it, and set the agent's server_url to the space's URL. A workspace admin must first turn on Managed MCP Servers on the workspace Previews page.
| Property | Value |
|---|---|
| URL pattern | https://<workspace-hostname>/api/2.0/mcp/genie/{genie_space_id} |
| OAuth scope | genie |
| Data scope | The single space's curated tables (up to 50), not the whole workspace |
| Access control | Permissions on the Genie space and its underlying data; calls don't go through Unity Gateway |
| Pricing | Databricks SQL pricing |
| Writes | None: read-only |
The MCP server has two limits that shape agent design. It is read-only, so it can query tables but never write to them. It is also stateless: each call is a fresh question. For follow-ups that need Genie to keep context, use AI Bridge from Python. It wraps the Genie API, handles requests, polling and results, and returns a conversation ID you can pass back on the next call.
genie = Genie(space_id="<genie-agent-id>", return_pandas=False)
@function_tool
def ask_genie(question: str) -> str:
"""Ask the configured Genie Agent a question about its business data."""
return genie.ask_question(question).resultThe per-space server is different from the Genie One MCP (system.ai.genie_one_mcp). Genie One answers business questions across the whole workspace using Genie Ontology, is governed through Unity Gateway at https://<workspace-hostname>/ai-gateway/mcp-services/system.ai.genie_one_mcp, and needs the ai-gateway OAuth scope for on-behalf-of user authentication. The older workspace-wide Beta endpoint, /api/2.0/mcp/genie with no space ID, is deprecated and will be sunset on October 31, 2026.
| Option | Use when | Who writes the SQL |
|---|---|---|
| Genie One MCP | Business questions across the workspace | Genie |
| Genie Agent MCP server | One curated Genie space, over MCP | Genie |
| AI Bridge tools (GenieAgent, Genie) | One curated Genie space from Python, keeping conversation_id for follow-ups | Genie |
| Databricks SQL MCP | The agent writes and runs its own SQL | The agent |
| Unity Catalog function tools | A predefined query with parameters | Written ahead of time |
Checkpoint 8 of 9· Fill the gap
This OpenAI Agents SDK tool wraps the AI Bridge Genie client so the model can query one Genie space without writing its own start-poll-fetch loop. Which method completes the tool?
genie = Genie(space_id="<genie-agent-id>", return_pandas=False)
@function_tool
def ask_genie(question: str) -> str:
"""Ask the configured Genie Agent a question about its business data."""
return genie. ? (question).resultAI Bridge wraps the Genie API. With one ask_question call, it sends the request, polls the message and fetches the query result. The other names are the separate Conversation API steps that AI Bridge runs for you. If you want follow-ups to keep context, pass the returned conversation_id on the next call.
Source: docs.databricks.com5.Genie as a subagent: Supervisor Agent or custom orchestrator
In a multi-agent system, the Genie space becomes one subagent, and a coordinator decides when to send it a question. The low-code coordinator is the Agent Bricks Supervisor Agent (Multiagent Supervisor), which orchestrates subagents and tools behind a single endpoint. Databricks now labels Supervisor Agent as a legacy offering, but it still coordinates Genie spaces this way. To add one, go to Tools and sub-agents, pick the Genie space, and write a detailed description. The supervisor uses that description to decide which questions to route to Genie. A supervisor can take up to 50 agents and tools.
Permissions follow the end user, not the supervisor. Each end user needs access to the Genie space and its underlying Unity Catalog objects. If they lack that access, the supervisor cannot return useful answers from Genie. If a user can reach some subagents but not others, the supervisor steers the conversation away from the ones they can't use. If they can reach none, it ends the conversation.
Build a custom orchestrator on Databricks Apps when you need routing logic or orchestration behaviour the Supervisor Agent doesn't support. The multi-agent template uses the OpenAI Agents SDK. Each backend is an entry in the SUBAGENTS list in agent_server/agent.py, and each entry becomes a tool. A genie entry connects through the built-in Databricks MCP server and needs the space ID plus CAN_RUN permission. As with the supervisor, routing quality depends on the description.
SUBAGENTS = [
{
"name": "genie",
"type": "genie",
"space_id": "<YOUR-GENIE-SPACE-ID>",
"description": (
"Query a Genie Agent for structured data analysis. "
"Use this for questions about data, metrics, and tables."
),
},The deployed app also has to declare the space as a resource in databricks.yml, with CAN_RUN permission. The app's service principal additionally needs access to the model endpoint and to the warehouse and data underneath the space. If the app has the Genie resource but not the warehouse, Genie can't run its SQL.
resources:
- name: 'genie_space'
genie_space:
name: 'Genie Agent'
space_id: '<YOUR-GENIE-SPACE-ID>'
permission: 'CAN_RUN'| Aspect | Supervisor Agent | Custom orchestrator on Apps |
|---|---|---|
| How Genie is added | Select the Genie space under Tools and sub-agents | A genie entry in SUBAGENTS with space_id |
| Connection | Managed by the supervisor | Built-in Databricks MCP server |
| Permission | End user needs access to the space and its Unity Catalog objects | CAN_RUN on the space, declared in databricks.yml |
| Choose it when | You want a UI-built system improved through natural language feedback from subject matter experts | You need custom routing or orchestration logic |
Checkpoint 9 of 9· Fill the gap
A custom orchestrator on Databricks Apps sends data questions to a Genie subagent. Its databricks.yml has to declare the Genie space as an app resource. Which permission level completes the declaration?
resources:
- name: 'genie_space'
genie_space:
name: 'Genie Agent'
space_id: '<YOUR-GENIE-SPACE-ID>'
permission: ' ? 'A genie subagent connects through the built-in Databricks MCP server and needs CAN_RUN on the space, so the app resource declares CAN_RUN. CAN_USE is the warehouse privilege and the permission an app needs on another app. Declaring the space doesn't replace the service principal's separate access to the warehouse and the data.
Source: docs.databricks.comSources
(8)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“you can combine a RAG agent that queries unstructured documents with a Genie agent that queries structured data”
↩︎ What a Genie space adds to a multi-agent system“Build a multi-agent system on Databricks Apps if you need custom routing logic or orchestration behavior that Agent Supervisor doesn't support.”
↩︎ Genie as a subagent: Supervisor Agent or custom orchestrator“combine a RAG agent that queries unstructured documents with a Genie agent that queries structured data”
↩︎ Checkpoint - 2.
“A Genie Agent is a collection of up to 50 Unity Catalog tables, views, or metric views that Genie keeps in context”
↩︎ What a Genie space adds to a multi-agent system“Read-only. The Genie Agent MCP server queries data; it doesn't write to your tables.”
↩︎ Connecting an agent through the Genie MCP server“A workspace administrator must enable Managed MCP Servers on the workspace Previews page.”
↩︎ Connecting an agent through the Genie MCP server“The agent sends a plain-language question, and Genie writes and runs the SQL against that agent's tables and returns the result”
↩︎ Key concept“No conversation history. The server invokes Genie as a tool, so it doesn't pass conversation history to the Genie API.”
↩︎ Exam trap 3“No conversation history. The server invokes Genie as a tool, so it doesn't pass conversation history to the Genie API.”
↩︎ Prediction - 3.https://docs.databricks.com/aws/en/genie-agentsOfficial docs
“Genie Agents were formerly known as Genie Spaces.”
↩︎ What a Genie space adds to a multi-agent system - 4.
“At least CAN USE privileges on a SQL pro or serverless SQL warehouse.”
↩︎ Before calling the Genie API: access and a well-curated space“If the agent is incomplete or untested, users might still receive incorrect results even with a correct API integration.”
↩︎ Before calling the Genie API: access and a well-curated space“Aim for at least five tested example SQL queries.”
↩︎ Before calling the Genie API: access and a well-curated space“Continue polling until a conclusive message status, such as COMPLETED, FAILED, or CANCELLED, is received.”
↩︎ The Conversation API flow: start, poll, fetch the result“The API doesn't retry failed requests for you, so add your own queuing and exponential backoff.”
↩︎ The Conversation API flow: start, poll, fetch the result“Start a new conversation for each session: Avoid reusing conversation threads across sessions, as this can reduce accuracy due to unintended context reuse.”
↩︎ Exam trap 2“Service principals must have permissions to access the required data and SQL warehouses.”
↩︎ Checkpoint - 5.
“databricks genie start-conversation SPACE_ID CONTENT [flags]”
↩︎ The Conversation API flow: start, poll, fetch the result“This is only available if a message has a query attachment and the message status is EXECUTING_QUERY or COMPLETED.”
↩︎ Exam trap 1“This is only available if a message has a query attachment and the message status is EXECUTING_QUERY or COMPLETED.”
↩︎ Prediction - 6.
“The previous Beta endpoint, https://<workspace-hostname>/api/2.0/mcp/genie, is deprecated and will be sunset on October 31, 2026.”
↩︎ Connecting an agent through the Genie MCP server - 7.
“The supervisor uses the information in the description to help it coordinate agents.”
↩︎ Genie as a subagent: Supervisor Agent or custom orchestrator“End users of the supervisor agent need explicit access to interact with each subagent.”
↩︎ Exam trap 4 - 8.
“When hosting your agent on Databricks Apps, add the Genie Agent as an app resource with Can run permission.”
↩︎ Genie as a subagent: Supervisor Agent or custom orchestrator“AI Bridge handles requests, polling, and query results through the Genie API.”
↩︎ Checkpoint