Repository navigation
Conversation
## Changes `databricks aitools install` now reports a coding agent as failed when it cannot write the skill files into that agent's skills directory. Before this change, the run logged a warning, still listed the agent as installed and exited with code 0. - `installSkillForAgents` now returns each agent that could not get a skill, along with the error. This covers a skills directory that can't be resolved, a third-party skill that can't be backed up, and a failed copy. - `InstallSkillsForAgents` saves the install state as before. It then returns a new `*installer.AgentSkillsError` that lists each agent that didn't get every skill, with the skill count and the first error. It prints `Installed N skills in <dir>.` only if at least one agent got the skills. - `executePlan` maps those agents to a `failed` outcome, the same way it already treats a plugin agent that failed. Each failed agent gets an error category, a message and a recovery step that re-runs the install for that agent only. An agent whose CLI is missing gets `--skills-only` in that step. The failure is an error if the agent was named with `--agents`, or if no other agent was set up. If it was detected and another agent did get the skills, it stays a warning. Stale plugin records are now forgotten only for agents that actually got the skills. - `UpdateSkills` doesn't change: an agent that can't get a skill is still a logged warning there. Example output, for a skills directory left owned by root: ``` Skipped Cursor: could not install 1 skill: mkdir ~/.cursor/skills/databricks-test: permission denied Check that you own ~/.cursor/skills/databricks-test and can write to it (an earlier run with sudo can leave it owned by root), then re-run 'databricks aitools install --scope=global --agents=cursor --skills-only'. Error: Cursor: could not install 1 skill: mkdir ~/.cursor/skills/databricks-test: permission denied ``` With `--output json`, the agent has `"status": "failed"`, `"error_category": "PERMISSION_DENIED"`, a message and a recovery step. ## Why A common way to get an unwritable skills directory is an earlier `sudo databricks aitools install`, which leaves it owned by root. The next install looked like it worked for that agent, but no skills were in place and nothing told the user why or how to fix it. Telemetry and the auto-install prompt also counted the run as a success, so a failed auto-install was never retried. ## Tests - New acceptance test `acceptance/cmd/aitools/telemetry/install-unwritable-agent-dir` (skipped on Windows, where `chmod` doesn't make a directory read-only). It covers a named agent with a read-only skills directory, in text and `--output json` (exit code 1, agent reported as failed, telemetry outcome `FAILURE` with `PERMISSION_DENIED`). It also covers a detected agent that fails while another one gets the skills (exit code 0, the failed agent reported, the other agent's skills in place). - Unit tests for `InstallSkillsForAgents` returning `AgentSkillsError` for an unwritable skills directory. Unit tests for `executePlan` with only one agent and with another agent set up, each with the agent named and detected. A unit test for the recovery step of an agent whose CLI is missing. - An auto-install prompt case: an agent that got no skills counts as a failed attempt and is retried later. - Changelog fragment in `.nextchanges/cli/`. Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
There was a problem hiding this comment.
Automated review at 21ade18. Each finding was verified against the code.
Not ready yet: 1 blocking issue(s), tagged [blocking].
This PR makes databricks aitools install report an agent as failed, with a recovery step, when its skill files can't be written. Before, the install exited 0 and listed the agent as installed. The interactive install path does what the description says. The auto-install retry it promises doesn't happen: the next attempt goes through the update path, which settles the version as up to date and never writes the missing skills. A few smaller issues remain: the same error now prints three times, the recovery step names a directory that doesn't exist, and the new acceptance test is skipped on Windows.
| agentsErr.Failures = append(agentsErr.Failures, *f) | ||
| } | ||
| } | ||
| return agentsErr |
There was a problem hiding this comment.
[blocking] The install state is saved with every skill recorded (line 510) before this AgentSkillsError is returned. On the next auto-install, planTools sees existing != nil (cmd/aitools/autoinstall_run.go:578-583) and calls updateTools → UpdateSkills. There every skill at the recorded version is Unchanged (update.go:190-193), and per-agent failures are dropped anyway (update.go:238). So changedAgents is empty, the attempt returns UP_TO_DATE and settles the version. Example: Cursor's ~/.cursor/skills is owned by root. Attempt 1 reports FAILED. Attempt 2 reports UP_TO_DATE even after the user runs chown, and Cursor never gets the skills. That contradicts the new test case "an agent that got no skills is a failed attempt, retried later", which only checks attempt 1. Should the state not record skills for an agent that got none, or should the update path re-expose skills to agents that lack them? A second runAutoInstallHook in that test would show which one works.
| @@ -718,13 +748,14 @@ func installSkillForAgents(ctx context.Context, skillName string, meta SkillMeta | |||
| // Copy from canonical dir instead of re-downloading. | |||
| if err := copyDir(canonicalDir, destDir); err != nil { | |||
| log.Warnf(ctx, "Failed to install for %s: %v", agent.DisplayName, err) | |||
There was a problem hiding this comment.
[nice to have] This log.Warnf stays even though the error now goes back to executePlan. That function prints Skipped Cursor: … plus a recovery step (cmd/aitools/install.go), and for a named agent the same text comes back as Error:. The new golden shows it: output.txt lines 29-32 have three lines with the same mkdir … permission denied, and with --output json the Warn still goes to stderr next to the JSON (line 46). Can the warnings at the other failed[agent] = err sites (lines 717, 725, 742) and this one become Debugf for InstallSkillsForAgents, so the caller reports the failure once? UpdateSkills still needs its warning, so it may have to stay there.
| continue | ||
| } | ||
| reason := f.Reason() | ||
| recovery := installRecovery(ctx, skillsAgentRerun(rerun, it), f.Err) |
There was a problem hiding this comment.
[nice to have] For a copyDir mkdir failure, permissionRecovery names PathError.Path, which is the directory that could not be created, not the one the user can't write to. In the golden, ~/.cursor/skills is the read-only directory, but the step says "Check that you own …/.cursor/skills/databricks-test". That path doesn't exist, so ls -ld or chown on it fails. Can the step name the first existing ancestor for a mkdir or create failure?
| // skillsAgentRerun is rerun for one agent that gets skill files. An agent | ||
| // whose CLI is missing gets --skills-only: named via --agents, it would get | ||
| // the plugin instead. | ||
| func skillsAgentRerun(inv installInvocation, it agentPlanItem) installInvocation { |
There was a problem hiding this comment.
[nice to have] skillsAgentRerun is a second way to build a one-agent rerun next to agentCommandText/skillsOnlyCommand. Going through installRecovery → rerunPhrase passes changed = nil to commandText. When a value can't be quoted (for example a --path that shellquote.Arg rejects), the step falls back to "your original install command" without --agents=cursor or --skills-only, and that rerun widens to every agent. Can this reuse agentCommandText, or pass the changed flags through?
| @@ -0,0 +1,5 @@ | |||
| # The case relies on chmod, which does not make a directory read-only on Windows. | |||
| GOOS.windows = false | |||
There was a problem hiding this comment.
[nice to have] AGENTS.md says tests must also run on Windows, but GOOS.windows = false means Windows never checks the exit code, the Skipped Cursor: line, the recovery step or the JSON failed outcome. The unit tests in this PR already use a setup that works on every OS: a regular file where the skills directory belongs. Could a case that uses touch "$HOME/.cursor/skills" run everywhere, with the chmod case kept only for the PERMISSION_DENIED category?
|
Commit: Regression test reportSelected 1 changed tests (limit=20, 0 not selected) 1 tests: regression=1 unreleased=0 coverage=0 failing=0
TestAccept/cmd/aitools/telemetry/install-unwritable-agent-dir: branch ✅ | main (0c71683) ❌ | latest (v1.28.0) ❌main (0c71683): latest (v1.28.0): |
✅ Integration test reportCommit: 5d538ff
Top 6 slowest tests (at least 2 minutes):
|
Changes
databricks aitools installnow reports a coding agent as failed when it cannot write the skill files into that agent's skills directory. Before this change, the run logged a warning, still listed the agent as installed and exited with code 0.installSkillForAgentsnow returns each agent that could not get a skill, along with the error. This covers a skills directory that can't be resolved, a third-party skill that can't be backed up, and a failed copy.InstallSkillsForAgentssaves the install state as before. It then returns a new*installer.AgentSkillsErrorthat lists each agent that didn't get every skill, with the skill count and the first error. It printsInstalled N skills in <dir>.only if at least one agent got the skills.executePlanmaps those agents to afailedoutcome, the same way it already treats a plugin agent that failed. Each failed agent gets an error category, a message and a recovery step that re-runs the install for that agent only. An agent whose CLI is missing gets--skills-onlyin that step. The failure is an error if the agent was named with--agents, or if no other agent was set up. If it was detected and another agent did get the skills, it stays a warning. Stale plugin records are now forgotten only for agents that actually got the skills.UpdateSkillsdoesn't change: an agent that can't get a skill is still a logged warning there.Example output, for a skills directory left owned by root:
With
--output json, the agent has"status": "failed","error_category": "PERMISSION_DENIED", a message and a recovery step.Why
A common way to get an unwritable skills directory is an earlier
sudo databricks aitools install, which leaves it owned by root. The next install looked like it worked for that agent, but no skills were in place and nothing told the user why or how to fix it. Telemetry and the auto-install prompt also counted the run as a success, so a failed auto-install was never retried.Tests
acceptance/cmd/aitools/telemetry/install-unwritable-agent-dir(skipped on Windows, wherechmoddoesn't make a directory read-only). It covers a named agent with a read-only skills directory, in text and--output json(exit code 1, agent reported as failed, telemetry outcomeFAILUREwithPERMISSION_DENIED). It also covers a detected agent that fails while another one gets the skills (exit code 0, the failed agent reported, the other agent's skills in place).InstallSkillsForAgentsreturningAgentSkillsErrorfor an unwritable skills directory. Unit tests forexecutePlanwith only one agent and with another agent set up, each with the agent named and detected. A unit test for the recovery step of an agent whose CLI is missing..nextchanges/cli/.