Skip to content

Log a telemetry event for each databricks skills command run - #8145

Open
simonfaltum wants to merge 3 commits into
mainfrom
skills/t1-telemetry-for-the-skills-commands
Open

simonfaltum wants to merge 3 commits into
mainfrom
skills/t1-telemetry-for-the-skills-commands

Conversation

@simonfaltum

@simonfaltum simonfaltum commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Changes

Each run of databricks skills (list, read, list-files, read-file, search) logs one SkillsCommandEvent: the command, the skill name for a successful read of a published skill, the catalog release version, the source that served it, the outcome, and an error category. The calling agent goes in ExecutionContext.calling_agent, which cmd/root fills from the value that cmd/skills records for the run.

  • libs/skills wraps the source that Resolve returns, and records what was read when the command's context carries a record. A successful read reads the catalog once, for the version and the listing; a failed read makes no catalog call. cmd/skills wraps each command's RunE once, so the command files are unchanged.
  • Nothing is logged when telemetry is disabled, and no record is installed then. The upload is best effort: it resolves auth in the background as install does, and never fails or prompts the command.
  • The commands exist only when DATABRICKS_SKILLS_PREVIEW is set. With it unset, no path changes, and the new execution context field is omitted.

Why

Without an event, nothing shows which skills agents load, from where, or through which agent. The event mirrors the SkillsCommandEvent message of the CLI log schema.

Decisions to review

  • Bounded wait for auth at exit. Upload needs workspace auth, and the skills commands never resolve it. A run that logged an event waits up to 3 seconds for an unfinished background resolution, so a slow credential helper can add that much to the command. Without the wait the event is not uploaded deterministically, which the acceptance test needs.
  • cmd/skills imports cmd/aitools. The auth helper and the calling-agent lookup live there. Exporting WithTelemetryAuth and CallingAgentType reuses them instead of copying them. Moving them to cmd/root would be cleaner and can follow as a separate refactor.
  • skill_name only after a successful read of a listed skill, and never from a folder or a non-default ref or base URL. A failed read may carry a typo or private text.
  • Only the folder source is wired. Resolve returns the DATABRICKS_SKILLS_DIR folder, so a run without it fails with SOURCE_UNAVAILABLE. LIVE, CACHE and BUNDLED are defined for the sources that follow, and the published-name rule is covered by unit tests rather than acceptance.
  • A run that fails argument parsing logs nothing, as the aitools commands do, because cobra rejects it before the command runs.

Tests

  • go test ./libs/skills/ ./cmd/skills/ passes. TestRecordSkillName covers the name rules, TestRecordFolderSendsNoName the folder rule, TestRecordReadFileCatalogCalls the catalog reads of a successful and a failed read, and TestErrorCategory the categories.
  • go test ./acceptance -run TestAccept/cmd/skills and -run TestAccept/cmd/aitools pass. The new cmd/skills/telemetry case shows the uploaded payloads for list, read and a failed read, the calling agent, nothing uploaded with telemetry disabled, and TestRecordRunsDisabledLogsNothing checks that no event is buffered, and identical output with telemetry on and off.
  • ./task fmt-q lint-q and tools/check_deadcode.py are clean.

Not tested: the live release source, which this change does not add, and uploads to a real workspace.

This pull request and its description were written by Isaac.

Each run of list, read, list-files, read-file or search logs one
SkillsCommandEvent: the command, the skill name for a successful read of
a published skill, the catalog release version, the source that served
it, the outcome and an error category. The calling agent is recorded in
the execution context, as the aitools events do.

Events follow the existing telemetry opt-out and are uploaded in the
background, best effort. The skills commands exist only when
DATABRICKS_SKILLS_PREVIEW is set, so nothing changes with it unset.

Co-authored-by: Isaac <no-reply@databricks.com>
@github-actions github-actions Bot added the aitools AI tools (databricks aitools) related changes label Nov 27, 2026
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Regression test report ✅

Commit: a9c450c25 | Workflow run

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

1 tests: regression=1 unreleased=0 coverage=0 failing=0
test branch main (905b0f7) latest (v1.28.0)
TestAccept/cmd/skills/telemetry ✅ ❌ ❌
TestAccept/cmd/skills/telemetry: branch ✅ | main (905b0f7) ❌ | latest (v1.28.0) ❌

main (905b0f7):

acceptance_test.go:1402: Diff:
        --- cmd/skills/telemetry/output.txt
        +++ /tmp/TestAcceptcmdskillstelemetry3723620299/002/output.txt
        @@ -5,14 +5,12 @@
         Databricks skills are not installed. To work with Databricks reliably, first run: databricks aitools install
         
         >>> print_skills
        -{"calling_agent":"CLAUDE_CODE","command":"LIST","catalog_release_version":"0.0.1","source":"FOLDER","outcome":"SUCCEEDED"}
         
         === skills read from a folder: the name is not sent, the release version and the source are
         
         >>> [CLI] skills read guide-skill
         
         >>> print_skills
        -{"calling_agent":null,"command":"READ","catalog_release_version":"0.0.1","source":"FOLDER","outcome":"SUCCEEDED"}
         
         === a failed read sends the error category and the version
         
        @@ -20,7 +12,6 @@
         Error: unknown skill "no-such-skill": run "databricks skills list" to see the available skills
         
         >>> print_skills
        -{"calling_agent":null,"command":"READ","catalog_release_version":"0.0.1","source":"FOLDER","outcome":"FAILED","error_category":"SKILL_NOT_FOUND"}
         
         === with telemetry disabled, nothing is uploaded
         
        
    acceptance_test.go:1180: 
        LOG.disabled: ---
        LOG.disabled: name: guide-skill
        LOG.disabled: description: A skill with a supporting file.
        LOG.disabled: ---
        LOG.disabled: 
        LOG.disabled: # Guide skill
        LOG.disabled: 
        LOG.disabled: Read the guide in references for details.
        LOG.disabled: 
        LOG.disabled: Other files in this skill, each read with its command:
        LOG.disabled:   databricks skills read-file guide-skill references/guide.md
        LOG.disabled:   databricks skills read-file -- guide-skill -notes.md
    acceptance_test.go:1180: 
        LOG.list: Pick the skill whose description matches the task.
        LOG.list: Read the skill before you act on it.
        LOG.list: 
        LOG.list: -foo: A skill whose name starts with a hyphen.
        LOG.list: demo-skill: A skill for tests.
        LOG.list: future-skill: A skill that needs a newer CLI.
        LOG.list: guide-skill: A skill with a supporting file.
        LOG.list: To read a skill, run: databricks skills read <name>
    acceptance_test.go:1180: 
        LOG.off: Pick the skill whose description matches the task.
        LOG.off: Read the skill before you act on it.
        LOG.off: 
        LOG.off: -foo: A skill whose name starts with a hyphen.
        LOG.off: demo-skill: A skill for tests.
        LOG.off: future-skill: A skill that needs a newer CLI.
        LOG.off: guide-skill: A skill with a supporting file.
        LOG.off: To read a skill, run: databricks skills read <name>
    acceptance_test.go:1180: 
        LOG.on: Pick the skill whose description matches the task.
        LOG.on: Read the skill before you act on it.
        LOG.on: 
        LOG.on: -foo: A skill whose name starts with a hyphen.
        LOG.on: demo-skill: A skill for tests.
        LOG.on: future-skill: A skill that needs a newer CLI.
        LOG.on: guide-skill: A skill with a supporting file.
        LOG.on: To read a skill, run: databricks skills read <name>
    acceptance_test.go:1180: 
        LOG.read: ---
        LOG.read: name: guide-skill
        LOG.read: description: A skill with a supporting file.
        LOG.read: ---
        LOG.read: 
        LOG.read: # Guide skill
        LOG.read: 
        LOG.read: Read the guide in references for details.
        LOG.read: 
        LOG.read: Other files in this skill, each read with its command:
        LOG.read:   databricks skills read-file guide-skill references/guide.md
        LOG.read:   databricks skills read-file -- guide-skill -notes.md
FAIL

latest (v1.28.0):

acceptance_test.go:1402: Diff:
        --- cmd/skills/telemetry/output.txt
        +++ /tmp/TestAcceptcmdskillstelemetry3005031052/002/output.txt
        @@ -2,30 +2,6 @@
         === skills list under a coding agent: the event and the calling agent are uploaded
         
         >>> [CLI] skills list
        -Databricks skills are not installed. To work with Databricks reliably, first run: databricks aitools install
        +Error: unknown command "skills" for "databricks"
         
        ->>> print_skills
        -{"calling_agent":"CLAUDE_CODE","command":"LIST","catalog_release_version":"0.0.1","source":"FOLDER","outcome":"SUCCEEDED"}
        -
        -=== skills read from a folder: the name is not sent, the release version and the source are
        -
        ->>> [CLI] skills read guide-skill
        -
        ->>> print_skills
        -{"calling_agent":null,"command":"READ","catalog_release_version":"0.0.1","source":"FOLDER","outcome":"SUCCEEDED"}
        -
        -=== a failed read sends the error category and the version
        -
        ->>> [CLI] skills read no-such-skill
        -Error: unknown skill "no-such-skill": run "databricks skills list" to see the available skills
        -
        ->>> print_skills
        -{"calling_agent":null,"command":"READ","catalog_release_version":"0.0.1","source":"FOLDER","outcome":"FAILED","error_category":"SKILL_NOT_FOUND"}
        -
        -=== with telemetry disabled, nothing is uploaded
        -
        ->>> [CLI] skills read guide-skill
        -
        ->>> print_skills
        -
        -=== output is the same with telemetry on and off
        +Exit code: 1
        
    acceptance_test.go:1180: LOG.list: 
FAIL

@eng-dev-ecosystem-bot

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

Copy link
Copy Markdown
Collaborator

✅ Integration test report

Commit: a9c450c

Run: 46093277769

Env ✅​pass 🙈​skip Time
✅​ aws linux-2core-8gb 174 18 4:23
✅​ aws-windows-latest-4core-16gb 174 18 3:17
✅​ azure linux-2core-8gb 173 18 4:25
✅​ azure-windows-latest-4core-16gb 173 18 3:20
✅​ gcp linux-2core-8gb 174 18 4:25
✅​ gcp-windows-latest-4core-16gb 174 18 3:38
Top 6 slowest tests (at least 2 minutes):
duration env testname
3:56 gcp linux-2core-8gb TestAccept
3:37 gcp-windows-latest-4core-16gb TestAccept
3:21 azure linux-2core-8gb TestAccept
3:18 azure-windows-latest-4core-16gb TestAccept
3:17 aws linux-2core-8gb TestAccept
3:16 aws-windows-latest-4core-16gb TestAccept

A read-file reads the catalog once, after the read succeeds, for the release version and to check that the skill is listed. A failed read makes no catalog call. With telemetry off, the commands install no record, so they make no extra call.

Co-authored-by: Isaac <no-reply@databricks.com>
@simonfaltum
simonfaltum marked this pull request as ready for review November 28, 2026 00:46
@simonfaltum
simonfaltum requested review from a team and lennartkats-db as code owners November 28, 2026 00:46

@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 33bbebb. Each finding was verified against the code.

Not ready yet: 1 open question(s) about a change users could be hurt by.

This PR makes each databricks skills command log a SkillsCommandEvent. It records what the folder source read and reports the calling agent in the execution context. The wiring looks right: the wrapper order, the opt-out and the catalog reads all hold up. There are some gaps, though. An oversized manifest isn't classified the way its doc says. The "published" check reads env vars that the package doc says only ref.go/fetch.go read. Two acceptance cases can't fail for the reason their titles give. The remaining open question is the unconditional auth wait on every run.

Questions

  1. [blocking] recordRuns sets WaitAtExit = true when each skills command is registered. Every run logs an event, so every run waits up to telemetryAuthBudget for auth, including cheap failures like skills search " " or a run that ends with ErrNoSource. The TelemetryAuth.WaitAtExit doc says it is false by default and is set only once a run is worth the wait, and install/instrumentCommand follow that. Should the wait be set only after Resolve/Catalog succeed? If you keep it on every run, the comment's "as install does" should be changed, since install only waits after plan confirmation.

Comment thread cmd/skills/telemetry.go Outdated
return protos.SkillsErrorCategoryFileNotFound
case errors.Is(err, libskills.ErrNoSource), errors.Is(err, libskills.ErrSourceUnreachable):
return protos.SkillsErrorCategorySourceUnavailable
case errors.Is(err, libskills.ErrUnsafeManifestPath), syntax, typed:

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] The doc on ErrManifestTooLarge in libs/skills/fetch.go says the command layer classifies it like a manifest that does not parse. fsSource.manifest returns it unwrapped, but this switch only checks ErrUnsafeManifestPath and the JSON errors, so a manifest over MaxFetchBodySize is reported as UNCATEGORIZED. Can you add errors.Is(err, libskills.ErrManifestTooLarge) to this case, plus a row for it in TestErrorCategory?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in a9c450c: errorCategory now maps ErrManifestTooLarge to CATALOG_INVALID, and TestErrorCategory has a row for it.

