Repository navigation
aitools: auto-install requires explicit or inferred consent - #8135
Conversation
## Changes Automatic installation of the Databricks AI tools now runs only after explicit or inferred consent, and it no longer asks anything after a command. - **Explicit consent** comes from `databricks aitools auto-install enable`, a global-scope `databricks aitools install`, or a "yes" to the skills prompt of `databricks apps init`. - **Inferred consent** comes from an existing global installation that the CLI made, meaning one that has install state. A run that finds one stores the consent. Skills without install state and project-scope installations don't count, and neither does a run in CI or one where `DATABRICKS_AITOOLS_AUTO_INSTALL` turns auto-install off. - With no consent stored, `Decide` returns a new reason, `no_consent`. This check runs after the CI and opt-out checks, so those still settle the version and are reported. A `no_consent` run doesn't look up the gate, installs nothing, sends no auto-install event and leaves the version unsettled, so the first run after consent can install. - The install prompt and its supporting code are gone: `ask`, `decline`, `skipUnaskable`, `canAsk`, the container check, `State.AcceptedVersion` and `State.InstalledWithoutConsent`. The helpers in `libs/cmdio` that only the prompt used are gone too: `IsLinePromptSupported`, `SupportsLinePrompt`, `MarkStdinReadInBackground`, `DiscardInput` and the per-OS foreground-process checks. - `AutoInstallsFor`, which decides whether the agent install hint moves to the end of a command, applies the same inferred-consent check without writing anything. This keeps the hint in step with what the run actually does. - The notice after an install or update now also names the removal command: `Turn off: databricks aitools auto-install disable. Remove: databricks aitools uninstall`. - The `DECLINED` and `UNANSWERED` telemetry outcomes are kept in the proto but documented as no longer sent. The telemetry README is updated to match. - The `auto-install` help text and the `enable` short description describe the new behavior. ## Why Before this change, a run with no coding agent asked before the first install. A coding agent's run installed without asking anyone. This change replaces both paths with one rule: install only once consent is stored, whether given explicitly or inferred from a CLI-made global installation. Without the prompt, a lot of fragile terminal handling also goes away. That code dealt with detecting the foreground process group, discarding typed-ahead input, background stdin readers and containers whose terminal never delivers an answer. ## Tests - Unit tests in `cmd/aitools` and `libs/aitools/autoinstall` cover installing with consent, skipping without it, and installing on the same version once consent is given. They also cover inferred consent from a CLI-made global installation and the new `no_consent` reason in `Decide`. The prompt tests and container tests are removed. - New acceptance test `acceptance/cmd/aitools/auto-install/no-consent`: a coding agent's call with no consent installs nothing, leaves the stored state unchanged, sends no auto-install event, doesn't read the manifest, and still shows the agent the install hint. After `databricks aitools auto-install enable`, the next command of the same version installs. - The existing auto-install acceptance cases (`agent-hint`, `first-run`, `no-terminal`, `retries`, `skipped`, `upgrade`) now run `auto-install enable` before the cases that install, and their outputs are regenerated. `skipped` checks that CI and the opt-outs are still reported before any consent exists. `upgrade` adds a case where a global installation made by an earlier CLI counts as consent. - Changelog fragment: `.nextchanges/cli/aitools-auto-install-consent.md`. Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
Regression test report ✅Commit: Selected 7 changed tests (limit=20, 0 not selected) 7 tests: regression=7 unreleased=0 coverage=0 failing=0
TestAccept/cmd/aitools/auto-install/agent-hint: branch ✅ | main (cfd268f) ❌ | latest (v1.28.0) ❌main (cfd268f): latest (v1.28.0): TestAccept/cmd/aitools/auto-install/first-run: branch ✅ | main (cfd268f) ❌ | latest (v1.28.0) ❌main (cfd268f): latest (v1.28.0): TestAccept/cmd/aitools/auto-install/no-consent: branch ✅ | main (cfd268f) ❌ | latest (v1.28.0) ❌main (cfd268f): latest (v1.28.0): TestAccept/cmd/aitools/auto-install/no-terminal: branch ✅ | main (cfd268f) ❌ | latest (v1.28.0) ❌main (cfd268f): latest (v1.28.0): TestAccept/cmd/aitools/auto-install/retries: branch ✅ | main (cfd268f) ❌ | latest (v1.28.0) ❌main (cfd268f): latest (v1.28.0): 2 more failure details omitted, see the full report in the run. |
There was a problem hiding this comment.
Automated review at 52c05f0. Each finding was verified against the code.
No blocking issues found. 4 non-blocking comment(s) below.
This PR replaces the post-command install prompt with a consent gate. Auto-install now runs only after auto-install enable, a global install, a "yes" in apps init, or when it finds an existing CLI-made global installation, and the prompt's terminal-handling code is removed. The gating logic looks consistent. Two first-run acceptance cases were regenerated into no-ops instead of being given consent. The new notice's uninstall hint fails when a project-scope install also exists. The changelog fragment is missing the PR link that check-changelog requires. One new unit test repeats the new no-consent acceptance case.
|
|
||
| >>> settled_version | ||
| {"last_version":"1.30.0","installed_without_consent":true} | ||
| {} |
There was a problem hiding this comment.
[nice to have] use_home hand-placed-home and use_home own-skill-home start with no consent, and the script never runs auto-install enable for them, so both runs now stop at no_consent. The regenerated golden accepted that: no KEPT outcome, settled_version is {}, and the own-skill case (lines 66-71) prints no notice and installs no databricks-test. The titles still say "kept … not retried" and "installs", and the hand-placed refusal has no acceptance coverage left. Can you add trace $CLI aitools auto-install enable after each of those use_home calls, as agent-hint and skipped do, and regenerate?
| const autoInstallDisable = "databricks aitools auto-install disable" | ||
| // autoInstallNoticeCommands is the end of the notice: how to turn auto-install | ||
| // off and how to remove what it installed. | ||
| const autoInstallNoticeCommands = "Turn off: databricks aitools auto-install disable. Remove: databricks aitools uninstall" |
There was a problem hiding this comment.
[nice to have] Say a project-scope install exists in the current directory. A coding agent or other non-interactive caller that runs the advertised databricks aitools uninstall gets the "installed in both global and project scopes" error from resolveScopeForUninstall. A person at a terminal gets a scope picker where they can choose the project scope. In both cases the command doesn't remove what auto-install installed. Can the notice say databricks aitools uninstall --scope=global, since auto-install only ever installs in global scope?
| @@ -0,0 +1 @@ | |||
| * The automatic installation of Databricks AI tools now runs only after explicit consent or when an existing CLI-managed global installation is found. Explicit consent is `databricks aitools auto-install enable`, a global `databricks aitools install`, or a "yes" to the skills prompt of `databricks apps init`. If you ran `databricks aitools auto-install enable` with an earlier CLI version and have no global installation that the CLI made, run it again: before, it only undid `disable` and did not record an agreement. With such an installation, the CLI infers the consent automatically. It no longer asks anything after a command, and its notice now also names `databricks aitools uninstall`. | |||
There was a problem hiding this comment.
[nice to have] .nextchanges/README.md requires a trailing ([#NNNN](https://github.com/databricks/cli/pull/NNNN)) link after the final period, and task check-changelog fails on this PR without it. Can you add it? You could also trim the entry while you're there: it's long for one bullet.
| assert.NotContains(t, stderr.String(), "Install Databricks AI tools") | ||
| // A machine whose user agrees after a run of a version installs on the next | ||
| // run of that version: the run without the consent left the version unsettled. | ||
| func TestAutoInstallAfterConsentOnTheSameVersion(t *testing.T) { |
There was a problem hiding this comment.
[nit] TestAutoInstallAfterConsentOnTheSameVersion makes the same checks as the second phase of the new acceptance/cmd/aitools/auto-install/no-consent test. First a run without consent leaves the state alone, then consent is stored, then the next run of the same version installs and stores {last_version: 1.30.0, consented: true}. .agents/rules/testing.md asks not to add a unit test that only duplicates an acceptance test. Can you drop it, or narrow it to something the acceptance test can't see?
✅ Integration test reportCommit: 7c4f67e
Top 6 slowest tests (at least 2 minutes):
|
rugpanov
left a comment
There was a problem hiding this comment.
Thanks for the changelog fix. All checks pass now. I have one question that can affect the consent rule, and two smaller points.
[nice to have] .nextchanges/cli/aitools-auto-install-keeps-hand-placed-skills.md (from #8071, not released yet) says "if you answered yes to the install question, it prints which skill it kept and the command that replaces it". This PR removes that question and that message. Then the next release notes describe a behavior that never ships. Remove that clause from the fragment in this PR.
The review-oss-bot comments on the first-run acceptance cases and on the uninstall notice are still open at this head.
Risk: HIGH. The change ships in the CLI binary and runs in the post-command hook after every successful command, so a defect reaches all users and a fix needs a new release. It also deletes shared terminal and prompt helpers in libs/cmdio and edits AskCancellable and the apps vite bridge. The install path itself stays behind the remote per-version gate and becomes more conservative.
| // in CI or with auto-install turned off in the environment does not count it. | ||
| // It only reads. | ||
| func existingInstallConsents(ctx context.Context, in autoinstall.Inputs) bool { | ||
| if in.CI || in.EnvOptOut || in.State.Consent() != autoinstall.ConsentUnknown { |
There was a problem hiding this comment.
[Question] Is it intended that install state from v1.28.0 counts as consent here? v1.28.0 installs for a coding agent's run without a question, and it writes no marker for that. Also, main skipped this inference when State.Installing was true. This PR removes that guard and its tests. So an unfinished v1.28.0 agent install (installing: true plus a global .state.json) now becomes consented: true. The answer matters because the goal of the PR is no install that the user did not agree to. If the remote gate was never on for v1.28.0, no such state exists, and the point does not apply.
| ReasonRetriesExhausted Reason = "retries_exhausted" | ||
| ReasonRetryNotDue Reason = "retry_not_due" | ||
| // The user never agreed to installing the tools. The version is left | ||
| // unsettled, so the first run after the user agrees installs. |
There was a problem hiding this comment.
[nit] This comment is true only for a run that stops at ReasonNoConsent. A CI run or a DATABRICKS_AITOOLS_AUTO_INSTALL=false run settles the version first. After that, ReasonAlreadyRan comes before the consent check, so auto-install enable on the same version installs nothing until the next version. Say this in the comment. If the first run after enable must install, check consent before ReasonAlreadyRan.
…icks-not-an-agent-makes-the-cli-ac Keeps main's removal of the auto-install prompt (#8135). The interactive flag now reads agent.Provider, so DATABRICKS_NOT_AN_AGENT keeps it off. Co-authored-by: Isaac <no-reply@databricks.com>
Main removed the auto-install consent prompt (#8135). Keep main's side of the auto-install run, and keep only the early return for the agent features switch at the top of AutoInstall, before the state is read. The seeded state in the disabled case now keeps its consent, and the disabled acceptance case seeds consent first, so the disabled run is shown to install nothing even with consent given. Co-authored-by: Isaac <no-reply@databricks.com>
Changes
Automatic installation of the Databricks AI tools now runs only after explicit or inferred consent, and it no longer asks anything after a command.
databricks aitools auto-install enable, a global-scopedatabricks aitools install, or a "yes" to the skills prompt ofdatabricks apps init.DATABRICKS_AITOOLS_AUTO_INSTALLturns auto-install off.Decidereturns a new reason,no_consent. This check runs after the CI and opt-out checks, so those still settle the version and are reported. Ano_consentrun doesn't look up the gate, installs nothing, sends no auto-install event and leaves the version unsettled, so the first run after consent can install.ask,decline,skipUnaskable,canAsk, the container check,State.AcceptedVersionandState.InstalledWithoutConsent. The helpers inlibs/cmdiothat only the prompt used are gone too:IsLinePromptSupported,SupportsLinePrompt,MarkStdinReadInBackground,DiscardInputand the per-OS foreground-process checks.AutoInstallsFor, which decides whether the agent install hint moves to the end of a command, applies the same inferred-consent check without writing anything. This keeps the hint in step with what the run actually does.Turn off: databricks aitools auto-install disable. Remove: databricks aitools uninstall.DECLINEDandUNANSWEREDtelemetry outcomes are kept in the proto but documented as no longer sent. The telemetry README is updated to match.auto-installhelp text and theenableshort description describe the new behavior.Why
Before this change, a run with no coding agent asked before the first install. A coding agent's run installed without asking anyone. This change replaces both paths with one rule: install only once consent is stored, whether given explicitly or inferred from a CLI-made global installation.
Without the prompt, a lot of fragile terminal handling also goes away. That code dealt with detecting the foreground process group, discarding typed-ahead input, background stdin readers and containers whose terminal never delivers an answer.
Tests
cmd/aitoolsandlibs/aitools/autoinstallcover installing with consent, skipping without it, and installing on the same version once consent is given. They also cover inferred consent from a CLI-made global installation and the newno_consentreason inDecide. The prompt tests and container tests are removed.acceptance/cmd/aitools/auto-install/no-consent: a coding agent's call with no consent installs nothing, leaves the stored state unchanged, sends no auto-install event, doesn't read the manifest, and still shows the agent the install hint. Afterdatabricks aitools auto-install enable, the next command of the same version installs.agent-hint,first-run,no-terminal,retries,skipped,upgrade) now runauto-install enablebefore the cases that install, and their outputs are regenerated.skippedchecks that CI and the opt-outs are still reported before any consent exists.upgradeadds a case where a global installation made by an earlier CLI counts as consent..nextchanges/cli/aitools-auto-install-consent.md.