Repository navigation
Gate static aitools install text on the agent features switch - #8223
Conversation
…es switch With DATABRICKS_CLI_DISABLE_AGENT_FEATURES set, the air help pages, the interactive quickstart and the AGENTS.md written by bundle init no longer name `databricks aitools install`. Unset, every text is unchanged. 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/air/agent-features-disabled: branch ✅ | main (d9bab18) ❌ | latest (v1.28.0) ❌main (d9bab18): latest (v1.28.0): same output as main (d9bab18) TestAccept/bundle/templates/default-minimal/agent-features-disabled/DMS=: branch ✅ | main (d9bab18) ❌ | latest (v1.28.0) ❌main (d9bab18): latest (v1.28.0): TestAccept/cmd/aitools/auto-install/agent-features-disabled: branch ✅ | main (d9bab18) ❌ | latest (v1.28.0) ❌main (d9bab18): latest (v1.28.0): TestAccept/cmd/aitools/auto-install/enable-disable: branch ✅ | main (d9bab18) ❌ | latest (v1.28.0) ❌main (d9bab18): latest (v1.28.0): TestAccept/cmd/aitools/telemetry/apps-init-tip: branch ✅ | main (d9bab18) ❌ | latest (v1.28.0) ❌main (d9bab18): latest (v1.28.0): TestAccept/cmd/skills/agent-features-disabled: branch ✅ | main (d9bab18) ❌ | latest (v1.28.0) ❌main (d9bab18): latest (v1.28.0): TestAccept/cmd/version: branch ✅ | main (d9bab18) ❌ | latest (v1.28.0) ❌main (d9bab18): latest (v1.28.0): |
✅ Integration test reportCommit: 69666d6
Top 3 slowest tests (at least 2 minutes):
|
There was a problem hiding this comment.
Automated review at c5da815. Each finding was verified against the code.
No blocking issues found. 9 non-blocking comment(s) below.
This PR hides the static databricks aitools install text in air help, the interactive quickstart and the generated AGENTS.md when DATABRICKS_CLI_DISABLE_AGENT_FEATURES is set. I found no bug: with the switch unset every text stays the same, and with it set each path drops the install text. What I'd change is mostly fit with existing code. Quickstart adds a second way to filter the text next to variantText. The air run help reads the switch in two places, and one of them has a context.TODO() fallback. Two comments are stale or unclear, and the new tests break a few rules in testing.md.
| } | ||
|
|
||
| // dropAitoolsInstallLines removes the lines that name `databricks aitools install`. | ||
| func dropAitoolsInstallLines(s string) string { |
There was a problem hiding this comment.
[nice to have] This file already gates aitools text with <!--aitools-->/<!--plain--> blocks through variantText, and dropAitoolsInstallLines adds a second mechanism that matches on line content. Any future line in quickstart-human.md that mentions databricks aitools install gets dropped silently. A nudge that wraps across two lines or rewords the command would be only partly removed. Can you wrap quickstart-human.md:63 in the existing markers and return variantText(humanQuickstart, false, aitoolsNudge) instead?
There was a problem hiding this comment.
Done. The human quickstart line is now wrapped in the existing aitools markers and quickstartFor returns variantText(humanQuickstart, false, aitoolsNudge); dropAitoolsInstallLines is gone.
|
|
||
| // helpContext returns the command's context, or an empty one for a command | ||
| // that was not run through Execute. | ||
| func helpContext(c *cobra.Command) context.Context { |
There was a problem hiding this comment.
[nice to have] The run help decides whether to show the skill in two ways. newRunCommand sets Long to runLong + runSkillLong, then buildCommand (air.go:56) overwrites it from the build ctx. Meanwhile -h config reads c.Context() at help time through helpContext. The context.TODO() fallback exists only for the new unit test, which calls the help func without Execute. In the real CLI, cobra always sets the context, which AGENTS.md says not to guard against ("Avoid speculative fallbacks", "Do not add defensive nil checks"). Could newRunCommand take the bool from buildCommand and choose both Long and the config-help skill line, so the overwrite and helpContext both go away?
There was a problem hiding this comment.
Done. newRunCommand now takes an agentSkill bool from buildCommand and picks both Long and the config-help skill line from it. The post-hoc Long override and helpContext are removed.
| } | ||
|
|
||
| func TestAirHelpInstallTextFollowsAgentFeaturesSwitch(t *testing.T) { | ||
| for _, tc := range agentFeatureSwitchCases { |
There was a problem hiding this comment.
[nice to have] TestAirHelpInstallTextFollowsAgentFeaturesSwitch checks the same three outputs and substrings as acceptance/air/agent-features-disabled. Likewise, TestAgentsMdInstallStepFollowsAgentFeaturesSwitch (libs/template/renderer_test.go:696) repeats bundle/templates/default-minimal/agent-features-disabled. The only extra coverage is how false, maybe and true parse, and that belongs to skills.AgentFeaturesDisabled. testing.md says not to add a unit test that only duplicates an acceptance test. Can these be dropped, or cut down to what the acceptance tests don't cover?
There was a problem hiding this comment.
Done. I dropped both unit tests. The acceptance cases cover the set and unset outputs, and the true/false/invalid parsing is already covered by TestAgentFeaturesDisabled in libs/skills.
| @@ -0,0 +1,11 @@ | |||
| # With DATABRICKS_CLI_DISABLE_AGENT_FEATURES set, the AGENTS.md written by bundle init names no aitools install. | |||
| echo '{"project_name": "my_project", "language_choice": "sql"}' > input.json | |||
There was a problem hiding this comment.
[nice to have] input.json is a fixed string, but the script writes it with echo and deletes it at the end. testing.md asks for static inputs to be committed next to script. Can you commit input.json and drop it from the rm -rf?
There was a problem hiding this comment.
Done. input.json is committed next to the script and removed from the rm -rf.
| # With DATABRICKS_CLI_DISABLE_AGENT_FEATURES set, the AGENTS.md written by bundle init names no aitools install. | ||
| echo '{"project_name": "my_project", "language_choice": "sql"}' > input.json | ||
| trace DATABRICKS_CLI_DISABLE_AGENT_FEATURES=1 $CLI bundle init default-minimal --config-file ./input.json --output-dir disabled | ||
| grep -c "aitools install" disabled/my_project/AGENTS.md || true |
There was a problem hiding this comment.
[nice to have] grep -c "aitools install" ... || true hides grep's exit code, so the check rests only on the 0 in output.txt. testing.md allows || true only for cleanup or when exit codes legitimately differ, and asks for the acceptance/bin helpers instead of inline grep. Can lines 4, 5 and 9 use cat .../AGENTS.md | contains.py "If the CLI is not installed" "!aitools install", as the air test in this PR does?
There was a problem hiding this comment.
Done. The script now uses cat ... | contains.py with "If the CLI is not installed" and "!aitools install" for the disabled case, and contains.py "aitools install" for the unset case. The grep/|| true calls are gone.
| @@ -0,0 +1,10 @@ | |||
| # With DATABRICKS_CLI_DISABLE_AGENT_FEATURES set, the air help pages name no | |||
There was a problem hiding this comment.
[nit] acceptance/air/help already traces $CLI air --help, and testing.md asks to extend an existing acceptance directory when coverage overlaps. Could these cases go there instead, or is a separate directory clearer because it is about the switch?
There was a problem hiding this comment.
I kept the separate directory. The case is about the env switch and runs each command both set and unset, and the help directory pins the unset command tree only. Adding set/unset runs there would mix two purposes in one golden.
| w := c.OutOrStdout() | ||
| fmt.Fprint(w, airHelpLinks) | ||
| fmt.Fprint(w, airSkillLine) | ||
| if !skills.AgentFeaturesDisabled(ctx) { |
There was a problem hiding this comment.
[nit] The doc comment on airSkillLine (line 28) still says it "is always printed for air", but this branch now leaves it out when DATABRICKS_CLI_DISABLE_AGENT_FEATURES is set. Can you update that comment to name the exception?
There was a problem hiding this comment.
Done. The comment now says the line is printed except when DATABRICKS_CLI_DISABLE_AGENT_FEATURES is set.
| } | ||
|
|
||
| // runLong is the run help text without the skill pointer. It is what is left | ||
| // when the agent features switch is on. |
There was a problem hiding this comment.
[nit] "when the agent features switch is on" is easy to read as "when agent features are on", but the switch disables them. Suggest: "It is used alone when DATABRICKS_CLI_DISABLE_AGENT_FEATURES is set; otherwise runSkillLong is appended."
There was a problem hiding this comment.
Done. The comment now reads: used alone when DATABRICKS_CLI_DISABLE_AGENT_FEATURES is set; otherwise runSkillLong is appended.
| tmpl := template.New("").Funcs(helpers).Funcs(template.FuncMap{ | ||
| // False when DATABRICKS_CLI_DISABLE_AGENT_FEATURES is set. The shared library uses | ||
| // it to leave out text that points coding agents at `databricks aitools install`. | ||
| // It is defined here, not in the helpers, because the library parses without them. |
There was a problem hiding this comment.
[nit] In production, promptForInput passes loadHelpers(ctx), so the shared library is parsed with the helpers attached. "the library parses without them" is only true for callers that pass nil helpers. Could the comment name those callers? Or could the helper move into loadHelpers next to deployment_history, which is the existing env-switch helper, with those callers updated?
There was a problem hiding this comment.
I tried moving it into loadHelpers, but several tests pass nil helpers and still parse the shared library (for example config_test.go and TestRendererSubTemplateInPath), and they fail with an undefined function. I kept it in newRenderer and reworded the comment to say that callers passing nil helpers still parse the library and need it.
…markers, trim duplicate tests Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
Changes
With
DATABRICKS_CLI_DISABLE_AGENT_FEATURESset, static help and template text no longer namesdatabricks aitools install. This is stacked on the PR that adds the switch; it merges after that one.databricks air --helpdrops the "Coding agent skill" line.databricks air run --helpanddatabricks air run -h configdrop the install step.databricks quickstartdrops the "Using an AI coding assistant?" line.databricks bundle initomits the install step and keeps the rest.The switch is read through
skills.AgentFeaturesDisabled(ctx), like the other gates. Unset, every text and golden is unchanged.Why
The switch turns off the agent nudges, but this static text still told agents to run
aitools install. It was flagged in review of the PR that adds the switch. The comment onairSkillLinesaid the air line was deliberate; the switch overrides it for this case.Tests
TestAgentFeaturesDisabledinlibs/skillscovers value parsing: unset,true,1,falseand an invalid value.TestQuickstartForInteractiveAitoolsLinecovers the interactive quickstart line.air/agent-features-disabled(air help, run help and config help) andbundle/templates/default-minimal/agent-features-disabled(the rendered AGENTS.md) show the text gone with the switch set and present with it unset.This pull request and its description were written by Isaac.