Skip to content

aitools: don't hint an install that auto-install is about to make - #7890

Open
anton-107 wants to merge 4 commits into
mainfrom
skip-install-hint-before-auto-install
Open

anton-107 wants to merge 4 commits into
mainfrom
skip-install-hint-before-auto-install

Conversation

@anton-107

Copy link
Copy Markdown
Contributor

Changes

When a coding agent runs the CLI, the CLI can print the "Databricks skills are not installed" hint before the command. On the same command, the auto-install that runs afterwards can install those skills for that agent. The agent then sees two lines that disagree: one tells it to run databricks aitools install, and the next says the tools were just installed.

With this change, the hint is skipped when the auto-install after the command is due to give that agent its first tools.

 MaybeHint(ctx, cmd)
   if hint.installed(ctx)
     return
+  if autoinstall.InstallsFor(cmd, hint.agentName)
+    return            // no event, no throttle marker
   claim throttle, print hint, log hint event
  • libs/aitools/autoinstall/hook.go: new hook InstallsFor(cmd, agentName), next to Run. main.go sets it to aitools.AutoInstallsFor, the same way Run is set, so libs/aitools/agents does not import cmd/aitools.
  • cmd/aitools/autoinstall_hint.go: AutoInstallsFor makes the same decision as autoInstall. It runs the state-free skips, loads the state and checks that Decide reaches the gate lookup. Then it plans the install and reports whether this agent is one of the plan's new agents. It reads the state but never writes it, and it does not fetch the compatibility manifest.
  • cmd/aitools/autoinstall_run.go: moves the building of autoinstall.Inputs into autoInstallInputs so both callers use it. Behavior is unchanged.
  • libs/aitools/agents: each agentHint now carries the agent's registry name so the hint can ask about it. This covers Claude Code and the registry agents.

Why

The hint runs before the command, but the gate is only fetched afterwards, so the check stops at the point where autoInstall would fetch it. A run that gets that far counts as installing, and its hint is withheld. If that run then installs nothing (for example, because the gate is off), the hint was not printed and no throttle marker was written. The next command prints the hint as usual. This costs one command of delay and avoids a network call before every command.

An agent that the install skips, such as Claude Code with no config dir, still gets the hint on the same command.

Tests

  • TestAutoInstallsFor (cmd/aitools) covers:

    • first run, retry and fresh state, which install;
    • an agent without a config dir;
    • a settled version, exhausted retries, opt-out in state and opt-out in env;
    • CI, a development build and a command that skips auto-install;
    • a corrupt install state, where planning fails.

    Each case also checks that the gate is never fetched, the state file is unchanged and nothing is installed.

  • libs/aitools/agents:

    • TestMaybeHint_WithheldWhileAutoInstallInstallsForTheAgent: both hint lines are withheld and no event is logged. When the next command does not install, it prints the hint.
    • TestMaybeHint_RegistryAgentAskedByItsName: a registry agent is asked about by its own name.
    • TestMaybeHint_InstalledToolingSkipsTheAutoInstallCheck: when the tooling is already installed, the hook is not called.
  • New acceptance test acceptance/cmd/aitools/auto-install/agent-hint covers four cases:

    • the first run prints only the install notice;
    • the second run prints nothing;
    • with the gate off, the first run prints nothing and the next prints the hint;
    • an agent the install skips still gets the hint next to the install notice.

Changelog fragment: .nextchanges/cli/aitools-auto-install-hint-contradiction.md.

## Changes

When a coding agent runs the CLI, the CLI can print the "Databricks skills are not installed" hint before the command. On the same command, the auto-install that runs afterwards can install those skills for that agent. The agent then sees two lines that disagree: one tells it to run `databricks aitools install`, and the next says the tools were just installed.

With this change, the hint is skipped when the auto-install after the command is due to give that agent its first tools.

```diff
 MaybeHint(ctx, cmd)
   if hint.installed(ctx)
     return
+  if autoinstall.InstallsFor(cmd, hint.agentName)
+    return            // no event, no throttle marker
   claim throttle, print hint, log hint event
```

- `libs/aitools/autoinstall/hook.go`: new hook `InstallsFor(cmd, agentName)`, next to `Run`. `main.go` sets it to `aitools.AutoInstallsFor`, the same way `Run` is set, so `libs/aitools/agents` does not import `cmd/aitools`.
- `cmd/aitools/autoinstall_hint.go`: `AutoInstallsFor` makes the same decision as `autoInstall`. It runs the state-free skips, loads the state and checks that `Decide` reaches the gate lookup. Then it plans the install and reports whether this agent is one of the plan's new agents. It reads the state but never writes it, and it does not fetch the compatibility manifest.
- `cmd/aitools/autoinstall_run.go`: moves the building of `autoinstall.Inputs` into `autoInstallInputs` so both callers use it. Behavior is unchanged.
- `libs/aitools/agents`: each `agentHint` now carries the agent's registry name so the hint can ask about it. This covers Claude Code and the registry agents.

## Why

The hint runs before the command, but the gate is only fetched afterwards, so the check stops at the point where `autoInstall` would fetch it. A run that gets that far counts as installing, and its hint is withheld. If that run then installs nothing (for example, because the gate is off), the hint was not printed and no throttle marker was written. The next command prints the hint as usual. This costs one command of delay and avoids a network call before every command.

An agent that the install skips, such as Claude Code with no config dir, still gets the hint on the same command.

## Tests

- `TestAutoInstallsFor` (`cmd/aitools`) covers:
  - first run, retry and fresh state, which install;
  - an agent without a config dir;
  - a settled version, exhausted retries, opt-out in state and opt-out in env;
  - CI, a development build and a command that skips auto-install;
  - a corrupt install state, where planning fails.

  Each case also checks that the gate is never fetched, the state file is unchanged and nothing is installed.
- `libs/aitools/agents`:
  - `TestMaybeHint_WithheldWhileAutoInstallInstallsForTheAgent`: both hint lines are withheld and no event is logged. When the next command does not install, it prints the hint.
  - `TestMaybeHint_RegistryAgentAskedByItsName`: a registry agent is asked about by its own name.
  - `TestMaybeHint_InstalledToolingSkipsTheAutoInstallCheck`: when the tooling is already installed, the hook is not called.
- New acceptance test `acceptance/cmd/aitools/auto-install/agent-hint` covers four cases:
  - the first run prints only the install notice;
  - the second run prints nothing;
  - with the gate off, the first run prints nothing and the next prints the hint;
  - an agent the install skips still gets the hint next to the install notice.

Changelog fragment: `.nextchanges/cli/aitools-auto-install-hint-contradiction.md`.

Co-authored-by: Isaac <no-reply@databricks.com>
@anton-107
anton-107 requested review from a team and lennartkats-db as code owners November 23, 2026 19:46
@github-actions github-actions Bot added the aitools AI tools (databricks aitools) related changes label Nov 23, 2026

@review-oss-bot review-oss-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review at 24b61a7. Each finding was verified against the code.

Not ready yet: 1 blocking issue(s), tagged [blocking].

This PR withholds the "Databricks skills are not installed" hint when the auto-install after the command is expected to install tools for the calling agent. The check guesses in the pre-run hook what the post-run install will do, and several real outcomes are guessed wrong. A command that fails never reaches the install, so the hint stays withheld on every failing command. Failed install attempts and holdout machines also lose the hint without getting an install in return. The first case should be fixed before merge, and the changelog fragment needs its PR link.

// The auto-install after this command prints its own notice; neither line
// may tell the agent to install what it installs. No marker is written, so
// a run that ends up not installing leaves the hint to the next command.
if autoinstall.InstallsFor != nil && autoinstall.InstallsFor(cmd, hint.agentName) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[blocking] MaybeHint runs in PersistentPreRunE, but autoinstall.Run runs only from PersistentPostRunE, which Cobra calls only when the command succeeds (cmd/root/root.go:113). When the command fails, nothing installs and auto-install.json is not written, so the next command gets the same answer and the hint is withheld again. Example: on a new CLI version, Claude Code with ~/.claude present runs databricks jobs list with no auth configured. Every call errors, and the agent never sees the hint until some command succeeds. Before this change it got the hint on the first command. This contradicts "the next command prints the hint" in the InstallsFor doc. Can the withheld hint be printed when the command fails (for example from the error path), or can the check be limited to runs that will reach the post-run hook?

}
var err error
in.State, err = autoinstall.Load(ctx)
if err != nil || autoinstall.Decide(in) != autoinstall.ReasonGateOff {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nice to have] Decide returns ReasonGateOff for any 0 < Attempts < MaxAttempts, so a retry after a failed attempt counts as installing (the "a retry installs too" case). A failed attempt prints "Could not install" only when asked, and coding agents are never asked. So with the gate on and the release download blocked or timing out, an agent can run up to 10 successful commands with neither the hint nor any install notice. Should this withhold the hint only on the version's first attempt (in.State.LastVersion != in.Version), so a failed attempt lets the hint through on the next command?

}
var err error
in.State, err = autoinstall.Load(ctx)
if err != nil || autoinstall.Decide(in) != autoinstall.ReasonGateOff {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nice to have] in.Bucket is never set here, and Decide checks the holdout only after the gate. So a holdout machine counts as installing, has its hint withheld, and is then settled as SKIPPED_HOLDOUT with nothing installed. On every new version the 10% control arm loses a hint the status quo would have shown, which skews the comparison the holdout exists for. When in.State.ID is set, the bucket is already known locally. Can this return false when autoinstall.InHoldout(autoinstall.Bucket(in.State.ID))?

@@ -0,0 +1 @@
* A coding agent no longer gets the "Databricks skills are not installed" hint on a command after which the automatic installation of Databricks AI tools installs them for that agent, so its output no longer tells it to install what the same command installs. When that installation does not happen, the hint appears on the next command.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nice to have] .nextchanges/README.md requires a trailing PR link such as ([#NNNN](https://github.com/databricks/cli/pull/NNNN)), and task check-changelog fails without it. The entry is also long for a single changelog line. Something like "Coding agents no longer get the install hint on a command whose automatic installation of Databricks AI tools installs them for that agent." would do. Can you shorten it and add the link?

Co-authored-by: Isaac <no-reply@databricks.com>
@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Commit: cb5377dad | Workflow run

Regression test report

Selected 1 changed tests (limit=20, 0 not selected)

1 tests: regression=1 unreleased=0 coverage=0 failing=0
test branch main (1ea5591) latest (v1.27.0)
TestAccept/cmd/aitools/auto-install/agent-hint ✅ ❌ ❌
TestAccept/cmd/aitools/auto-install/agent-hint: branch ✅ | main (1ea5591) ❌ | latest (v1.27.0) ❌

main (1ea5591):

acceptance_test.go:1270: Substituted DATABRICKS_CLI_GITHUB_API_URL "$DATABRICKS_HOST" -> "http://127.0.0.1:37509" ("[DATABRICKS_HOST]")
    acceptance_test.go:1270: Substituted DATABRICKS_SKILLS_BASE_URL "$DATABRICKS_HOST" -> "http://127.0.0.1:37509" ("[DATABRICKS_HOST]")
    acceptance_test.go:1402: Diff:
        --- cmd/aitools/auto-install/agent-hint/output.txt
        +++ /tmp/TestAcceptcmdaitoolsauto-installagent-hint3701063300/002/output.txt
        @@ -2,8 +2,8 @@
         === a failing command: no install, the hint once the command ends
         
         >>> CLAUDECODE=1 [CLI] jobs get abc
        -Error: invalid JOB_ID: abc
         Databricks skills are not installed. To work with Databricks reliably, first run: databricks aitools install
        +Error: invalid JOB_ID: abc
         
         Exit code: 1
         
        @@ -13,9 +12,11 @@
         === first run of a new version: the install notice, no install hint
         
         >>> CLAUDECODE=1 [CLI] jobs list
        +Databricks skills are not installed. To work with Databricks reliably, first run: databricks aitools install
         Installed Databricks AI tools for Claude Code, Cursor. Disable: databricks aitools auto-install disable
         
         >>> print_telemetry
        +{"command":"jobs_list","exit_code":0,"aitools_hint_event":{"hint_kind":"INSTALL_TEXT"}}
         {"command":"jobs_list","exit_code":0,"aitools_install_event":{"agents":["CLAUDE_CODE","CURSOR"],"scope":"GLOBAL","error_category":"TYPE_UNSPECIFIED","agent_results":[{"agent":"CLAUDE_CODE","error_category":"CLI_NOT_ON_PATH"}],"trigger":"AUTO_FIRST_RUN"}}
         {"command":"jobs_list","exit_code":0,"aitools_auto_install_event":{"outcome":"INSTALLED","holdout_arm":"TREATMENT","interactive":false}}
         
        
FAIL

latest (v1.27.0):

acceptance_test.go:1270: Substituted DATABRICKS_CLI_GITHUB_API_URL "$DATABRICKS_HOST" -> "http://127.0.0.1:38855" ("[DATABRICKS_HOST]")
    acceptance_test.go:1270: Substituted DATABRICKS_SKILLS_BASE_URL "$DATABRICKS_HOST" -> "http://127.0.0.1:38855" ("[DATABRICKS_HOST]")
    acceptance_test.go:1402: Diff:
        --- cmd/aitools/auto-install/agent-hint/output.txt
        +++ /tmp/TestAcceptcmdaitoolsauto-installagent-hint2543440491/002/output.txt
        @@ -2,8 +2,8 @@
         === a failing command: no install, the hint once the command ends
         
         >>> CLAUDECODE=1 [CLI] jobs get abc
        -Error: invalid JOB_ID: abc
         Databricks skills are not installed. To work with Databricks reliably, first run: databricks aitools install
        +Error: invalid JOB_ID: abc
         
         Exit code: 1
         
        @@ -13,9 +12,11 @@
         === first run of a new version: the install notice, no install hint
         
         >>> CLAUDECODE=1 [CLI] jobs list
        +Databricks skills are not installed. To work with Databricks reliably, first run: databricks aitools install
         Installed Databricks AI tools for Claude Code, Cursor. Disable: databricks aitools auto-install disable
         
         >>> print_telemetry
        +{"command":"jobs_list","exit_code":0,"aitools_hint_event":{"hint_kind":"INSTALL_TEXT"}}
         {"command":"jobs_list","exit_code":0,"aitools_install_event":{"agents":["CLAUDE_CODE","CURSOR"],"scope":"GLOBAL","error_category":"TYPE_UNSPECIFIED","agent_results":[{"agent":"CLAUDE_CODE","error_category":"CLI_NOT_ON_PATH"}],"trigger":"AUTO_FIRST_RUN"}}
         {"command":"jobs_list","exit_code":0,"aitools_auto_install_event":{"outcome":"INSTALLED","holdout_arm":"TREATMENT","interactive":false}}
         
        
FAIL

Comment thread libs/aitools/agents/hint.go Resolved
Comment thread cmd/aitools/autoinstall_hint.go Resolved
if err != nil {
return false
}
for _, it := range tools.plan {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[non-blocking] An update plan has no items, so this returns false when the global install predates the calling agent. With tools installed for Cursor only and ~/.claude created later, an upgrade that updates a skill still prints the hint followed by "Updated Databricks AI tools for Claude Code, Cursor" on the same command. Is the update path meant to be out of scope? If so, can the doc comment say it?

@eng-dev-ecosystem-bot

eng-dev-ecosystem-bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Integration test report

Commit: cb5377d

Run: 45268395058

Env 💚​RECOVERED ✅​pass 🙈​skip Time
💚​ aws linux-2core-8gb 1 272 20 15:38
💚​ aws-windows-latest-4core-16gb 1 274 18 10:32
💚​ azure linux-2core-8gb 1 271 20 15:07
💚​ azure-windows-latest-4core-16gb 1 273 18 12:53
💚​ gcp linux-2core-8gb 1 272 20 12:58
💚​ gcp-windows-latest-4core-16gb 1 274 18 8:46
Test Name aws linux-2core-8gb aws-windows-latest-4core-16gb azure linux-2core-8gb azure-windows-latest-4core-16gb gcp linux-2core-8gb gcp-windows-latest-4core-16gb
💚​ TestAccept 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
Top 32 slowest tests (at least 2 minutes):
duration env testname
4:30 aws linux-2core-8gb TestFilerWorkspaceFilesExtensionsDelete
4:08 azure-windows-latest-4core-16gb TestFilerWorkspaceFilesExtensionsReadDir
4:02 gcp-windows-latest-4core-16gb TestFilerWorkspaceNotebook/scalaJupyterNb.ipynb
4:00 aws linux-2core-8gb TestAccept
3:59 aws-windows-latest-4core-16gb TestAccept
3:56 azure linux-2core-8gb TestAccept
3:47 azure-windows-latest-4core-16gb TestAccept
3:33 aws-windows-latest-4core-16gb TestFilerWorkspaceFilesExtensionsRead
3:30 gcp linux-2core-8gb TestAccept
3:21 gcp linux-2core-8gb TestFilerWorkspaceFilesExtensionsReadDir
3:09 gcp-windows-latest-4core-16gb TestFilerWorkspaceFilesExtensionsRead
3:08 gcp-windows-latest-4core-16gb TestAccept
3:02 aws linux-2core-8gb TestFilerRecursiveDelete/workspace_files_extensions
2:58 gcp-windows-latest-4core-16gb TestFilerWorkspaceFilesExtensionsReadDir
2:45 aws linux-2core-8gb TestExportDirDoesNotOverwrite
2:40 azure-windows-latest-4core-16gb TestImportDirDoesNotOverwrite
2:34 azure linux-2core-8gb TestImportDirWithOverwriteFlag
2:29 azure-windows-latest-4core-16gb TestExportDir
2:22 gcp-windows-latest-4core-16gb TestImportDirWithOverwriteFlag
2:21 azure-windows-latest-4core-16gb TestFilerReadWrite/workspace_files
2:17 aws-windows-latest-4core-16gb TestFilerRecursiveDelete/workspace_files_extensions
2:11 aws-windows-latest-4core-16gb TestImportDirDoesNotOverwrite
2:11 azure linux-2core-8gb TestFilerWorkspaceFilesExtensionsStat
2:11 azure-windows-latest-4core-16gb TestFilerWorkspaceFilesExtensionsRead
2:08 aws linux-2core-8gb TestFilerWorkspaceNotebook/pythonJupyterNb.ipynb
2:08 aws linux-2core-8gb TestFilerReadWrite/workspace_files
2:05 azure linux-2core-8gb TestSyncIncrementalFileSync
2:04 gcp linux-2core-8gb TestExportDir
2:02 aws-windows-latest-4core-16gb TestFilerWorkspaceNotebook/sqlNb.sql
2:01 aws-windows-latest-4core-16gb TestFilerWorkspaceFilesExtensionsDelete
2:01 aws-windows-latest-4core-16gb TestExportDir
2:00 gcp linux-2core-8gb TestFilerRecursiveDelete/workspace_files

@simonfaltum simonfaltum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Automated review from simonfaltum's review agent (pr-review skill) at b117245. Each finding was verified against the code; simonfaltum may follow up.

Not approving yet: 1 blocking issue(s), tagged [blocking].

This PR withholds the "Databricks skills are not installed" hint when the auto-install after the command is predicted to give the calling agent its first tools, which fixes the contradiction on a successful first install. The prediction is made before the command, but auto-install runs only after a command that succeeded. So on a failing command the hint is withheld and nothing installs, and every later failing command does the same; this is the blocking item, already raised in an open thread. Failed retries, holdout machines and the update path are smaller gaps in the same prediction. Deciding the hint after the command, from what auto-install actually did, may close all of them at once.

Questions

  1. AutoInstallsFor repeats the first half of autoInstall (state-free skips, Load, Decide, planTools, newAgents) to predict, before the command runs, what the post-run hook will do. Any later change to how autoInstall decides has to be copied here, or the hint and the install disagree again; the holdout, retry and failed-command gaps are cases where the copy already differs. Would it be simpler to decide the hint after the command, from what auto-install actually did? Or should both callers use one shared decision helper? (non-blocking)

Agreeing with existing threads

  • [blocking] The hint is withheld on every failing command, with no install to replace it: #7890 (comment)
  • [nice to have] Failed install retries withhold the hint with no notice: #7890 (comment)
  • [nice to have] Holdout machines lose the first-command hint: #7890 (comment)
  • [nice to have] The update path still prints the hint next to "Updated … for ": #7890 (comment)

anton-107 and others added 2 commits November 23, 2026 20:50
Co-authored-by: Isaac <no-reply@databricks.com>
Auto-install runs only after a command succeeded, and its gate lookup or
install can still end without tools. The hint withheld for it now prints
when the command ends unless the agent has the tools by then, so a failing
command still gets it. A holdout machine is not withheld from, and an
update counts as installing for every agent with a config directory.

Co-authored-by: Isaac <no-reply@databricks.com>
@anton-107
anton-107 requested a review from a team as a code owner November 23, 2026 21:17

This branch has not been deployed

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

Labels

aitools AI tools (databricks aitools) related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants