Skip to content

[DRAFT] Add experimental genie-cli command#5989

Open
tedjt wants to merge 6 commits into
databricks:mainfrom
tedjt:experimental-genie-cli
Open

[DRAFT] Add experimental genie-cli command#5989
tedjt wants to merge 6 commits into
databricks:mainfrom
tedjt:experimental-genie-cli

Conversation

@tedjt

@tedjt tedjt commented Jul 21, 2026

Copy link
Copy Markdown

Summary

Adds databricks experimental genie-cli: an out-of-the-box interactive AI coding agent preconfigured for a Databricks workspace. It authenticates through the workspace and routes model requests through the Databricks AI Gateway (no separate model API keys), preloads the Databricks skills plugin, registers Databricks MCP tools, and primes the agent with a Databricks-aware system prompt.

The command orchestrates an existing launcher (ucode) driving a coding agent, but that runtime is an intentional implementation detail: users only interact with genie-cli. The command is Hidden, matching the other in-progress experimental commands.

What each run does

  1. Ensures the launcher runtime is installed — installs it via uv tool install when missing, and errors with actionable instructions when uv itself is absent (no speculative auto-bootstrap of uv).
  2. Configures the chosen harness against the resolved workspace non-interactively — uses whatever identity the invocation resolved (--profile, DATABRICKS_CONFIG_PROFILE, the default profile, or env-var auth): --profiles <name> for a named profile (adding --use-pat for PAT profiles), else --workspaces <host>. This step also installs the agent binary and the Databricks CLI the launcher relies on.
  3. Installs the Databricks skills plugin for the harness if not already recorded, then refreshes it on every run (best-effort — offline/GitHub-unreachable warns and still launches). Skipped for harnesses without a headless plugin (e.g. opencode, which is skills-only).
  4. Registers Databricks MCP tools for the session from system.ai (best-effort).
  5. Primes the agent with a Databricks system prompt and hands off to the interactive session via process replacement (libs/execv, the same primitive databricks psql uses).

Choosing the coding agent (--harness)

--harness (default codex) selects which agent ucode launches; any ucode agent name is accepted. codex and opencode are both primed with the Databricks system prompt; other agents launch without injection.

System prompt

The prompt is adapted from the internal Genie Code agent, retargeted to the real databricks CLI, the installed Databricks skills, and the Databricks MCP servers. It:

  • Embeds the resolved workspace host and CLI profile, so the agent operates against the same workspace genie-cli authenticated with.
  • Aggressively routes any task that doesn't depend on the local filesystem (data discovery, analytics, data science) through hosted Genie via databricks experimental genie ask "<question>" — for a better, workspace-grounded, shareable result — rather than using Genie only to find tables and then hand-writing SQL locally. Genie still returns the SQL and tables it used, so the agent can explore further locally when the task genuinely needs it.
  • Is injected per-session only, without writing to the user's agent config, and delivery is harness-specific:
    • codex: inline -c developer_instructions=<toml> (additive developer-role message).
    • opencode: written to a genie-cli-managed file and referenced via OPENCODE_CONFIG_CONTENT={"instructions":[...]}, whose entries opencode appends to the model context (opencode has no inline system-prompt flag).
  • Can be disabled with --no-system-prompt.

Testing

  • go build ./..., go test ./experimental/geniecli/... (unit tests for arg construction, runtime detection/install, harness-aware launch args + env, prompt rendering with/without profile, per-harness injection, and the non-plugin-harness skip), and golangci-lint all pass (0 issues).
  • No new dependencies (no go.mod/go.sum changes). Reuses libs/aitools/installer so plugin behavior stays consistent with databricks aitools.
  • Built the binary and confirmed --harness / --no-system-prompt and help render correctly.

Note: the underlying agent runtime and MCP/opencode behavior have been verified against ucode/opencode/Codex source and unit tests, but not yet in a live end-to-end session (which would install ucode + an agent and mutate agent config).

