Repository navigation
Resolve skills hints once per command run - #8134
Conversation
Skill sources need the manifest type and its path checks, and the libs-no-aitools lint rule keeps shared libs from importing the installer. Move Manifest, SkillMeta, NormalizeManifest, CheckManifestPaths, EscapesDir and ErrUnsafeManifestPath down into libs/skills; the installer uses them from there through aliases. Add the Skill and Catalog types, the Source interface, sentinel errors, and NewFSSource over any fs.FS laid out like a skills release. The manifest accepts optional per-skill commands and a top-level catalog_rules file. Co-authored-by: Isaac <no-reply@databricks.com>
The installer and libs/skills both reserve .state.json. Define the name once in libs/skills and have the installer use it. Co-authored-by: Isaac <no-reply@databricks.com>
The Windows CI checkout turns the LF fixtures into CRLF, so the exact content assertions failed. Normalize line endings before comparing. Co-authored-by: Isaac <no-reply@databricks.com>
Clean catalog_rules before reading it, expose min_cli_version on Skill, document the Catalog fields and the release-relative paths the manifest may name. Co-authored-by: Isaac <no-reply@databricks.com>
Keep the path helper unexported since only libs/skills calls it, reject a catalog_rules path that cleans to a directory, and test a missing rules file. Drop the min_cli_version field, which is not in the skill interface the package needs yet. Co-authored-by: Isaac <no-reply@databricks.com>
Skill now has MinCLIVer, read from the manifest's min_cli_version, so a caller can apply the same rule install uses. The fixture covers it. Co-authored-by: Isaac <no-reply@databricks.com>
Register the hidden skills command group only when DATABRICKS_SKILLS_PREVIEW is set. Its five subcommands are stubs that report they are not implemented yet. Add guards for the feature and for its hints switch, DATABRICKS_SKILLS_HINTS, and a resolver for the folder in DATABRICKS_SKILLS_DIR, with an acceptance fixture release that later changes reuse. With the variable unset, the command group is not registered and nothing else changes. Co-authored-by: Isaac <no-reply@databricks.com>
Add a skills_hints boolean to the compatibility manifest entry, following auto_install: off when absent, ignored by CLIs that predate it. HintsEnabled stays off unless the skills feature is on. Then DATABRICKS_SKILLS_HINTS, when set, decides in both directions; otherwise the entry for this CLI version does. The entry is read from the local manifest cache or the embedded manifest only. Hints are resolved while help is printed, so they never fetch the manifest. Co-authored-by: Isaac <no-reply@databricks.com>
… hints The manifest cache is written as the bytes that were fetched, not re-encoded from the parsed manifest, so fields a CLI does not know (skills_hints for a CLI that predates it) survive a refresh. Hints are resolved without fetching, so a cache older than the one-hour TTL is ignored there and the embedded manifest (off) applies. A remote change reaches hints only through a command that refreshes the cache. Also: log why hints stay off when the manifest cannot be read, pin the cache and skills environment in the tests so a developer's shell cannot change them, and document the stale-cache rule in the field comment, the README and the bump-cli-compat skill. Co-authored-by: Isaac <no-reply@databricks.com>
…st env helper A CLI that predates skills_hints re-encodes the manifest cache when it refreshes it and drops the field, so this CLI reads hints as off until it refreshes the cache itself. Say so in the cache write comment and the build README. The guard tests now use testutil.CleanupEnvironment instead of a package-local unsetEnv helper. Co-authored-by: Isaac <no-reply@databricks.com>
Hints no longer fall back to the embedded manifest: without a fresh local cache they stay off, so a released CLI can be turned off remotely too. The cache is written in its previous form again; the raw-bytes write did not help skills_hints, since this CLI's entry already carries the field. The cache path comes from clicompat.LocalManifestPath, so the guard tests do not repeat the file name. The read-path explanation now lives in the README, and the code comments point there. Co-authored-by: Isaac <no-reply@databricks.com>
…ar-w Co-authored-by: Isaac <no-reply@databricks.com>
…ests Check the skills group in the root command uniqueness test, even though it is registered only behind DATABRICKS_SKILLS_PREVIEW. Clear both guard variables in the guard tests so an exported value does not leak in. LocalCatalog calls Resolve first and maps ErrNoSource to no catalog. Route the acceptance help check to LOG.help. Co-authored-by: Isaac <no-reply@databricks.com>
…h3-remote-switch-for-skills-hints Resolve the guard test conflict by keeping the clean-environment helper and setting only the variables each case names. Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com> # Conflicts: # libs/skills/guard.go # libs/skills/guard_test.go
Name skills_hints in the manifest bump steps of internal/build/README.md. Test an empty DATABRICKS_SKILLS_HINTS as set, so it forces hints off. Share the test cache writer with testutil.WriteFile and state the contract of forceEmbedded and cacheEnabled. Co-authored-by: Isaac <no-reply@databricks.com>
…-skills-hints-once-per-command-ru
HintsEnabled read the manifest cache on every call. Auto-install can refresh that cache between the hint check and the hint printed after the command, so the help footer, the hint text, its throttle and the skills command exemption could disagree within one run. execute puts a memo on the context, and HintsEnabled answers from it after its first call in the run. Without the memo, HintsEnabled reads the cache on every call as before, and with DATABRICKS_SKILLS_PREVIEW unset nothing changes. Co-authored-by: Isaac <no-reply@databricks.com>
✅ Integration test reportCommit: d92ac33
Top 6 slowest tests (at least 2 minutes):
|
Auto-install can refresh the manifest cache between MaybeHint and the deferred hint. Memoise the hints value on the run's context so the deferred text, its kind and its throttle keep the value MaybeHint saw. Drop the unused lock and a duplicated preview-off test, use testutil.WriteFile in the root test, and reword the root comment to name the deferred hint. Co-authored-by: Isaac <no-reply@databricks.com>
The memo test with the preview unset proves the feature gate still wins over a memoised context. Restore it, and note in WithHintsMemo that HintsEnabled must run on the command goroutine since the memo has no lock. Co-authored-by: Isaac <no-reply@databricks.com>
There was a problem hiding this comment.
Automated review at f6345f3. Each finding was verified against the code.
No blocking issues found.
This PR adds a memo to the run's context so skills.HintsEnabled gives the same answer for the whole command run. That keeps a deferred hint's text, kind and throttle consistent even if auto-install refreshes the manifest cache before the hint prints. I traced MaybeHint and show in libs/aitools/agents/hint.go: before the change, message(ctx) was called twice, so the text and its throttle could disagree. The memo resolves that, and the tests cover the refresh both at the library level and through execute. I found no concrete defect. The memo isn't locked, but I found no caller that reaches HintsEnabled from another goroutine.
rugpanov
left a comment
There was a problem hiding this comment.
The change is correct, and I found no blocking issue. The memo makes the pre-run hint check and the deferred hint use the same value. With DATABRICKS_SKILLS_PREVIEW unset, behavior does not change. I left two optional suggestions and one nit inline.
Risk: LOW. The change has an effect only when the hidden DATABRICKS_SKILLS_PREVIEW env var is set. It touches only the stderr skills hint path and adds no persisted state, so a revert is simple. Unit tests cover the memo, preview off and the deferred hint, and all CI checks pass.
| if !ok { | ||
| return resolveHints(ctx) | ||
| } | ||
| if !memo.resolved { |
There was a problem hiding this comment.
[nice to have] HintsEnabled reads and writes memo.resolved and memo.on with no lock. The memo is a context value, so every goroutine that gets a derived context shares it. No current caller runs off the command goroutine. But a future parallel caller causes a data race, and only the doc comment at line 43 prevents it. Use a sync.Once field, for example once sync.Once; on bool with memo.once.Do(func() { memo.on = resolveHints(ctx) }), and remove the caveat. Call Do with the caller's ctx, so that resolveHints logs to the logger of that call.
There was a problem hiding this comment.
Done in d92ac33. The memo now takes a mutex, and HintsEnabled passes the caller's ctx to resolveHints, so the first call's logger is used. I did not use sync.Once: this repo's forbidigo rule rejects it and points to sync.OnceValue, which cannot take the caller's ctx. The caveat about the command goroutine is gone; the memo is safe for concurrent use.
| // Skill hints resolve once for this run, so a deferred hint, its text and | ||
| // its throttle agree even when auto-install refreshes the manifest cache | ||
| // before the hint prints. | ||
| ctx = skills.WithHintsMemo(ctx) |
There was a problem hiding this comment.
[nice to have] The mismatch comes from one function. MaybeHint calls hint.message(ctx) for textDue, and the deferred show calls message(ctx) again after auto-install. If MaybeHint resolves msg once and gives it to show, the text, the throttle and the exemption use the same pre-run value. That fix needs no context memo, no change in execute and no run-wide rule for HintsEnabled. Today no other caller needs a run-wide value: the help footer runs before auto-install. Consider the local fix, or name in the PR the later caller that needs the run-wide memo.
There was a problem hiding this comment.
Kept the run-wide memo; the local fix alone does not meet the acceptance criterion. The ticket asks that HintsEnabled return the same value for the whole run, and TestExecuteSkillHintsOncePerRun checks HintsEnabled itself. A fix inside MaybeHint would make the deferred text consistent, but any later HintsEnabled call in the same run would still re-read the cache. The memo is one context value and a mutex, and the local fix is not needed on top of it. Callers today: the deferred show path (after auto-install) and the help footer and skills.WriteGroupHint (during the command, before auto-install). No change in d92ac33 for this point beyond the memo guard.
| ctx = context.WithValue(ctx, caughtSignalKey{}, &caught) | ||
| var deferredHint func() | ||
| ctx = context.WithValue(ctx, deferredHintKey{}, &deferredHint) | ||
| // Skill hints resolve once for this run, so a deferred hint, its text and |
There was a problem hiding this comment.
[nit] This comment repeats the reason in the doc comment of skills.WithHintsMemo (libs/skills/guard.go:38-43). .agents/rules/comments.md asks for concise comments. Shorten it to one line, for example // One skills hints value per run; see skills.WithHintsMemo.
There was a problem hiding this comment.
Shortened to one line in d92ac33: // One skills hints value per run; see skills.WithHintsMemo.
HintsEnabled may now be called from any goroutine that holds the run context, so the memo takes a lock instead of relying on the command goroutine. The lock is held on the caller's context, so the first call's logger is used. Shorten the root comment to point at WithHintsMemo. Co-authored-by: Isaac <no-reply@databricks.com>
Skill hints can change within one command run.
MaybeHintchecks them before a command, and when auto-install may give the agent its tools, the hint prints after the command. If auto-install refreshes the manifest cache in between, the hint text, its throttle and the skills command exemption can disagree. This PR resolves the hints value once per run, so they agree. WithDATABRICKS_SKILLS_PREVIEWunset, behaviour is unchanged.Changes
executeputsskills.WithHintsMemoon the run's context.skills.HintsEnabledanswers from the memo after its first call.DATABRICKS_SKILLS_PREVIEWunset,HintsEnabledreturns false before it reads the memo, so behaviour and goldens are unchanged.Why
skills.HintsEnabledread the manifest cache on every call. The auto-install that runs after a command can refresh that cache before the deferred hint prints, so the hint and its throttle could use different answers within one run. Memoising the answer on the run's context fixes this. The memo resolves on the first call rather than inexecute, so a run that never checks hints does not read the cache. It lives on the context, so tests and library callers never share a value between runs. Without a memo,HintsEnabledreads the cache on each call, as before. The memo is a design choice to review: the first call decides the run's value, so any environment change the run makes must come before that call.Tests
TestHintsEnabledOncePerRuncovers a cache refresh in the middle of a run: the run keeps its answer, a call without the memo sees the refreshed cache, and a new run sees it.TestMaybeHint_DeferredSkillsHintIgnoresCacheRefreshcovers a deferred hint whose cache is refreshed before it prints: the text, its kind and its throttle keep the first answer. It fails without the memo.TestExecuteSkillHintsOncePerRuncovers the same refresh inside a command run throughexecute, so it also proves the wiring.go test ./libs/skills/... ./cmd/root/... ./libs/aitools/agents/...passes, and./task fmt-q lint-qreports no issues.go test ./acceptance -run 'TestAccept/cmd/skills'andTestAccept/helppass with no golden changes.Not tested: a real auto-install that refreshes the cache. The refresh is simulated by rewriting the cache file in the tests.
This pull request and its description were written by Isaac.