Repository navigation
aitools: skip the install hint on auth, lookup, and completion commands #7452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
67eaed7
887c084
e64c568
d0be319
2424143
3d91441
3238771
b85bd34
83b8607
34addb8
6d9ae47
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| * Stop printing the Databricks AI tooling install hint on `auth`, `configure`, `current-user me`, `version`, `help`, and shell-completion commands. ([#7452](https://github.com/databricks/cli/pull/7452)) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,46 +1,36 @@ | ||
|
|
||
| === Codex is hinted once per thread | ||
|
|
||
| >>> CODEX_CI=1 CODEX_THREAD_ID=thread-1 [CLI] version | ||
| >>> CODEX_CI=1 CODEX_THREAD_ID=thread-1 [CLI] jobs list | ||
| Databricks skills are not installed. To work with Databricks reliably, first run: databricks aitools install --agents codex --scope global | ||
| Databricks CLI v[CLI_VERSION] | ||
|
|
||
| >>> CODEX_CI=1 CODEX_THREAD_ID=thread-1 [CLI] version | ||
| Databricks CLI v[CLI_VERSION] | ||
| >>> CODEX_CI=1 CODEX_THREAD_ID=thread-1 [CLI] jobs list | ||
|
|
||
| >>> CODEX_CI=1 CODEX_THREAD_ID=thread-2 [CLI] version | ||
| >>> CODEX_CI=1 CODEX_THREAD_ID=thread-2 [CLI] jobs list | ||
| Databricks skills are not installed. To work with Databricks reliably, first run: databricks aitools install --agents codex --scope global | ||
| Databricks CLI v[CLI_VERSION] | ||
|
|
||
| === Cursor exposes no session id, so it is hinted once per machine | ||
|
|
||
| >>> CURSOR_AGENT=1 [CLI] version | ||
| >>> CURSOR_AGENT=1 [CLI] jobs list | ||
| Databricks skills are not installed. To work with Databricks reliably, first run: databricks aitools install --agents cursor --scope global | ||
| Databricks CLI v[CLI_VERSION] | ||
|
|
||
| >>> CURSOR_AGENT=1 [CLI] version | ||
| Databricks CLI v[CLI_VERSION] | ||
| >>> CURSOR_AGENT=1 [CLI] jobs list | ||
|
|
||
| === Copilot CLI maps to the copilot registry agent | ||
|
|
||
| >>> COPILOT_CLI=1 [CLI] version | ||
| >>> COPILOT_CLI=1 [CLI] jobs list | ||
| Databricks skills are not installed. To work with Databricks reliably, first run: databricks aitools install --agents copilot --scope global | ||
| Databricks CLI v[CLI_VERSION] | ||
|
|
||
| === Gemini CLI with its own Databricks skills is not hinted | ||
|
|
||
| >>> GEMINI_CLI=1 [CLI] version | ||
| Databricks CLI v[CLI_VERSION] | ||
| >>> GEMINI_CLI=1 [CLI] jobs list | ||
|
|
||
| === Agents the CLI cannot install for are not hinted | ||
|
|
||
| >>> WINDSURF_AGENT=1 [CLI] version | ||
| Databricks CLI v[CLI_VERSION] | ||
| >>> WINDSURF_AGENT=1 [CLI] jobs list | ||
|
|
||
| >>> VSCODE_AGENT=1 [CLI] version | ||
| Databricks CLI v[CLI_VERSION] | ||
| >>> VSCODE_AGENT=1 [CLI] jobs list | ||
|
|
||
| === Nested agents are not hinted | ||
|
|
||
| >>> CODEX_CI=1 CURSOR_AGENT=1 CODEX_THREAD_ID=thread-3 [CLI] version | ||
| Databricks CLI v[CLI_VERSION] | ||
| >>> CODEX_CI=1 CURSOR_AGENT=1 CODEX_THREAD_ID=thread-3 [CLI] jobs list |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,28 @@ | ||
| # aitools commands skip the install hint; version exercises it without auth or network. | ||
| # Hint-exempt commands such as aitools and version skip the install hint; jobs list | ||
| # exercises it against the fake server and prints nothing to stdout. | ||
| sethome ./home | ||
| unset XDG_CONFIG_HOME GEMINI_CLI_HOME CODEX_THREAD_ID | ||
|
|
||
| title "Codex is hinted once per thread" | ||
| trace CODEX_CI=1 CODEX_THREAD_ID=thread-1 $CLI version | ||
| trace CODEX_CI=1 CODEX_THREAD_ID=thread-1 $CLI version | ||
| trace CODEX_CI=1 CODEX_THREAD_ID=thread-2 $CLI version | ||
| trace CODEX_CI=1 CODEX_THREAD_ID=thread-1 $CLI jobs list | ||
| trace CODEX_CI=1 CODEX_THREAD_ID=thread-1 $CLI jobs list | ||
| trace CODEX_CI=1 CODEX_THREAD_ID=thread-2 $CLI jobs list | ||
|
|
||
| title "Cursor exposes no session id, so it is hinted once per machine" | ||
| trace CURSOR_AGENT=1 $CLI version | ||
| trace CURSOR_AGENT=1 $CLI version | ||
| trace CURSOR_AGENT=1 $CLI jobs list | ||
| trace CURSOR_AGENT=1 $CLI jobs list | ||
|
|
||
| title "Copilot CLI maps to the copilot registry agent" | ||
| trace COPILOT_CLI=1 $CLI version | ||
| trace COPILOT_CLI=1 $CLI jobs list | ||
|
|
||
| title "Gemini CLI with its own Databricks skills is not hinted" | ||
| sethome ./gemini-home | ||
| trace GEMINI_CLI=1 $CLI version | ||
| trace GEMINI_CLI=1 $CLI jobs list | ||
| sethome ./home | ||
|
|
||
| title "Agents the CLI cannot install for are not hinted" | ||
| trace WINDSURF_AGENT=1 $CLI version | ||
| trace VSCODE_AGENT=1 $CLI version | ||
| trace WINDSURF_AGENT=1 $CLI jobs list | ||
| trace VSCODE_AGENT=1 $CLI jobs list | ||
|
|
||
| title "Nested agents are not hinted" | ||
| trace CODEX_CI=1 CURSOR_AGENT=1 CODEX_THREAD_ID=thread-3 $CLI version | ||
| trace CODEX_CI=1 CURSOR_AGENT=1 CODEX_THREAD_ID=thread-3 $CLI jobs list |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,38 +1,57 @@ | ||
|
|
||
| === Plugin installed only in the custom config directory | ||
|
|
||
| >>> CLAUDE_CONFIG_DIR=custom [CLI] version | ||
| Databricks CLI v[CLI_VERSION] | ||
| >>> CLAUDE_CONFIG_DIR=custom [CLI] clusters list | ||
| ID Name State | ||
| 4321 some-test-cluster | ||
| 9876 some-other-cluster | ||
|
|
||
| === Custom directory takes precedence over the default installation | ||
|
|
||
| >>> CLAUDE_CONFIG_DIR=missing [CLI] version | ||
| >>> CLAUDE_CONFIG_DIR=missing [CLI] clusters list | ||
| <claude-code-hint v="1" type="plugin" value="databricks@claude-plugins-official" /> | ||
| Databricks skills are not installed. To work with Databricks reliably, first run: databricks aitools install | ||
| Databricks CLI v[CLI_VERSION] | ||
| ID Name State | ||
| 4321 some-test-cluster | ||
| 9876 some-other-cluster | ||
|
|
||
| === Exempt commands never hint, even without the tooling | ||
|
|
||
| >>> CLAUDE_CONFIG_DIR=missing [CLI] current-user me | ||
| json.userName = "[USERNAME]"; | ||
|
|
||
| === Empty override uses the default installation | ||
|
|
||
| >>> CLAUDE_CONFIG_DIR= [CLI] version | ||
| Databricks CLI v[CLI_VERSION] | ||
| >>> CLAUDE_CONFIG_DIR= [CLI] clusters list | ||
| ID Name State | ||
| 4321 some-test-cluster | ||
| 9876 some-other-cluster | ||
|
|
||
| === Unset override uses the default installation | ||
|
|
||
| >>> [CLI] version | ||
| Databricks CLI v[CLI_VERSION] | ||
| >>> [CLI] clusters list | ||
| ID Name State | ||
| 4321 some-test-cluster | ||
| 9876 some-other-cluster | ||
|
|
||
| === Outside a Claude Code subprocess only the text hint prints | ||
|
|
||
| >>> CLAUDE_CODE_CHILD_SESSION= [CLI] version | ||
| >>> CLAUDE_CODE_CHILD_SESSION= [CLI] clusters list | ||
| Databricks skills are not installed. To work with Databricks reliably, first run: databricks aitools install | ||
| Databricks CLI v[CLI_VERSION] | ||
| ID Name State | ||
| 4321 some-test-cluster | ||
| 9876 some-other-cluster | ||
|
|
||
| === Within one session both lines print once, so 2>&1 pipelines see them only on the first command | ||
|
|
||
| >>> [CLI] version | ||
| >>> [CLI] clusters list | ||
| <claude-code-hint v="1" type="plugin" value="databricks@claude-plugins-official" /> | ||
| Databricks skills are not installed. To work with Databricks reliably, first run: databricks aitools install | ||
| Databricks CLI v[CLI_VERSION] | ||
|
|
||
| >>> [CLI] version | ||
| Databricks CLI v[CLI_VERSION] | ||
| ID Name State | ||
| 4321 some-test-cluster | ||
| 9876 some-other-cluster | ||
|
|
||
| >>> [CLI] clusters list | ||
| ID Name State | ||
| 4321 some-test-cluster | ||
| 9876 some-other-cluster |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,11 +48,6 @@ const ( | |
| // unattended runs. | ||
| ciEnv = "CI" | ||
|
|
||
| // aiToolsCommandName is the top-level command whose subtree is never hinted: | ||
| // telling the agent to run `databricks aitools install` while it is already | ||
| // running an aitools command makes no sense. | ||
| aiToolsCommandName = "aitools" | ||
|
|
||
| // authCommandName and tokenCommandName name `databricks auth token`, the | ||
| // credential helper the SDKs and Terraform run. They embed its stderr | ||
| // mid-line in their own errors, where Claude Code can't strip the native | ||
|
|
@@ -171,9 +166,10 @@ func (h *agentHint) nativeLine(ctx context.Context) string { | |
|
|
||
| // MaybeHint recommends installing the Databricks AI tooling when a supported | ||
| // agent drives the CLI without it installed. It is a no-op for human callers, | ||
| // unsupported agents, aitools commands themselves, the `auth token` and `auth | ||
| // docker token` credential helpers, a CLI process the CLI started itself, when | ||
| // there is no output stream, and once the tooling is present. | ||
| // unsupported agents, hint-exempt commands (isHintExemptCommand), the `auth | ||
| // token` and `auth docker token` credential helpers, a CLI process the CLI | ||
| // started itself, when there is no output stream, and once the tooling is | ||
| // present. | ||
| // Both lines, the agent-native one (if any) and the model-facing text, and | ||
| // their hint-shown events are throttled together per session, or per agent on | ||
| // this machine for agents without a session id (fallbackKey). | ||
|
|
@@ -187,7 +183,7 @@ func MaybeHint(ctx context.Context, cmd *cobra.Command, pluginRecorded PluginRec | |
| if hint == nil { | ||
| return | ||
| } | ||
| if isAIToolsCommand(cmd) { | ||
| if isHintExemptCommand(cmd) { | ||
| return | ||
| } | ||
| if isCredentialHelperCommand(cmd) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nit] Under the real |
||
|
|
@@ -278,11 +274,33 @@ func isCredentialHelperCommand(cmd *cobra.Command) bool { | |
| return parent != nil && parent.Name() == authCommandName | ||
| } | ||
|
|
||
| // isAIToolsCommand reports whether cmd is the aitools command or one of its | ||
| // subcommands, walking the parent chain (mirrors versioncheck.isExemptCommand). | ||
| func isAIToolsCommand(cmd *cobra.Command) bool { | ||
| for c := cmd; c != nil; c = c.Parent() { | ||
| if c.Name() == aiToolsCommandName { | ||
| // hintExemptCommands are the commands, with their subcommands, on which no | ||
| // tooling hint prints. Paths are relative to the root command. The aitools | ||
| // trees are exempt because telling the agent to run aitools while it already | ||
| // runs aitools makes no sense. The rest are plumbing or one-shot lookups (auth | ||
| // checks, "who am I", version, help, shell completion): the agent has no task | ||
| // to apply the skills to. The nudge eval measured only "who am I": 0 of 20 | ||
| // runs installed the tooling. | ||
| var hintExemptCommands = []string{ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nice to have] The entries in
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd rather not add this one. |
||
| "aitools", | ||
| "experimental aitools", | ||
| "auth", | ||
| "configure", | ||
| "current-user me", | ||
| "version", | ||
| "completion", | ||
| "help", | ||
| cobra.ShellCompRequestCmd, | ||
| } | ||
|
|
||
| // isHintExemptCommand reports whether cmd is one of hintExemptCommands or a | ||
| // subcommand of one. | ||
| func isHintExemptCommand(cmd *cobra.Command) bool { | ||
| path := cmd.CommandPath() | ||
| root := cmd.Root().CommandPath() | ||
| for _, exempt := range hintExemptCommands { | ||
| full := root + " " + exempt | ||
| if path == full || strings.HasPrefix(path, full+" ") { | ||
| return true | ||
| } | ||
| } | ||
|
|
@@ -367,8 +385,7 @@ func SelfExecEnv(environ []string) []string { | |
| // ExecutionContext.Command names the command the hint was shown on. | ||
| // | ||
| // The event is buffered and uploaded by cmd/root at exit, which needs resolved | ||
| // auth: a hint shown on a command that never resolves auth (e.g. `databricks | ||
| // version`) is not uploaded. | ||
| // auth: a hint shown on a command that never resolves auth is not uploaded. | ||
| func logHintShown(ctx context.Context, kind protos.AitoolsHintKind) { | ||
| telemetry.Log(ctx, protos.DatabricksCliLog{ | ||
| AitoolsHintEvent: &protos.AitoolsHintEvent{HintKind: kind}, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit]
.agents/rules/testing.mdasks for noisy output to go toLOG.<name>, not/dev/null, so it stays visible undergo test -v. Usetrace $CLI bundle schema > LOG.schema; the golden still shows only the hint on stderr.