Add `databricks experimental genie-cli`: an out-of-the-box interactive AI
coding agent preconfigured for a Databricks workspace. It authenticates
through the workspace and routes model requests through the Databricks AI
Gateway (no separate model API keys), and it preloads the Databricks skills
plugin so the agent works effectively against Databricks.

The command orchestrates an existing launcher (ucode) driving Codex, but
that runtime is an intentional implementation detail: users only interact
with `genie-cli`. On each run it:

  1. ensures the launcher runtime is installed (installing it via uv, and
     erroring with actionable instructions when uv is absent),
  2. configures the agent against the resolved workspace non-interactively,
  3. installs the Databricks skills plugin for the agent if not already
     recorded, then refreshes it (refresh failures are non-fatal so the
     agent still starts offline), and
  4. hands off to the interactive agent session via process replacement.

Co-authored-by: Isaac
@github-actions

Copy link
Copy Markdown
Contributor

Waiting for approval

Based on git history, these people are best suited to review:

  • @simonfaltum -- recent work in cmd/experimental/

Eligible reviewers: @andrewnester, @anton-107, @denik, @janniklasrose, @lennartkats-db, @pietern, @renaudhartert-db, @shreyas-goenka

Suggestions based on git history. See OWNERS for ownership rules.

Make the agent operate as a Databricks CLI assistant out of the box:

  - Inject a default system prompt (adapted from the Genie Code agent,
    retargeted to the real `databricks` CLI, the Databricks skills, and the
    Databricks MCP servers). It is injected per-session only, via the agent's
    `-c developer_instructions=` override — an additive developer-role message,
    so nothing is written to the user's agent config and their own instructions
    are untouched. `--no-system-prompt` opts out.
  - Embed the resolved workspace host and CLI profile in the prompt so the
    agent acts against the same workspace and profile genie-cli authenticated
    with.
  - Register Databricks MCP services from system.ai for the session
    (best-effort: a workspace without those services warns and still launches).

Co-authored-by: Isaac
@tedjt tedjt changed the title Add experimental genie-cli command [DRAFT] Add experimental genie-cli command Jul 21, 2026
tedjt added 4 commits July 20, 2026 20:45
Mark genie-cli Hidden like the other in-progress experimental commands
(genie, aitools). It stays fully runnable; it just doesn't list in
`databricks experimental --help`.

Co-authored-by: Isaac
Guide the agent to answer data discovery and data-science / analytics
questions with `databricks experimental genie ask "<question>"` instead of
hand-writing SQL, falling back to SQL only when Genie can't answer or the
user is authoring a query/pipeline.

Co-authored-by: Isaac
Sharpen the prompt around one decision: if a task does not depend on the
user's local filesystem, do the whole thing through `genie ask` rather than
using Genie only to find tables and then hand-writing SQL locally. Genie
gives a better, workspace-grounded, shareable result and still returns the
SQL and tables it used (via --include-sql / --output json) so the agent can
explore further locally when the task genuinely needs it.

Co-authored-by: Isaac
Add a --harness flag (default codex) so the user can choose which coding
agent ucode launches, with pass-through for any ucode agent name.

Make system-prompt injection harness-aware, since agents differ:
  - codex: inline `-c developer_instructions=<toml>` (unchanged).
  - opencode: no inline flag, so the prompt is written to a genie-cli-managed
    file and referenced via OPENCODE_CONFIG_CONTENT={"instructions":[...]},
    whose entries opencode appends to the model context. Still session-scoped
    (env var only) and non-destructive to the user's own opencode config.
  - any other harness: launched with no prompt injection.

Skip the aitools plugin step for harnesses without a headless plugin (e.g.
opencode, which is skills-only): those rely on the injected system prompt.

Co-authored-by: Isaac
@github-actions

Copy link
Copy Markdown
Contributor

An authorized user can trigger integration tests manually by following the instructions below:

Trigger:
go/deco-tests-run/cli

Inputs:

  • PR number: 5989
  • Commit SHA: f3649badce01615dfee080f27c3c4f39a29d6471

Checks will be approved automatically on success.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant