Loading...
Loading...
Create, manage, and query Databricks Genie Agents — curated, per-data natural-language agents (formerly Genie Spaces): build, export/import, migrate across workspaces, and ask questions of a *specific* Agent via the Conversation API. For general data questions or finding data across your workspace, use databricks-data-discovery (Genie One) instead.
npx skill4agent add databricks/databricks-agent-skills databricks-genie-agentsdatabricks-data-discoverydiscover-schemaquery "SHOW TABLES IN ..."databricks experimental aitools tools discover-schema catalog.schema.gold_sales catalog.schema.gold_customersdatabricks experimental aitools tools query --warehouse <WH> "..."DATABRICKS_WAREHOUSE_ID--warehouse <ID>databricks experimental aitools tools statement submit... getSUCCEEDED|FAILED|CANCELED|CLOSEDSIDS=()
for q in "$@"; do
SIDS+=( "$(databricks experimental aitools tools statement submit --warehouse "$WH" "$q" | jq -r .statement_id)" )
done
for s in "${SIDS[@]}"; do databricks experimental aitools tools statement get "$s"; done
# Use `status` for non-blocking peek; `cancel` to terminate.genie_agent.json# List all Genie Agents
databricks genie list-spaces
# Create a Genie Agent from a local file
# IMPORTANT: sample_questions require a 32-char hex "id" and "question" must be an array
# IMPORTANT: parent_path must ALREADY EXIST — create it first, or create fails with
# "Tree node with path ... does not exist":
databricks workspace mkdirs /Workspace/Users/you@company.com/genie_spaces
databricks genie create-space --json "{
\"warehouse_id\": \"WAREHOUSE_ID\",
\"title\": \"Sales Analytics\",
\"description\": \"Explore sales data\",
\"parent_path\": \"/Workspace/Users/you@company.com/genie_spaces\",
\"serialized_space\": $(cat genie_agent.json | jq -c '.' | jq -Rs '.')
}"
# Get agent details (with full config)
databricks genie get-space SPACE_ID --include-serialized-space
# Tag the Genie Agent for resource tracking — use any tag the user indicated for their
# project; otherwise default to `ai_generated_source=databricks-agent-skills`.
# (Beta CLI surface — ignore if the command fails.)
databricks workspace-entity-tag-assignments create-tag-assignment \
geniespaces SPACE_ID ai_generated_source --tag-value databricks-agent-skills || true
# Delete a Genie Agent
databricks genie trash-space SPACE_IDgenie_agent.jsonjq -c '.' | jq -Rs '.'jq -r '.serialized_space | fromjson'# Export: extract serialized_space AND unwrap it to a parsed object on disk
databricks genie get-space SPACE_ID --include-serialized-space -o json \
| jq '.serialized_space | fromjson' > genie_agent.json
# Import: same stringify pattern as Step 2 (Create)
databricks genie create-space --json "{
\"warehouse_id\": \"WAREHOUSE_ID\",
\"title\": \"Sales Analytics\",
\"description\": \"Migrated agent\",
\"parent_path\": \"/Workspace/Users/you@company.com/genie_spaces\",
\"serialized_space\": $(cat genie_agent.json | jq -c '.' | jq -Rs '.')
}"update-spaceALTEROPTIMIZEcancelled# 1. Edit your local genie_agent.json (add questions, fix SQL examples, improve instructions)
# 2. Push updates back to the agent
databricks genie update-space SPACE_ID --json "{\"serialized_space\": $(cat genie_agent.json | jq -c '.' | jq -Rs '.')}"serialized_spacesample_questionsexample_question_sqlstext_instructionsid| Field | Format |
|---|---|
| |
| |
| |
text_instructionsexample_question_sqlsquestionsqlcontentdata_sources.tablesidentifiercolumn_configscolumn_nameexample_question_sqlstext_instructionsidsample_questionstext_instructionstext_instructions must contain at most one item1…00011…0002sample_questions2…00012…0002example_question_sqls3…0001text_instructionsbenchmarksserialized_spaceversionconfigdata_sourcesinstructionsinstructionsidtext_instructionsversionconfigdata_sourcesinstructionssample_questionsexample_question_sqlstext_instructionsid{
"version": 2,
"config": {
"sample_questions": [
{"id": "10000000000000000000000000000001", "question": ["What is our current on-time performance?"]}
]
},
"data_sources": {
"tables": [
{"identifier": "catalog.ops.gold_otp_summary"}
]
},
"instructions": {
"example_question_sqls": [
{
"id": "20000000000000000000000000000001",
"question": ["What is our on-time performance?"],
"sql": ["SELECT flight_date, ROUND(SUM(on_time_count) * 100.0 / SUM(total_flights), 1) AS otp_pct\n", "FROM catalog.ops.gold_otp_summary\n", "WHERE flight_date >= date_sub(current_date(), 7)\n", "GROUP BY flight_date ORDER BY flight_date"]
}
],
"text_instructions": [
{
"id": "30000000000000000000000000000001",
"content": [
"On-time performance (OTP) questions: Use gold_otp_summary table. OTP target is 85%.\n",
"Delay analysis questions: Use gold_delay_analysis table. Filter by delay_code for specific delay types.\n",
"When asked about 'this week' or 'recent': Use flight_date >= date_sub(current_date(), 7).\n",
"When comparing aircraft: Join with gold_aircraft_reliability on tail_number."
]
}
]
}
}sedpython3 -c "import sys; p=sys.argv[1]; open(p,'w').write(open(p).read().replace('source_catalog','target_catalog'))" genie_agent.jsonDATABRICKS_CONFIG_PROFILE=profile_nameScope: use this to query one specific Genie Agent — typically to validate an Agent after creating or editing it, or to lean on its curated business logic and certified queries. For general natural-language data questions or finding data across your workspace, don't use this — route to the databricks-data-discovery skill (Genie One) instead.
start-conversationcreate-messageget-message--no-waitstart-conversationcreate-message{conversation_id, message_id}get-message.statusCOMPLETEDFAILEDCANCELLEDSUBMITTEDFILTERING_CONTEXTASKING_AIEXECUTING_QUERY# Start a new conversation (async — get IDs back immediately)
databricks genie start-conversation --no-wait SPACE_ID "What were total sales last month?"
# → {"conversation_id": "...", "message_id": "..."}
# Poll state
databricks genie get-message SPACE_ID CONV_ID MSG_ID | jq '{status, error}'
# When COMPLETED, pull the generated SQL and any text reply
databricks genie get-message SPACE_ID CONV_ID MSG_ID \
| jq '.attachments[] | {sql: .query.query, description: .query.description, text: .text.content}'
# Fetch the query result rows (columns + data_array)
databricks genie get-message-attachment-query-result SPACE_ID CONV_ID MSG_ID ATTACHMENT_ID \
| jq '{columns: .statement_response.manifest.schema.columns | map({name, type: .type_name}),
rows: .statement_response.result.data_array}'
# Follow-up in the same conversation (Genie remembers context)
databricks genie create-message --no-wait SPACE_ID CONV_ID "Break that down by region"create-messageCONV_IDFAILEDget-message.error.error[INSUFFICIENT_PERMISSIONS] ....error.typeSQL_EXECUTION_EXCEPTIONsuggested_questions| Issue | Solution |
|---|---|
| Add 32-char hex UUID |
| Use |
| No warehouse available | Create a SQL warehouse or provide |
Empty | Requires CAN EDIT permission on the agent |
| Tables not found after migration | Remap catalog name in |
| Slow answers / query timeouts | Size up the warehouse attached to the agent; simplify or pre-aggregate tall source tables |
| Wrong or empty answers | Add |