Comment thread libs/skills/record.go
// namesArePublished reports whether this source's skill names are published ones. A folder's names, and those of a ref
// or base URL the user chose, are the user's own.
func (r *recordingSource) namesArePublished(ctx context.Context) bool {
return r.rec.Origin != OriginFolder && env.Get(ctx, "DATABRICKS_SKILLS_REF") == "" && env.Get(ctx, "DATABRICKS_SKILLS_BASE_URL") == ""

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] namesArePublished reads DATABRICKS_SKILLS_REF and DATABRICKS_SKILLS_BASE_URL directly. The package doc in skills.go says ref.go and fetch.go are the only code here that reads them. With the only wired origin (OriginFolder), the first condition already returns false, so these checks never run today. Could Resolve pass a published bool to record(...), decided where the ref and base URL are actually resolved? You could also add the checks together with the live source, so that the two can't drift apart.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not in this PR. This branch has no live source yet, and the code that reads DATABRICKS_SKILLS_REF and DATABRICKS_SKILLS_BASE_URL arrives with it, so the folder origin never reaches this check today. Until then the check stays on the recording path, where TestRecordSkillName covers the ref and base URL cases. When the live source lands, it can decide published where it picks its ref and pass the flag to record, so the two cannot drift. Tracked as a follow-up.

Comment thread acceptance/cmd/skills/telemetry/script Outdated
trace print_skills

title "with telemetry disabled, no event is recorded"
DATABRICKS_CLI_DISABLE_TELEMETRY=1 trace $CLI skills read guide-skill > /dev/null

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] telemetry.Upload already returns early on DATABRICKS_CLI_DISABLE_TELEMETRY, so this golden would stay empty even if recordRuns still installed the record and logged the event. The case doesn't cover the early return in recordRuns. In the same way, the "a failed read sends no name" case (line 26) reads from a folder, which never sends a name, so it would pass even if a failed read sent the name. Could you add a unit test that checks telemetry.BufferedEvents after a run with telemetry disabled, and retitle the two cases to say what they show (nothing uploaded; the error category and the version)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in a9c450c. The two cases are retitled to what they show: nothing is uploaded with telemetry disabled, and a failed read sends the error category and the version. The rule that a failed read sends no name is covered by TestSkillsEventFailedReadSendsNoName, which runs the error path directly. TestRecordRunsDisabledLogsNothing checks BufferedEvents with telemetry disabled, so it fails if the wrapper logs.

Comment thread acceptance/cmd/skills/telemetry/script Outdated

title "skills list under a coding agent: the event and the calling agent are uploaded"
export CLAUDECODE=1
trace $CLI skills list > /dev/null

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[nit] .agents/rules/testing.md asks for noisy output to go to LOG.<name>, not /dev/null. This line and lines 23 and 31 throw the command output away. Can these redirect to LOG.list / LOG.read like the LOG.on/LOG.off at the end?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in a9c450c. The three runs that discarded output now write to LOG.list, LOG.read and LOG.disabled, as LOG.on and LOG.off do. The golden is unchanged.

Comment thread cmd/skills/telemetry.go Outdated
// logEvent buffers the event of a run for the upload at exit, and sets the calling agent for its execution context.
func logEvent(cmd *cobra.Command, command protos.SkillsCommand, rec *libskills.Record, err error) {
ctx := cmd.Context()
if telemetry.Disabled(ctx) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[nit] logEvent is only called from the recordRuns wrapper, which has already returned early when telemetry.Disabled(cmd.Context()) is true, so this check can never fire. Can we drop it and keep the single check in recordRuns?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in a9c450c. The check is removed from logEvent. recordRuns is its only caller and returns early when telemetry is disabled, and TestRecordRunsDisabledLogsNothing covers that path.

Classify an oversized manifest as a catalog error, drop the telemetry check
in logEvent that recordRuns already makes, and add a test that a run with
telemetry disabled logs nothing. The acceptance cases now send their output
to LOG files, and the two cases that the folder source could not prove are
retitled to what they show.

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

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.

2 participants