CertSafari
    Databricks Certified Generative AI Engineer Associate· Lessons

    Domain 3 · Lesson 27/56

    Genie in multi-agent systems: Conversation API, MCP server and subagents

    Enable multi-agent systems to leverage Genie Spaces or conversational API to retrieve data

    19 min read
    2.31% of exam
    8 sources
    Published 22 Oct 2026
    Docs as of 17 Oct 2026

    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.

    Two retrieval tools a multi-agent system routes between
    AspectGenie space (Genie Agent)RAG / retriever subagent
    Data it reachesStructured data in Unity Catalog tablesUnstructured documents
    What it does with a questionWrites and runs SQL, returns the resultRetrieves relevant document content
    Typical questionMetrics, totals, rankings, comparisonsPolicies, 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?

    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?

    Sources123

    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 instruction as it appears inside the serialized_space string of the Create Genie Agent request: business rules Genie applies when it writes SQLjson
    \"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?

    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?

    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}.

    1. Start a conversation. A brand-new question goes to start-conversation for 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.
    2. Poll the message. Call get-message with 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.
    3. Fetch the rows. When the message has a query attachment, call get-message-attachment-query-result with its attachment ID to get the tabular result, then hand it back to the orchestrating agent.
    CLI forms of the three calls; each argument maps to a path segment of the REST endpointbash
    databricks genie get-message abc123 conv456 msg789

    Some 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. 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. 2.Poll get-message with the space, conversation and message IDs, backing off exponentially between polls
    3. 3.Hand the tabular result back to the orchestrating agent
    4. 4.Call start-conversation on the space with the question text to receive a conversation ID and a message ID

    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?

    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?

    Sources54

    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.

    Genie Agent MCP server at a glance
    PropertyValue
    URL patternhttps://<workspace-hostname>/api/2.0/mcp/genie/{genie_space_id}
    OAuth scopegenie
    Data scopeThe single space's curated tables (up to 50), not the whole workspace
    Access controlPermissions on the Genie space and its underlying data; calls don't go through Unity Gateway
    PricingDatabricks SQL pricing
    WritesNone: 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.

    AI Bridge Genie client wrapped as a function tool (OpenAI Agents SDK)python
    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).result

    The 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.

    Choosing how an agent reaches structured data
    OptionUse whenWho writes the SQL
    Genie One MCPBusiness questions across the workspaceGenie
    Genie Agent MCP serverOne curated Genie space, over MCPGenie
    AI Bridge tools (GenieAgent, Genie)One curated Genie space from Python, keeping conversation_id for follow-upsGenie
    Databricks SQL MCPThe agent writes and runs its own SQLThe agent
    Unity Catalog function toolsA predefined query with parametersWritten 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).result

    Sources26

    5.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.

    Genie subagent entry in the orchestrator's SUBAGENTS listpython
    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.

    Declaring the Genie space as an app resource in databricks.ymlyaml
    resources:
      - name: 'genie_space'
        genie_space:
          name: 'Genie Agent'
          space_id: '<YOUR-GENIE-SPACE-ID>'
          permission: 'CAN_RUN'
    Two ways to put Genie under a coordinator
    AspectSupervisor AgentCustom orchestrator on Apps
    How Genie is addedSelect the Genie space under Tools and sub-agentsA genie entry in SUBAGENTS with space_id
    ConnectionManaged by the supervisorBuilt-in Databricks MCP server
    PermissionEnd user needs access to the space and its Unity Catalog objectsCAN_RUN on the space, declared in databricks.yml
    Choose it whenYou want a UI-built system improved through natural language feedback from subject matter expertsYou 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: ' ? '

    Sources718

    Sources

    (8)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 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. 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. 3.
      “Genie Agents were formerly known as Genie Spaces.”
      ↩︎ What a Genie space adds to a multi-agent system
    4. 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. 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. 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. 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. 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

    Spotted a mistake, or was something unclear? Tell us.