Skip to content

Add agent detection library - #4287

Merged
pietern merged 1 commit into
mainfrom
agent-ua
Jan 19, 2026
Merged

Add agent detection library#4287
pietern merged 1 commit into
mainfrom
agent-ua

Conversation

@pietern

Copy link
Copy Markdown
Contributor

Changes

Adds libs/agent package to detect AI agents (Claude Code, Gemini CLI, Cursor) via environment variables. Used in user agent tracking and available for telemetry and (future, optional) conditional behavior.

Detection only succeeds when exactly one agent environment variable is set, preventing ambiguous detection in environments with multiple agents.

Implementation:

  • libs/agent: Detection logic with Detect(), Product(), and Mock()
  • cmd/root: Integrated agent detection into command execution

Environment variable sources:

Adds libs/agent package to detect agents (Claude Code, Gemini CLI, Cursor)
via environment variables. Used in user agent tracking and available for
telemetry and conditional behavior.
Detection only succeeds when exactly one agent environment variable is
set, preventing ambiguous detection in environments with multiple agents.
Implementation:
- libs/agent: Detection logic with Detect(), Product(), and Mock()
- cmd/root: Integrated agent detection into command execution
- Test config: Clear agent env vars in acceptance tests to prevent
interference with test outputs
Environment variable sources:
- CLAUDECODE=1: anthropics/claude-code#531
- GEMINI_CLI=1: https://github.com/google-gemini/gemini-cli/blob/main/docs/cli/commands.md
- CURSOR_AGENT=1: https://forum.cursor.com/t/cursor-cli-is-not-setting-cursor-agent-1-environment-variable-while-executing-bash-commands/132427
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@eng-dev-ecosystem-bot

eng-dev-ecosystem-bot commented Jan 15, 2026

Copy link
Copy Markdown
Collaborator

Commit: c299cef

Run: 21028121325

Env🟨​KNOWN🔄​flaky💚​RECOVERED🙈​SKIP✅​pass🙈​skipTime
🟨​aws linux710239369519:46
🟨​aws windows107239569319:20
🟨​aws-ucws linux3212255856831:43
🟨​aws-ucws windows6211255856627:40
💚​azure linux12339369420:30
🟨​azure windows48339569218:46
💚​azure-ucws linux12355456733:46
🟨​azure-ucws windows48355656528:16
💚​gcp linux12338270019:13
🟨​gcp windows48338469817:42
21 interesting tests: 10 KNOWN, 8 RECOVERED, 2 flaky, 1 SKIP
Test Nameaws linuxaws windowsaws-ucws linuxaws-ucws windowsazure linuxazure windowsazure-ucws linuxazure-ucws windowsgcp linuxgcp windows
🟨​TestAccept🟨​K🟨​K🟨​K🟨​K💚​R🟨​K💚​R🟨​K💚​R🟨​K
💚​TestAccept/bundle/deployment/bind/alert🙈​S🙈​S🙈​S🙈​S💚​R💚​R💚​R💚​R💚​R💚​R
🟨​TestAccept/bundle/generate/alert💚​R🟨​K💚​R🟨​K💚​R🟨​K💚​R🟨​K💚​R🟨​K
🟨​TestAccept/bundle/generate/alert/DATABRICKS_BUNDLE_ENGINE=direct💚​R🟨​K💚​R🟨​K💚​R🟨​K💚​R🟨​K💚​R🟨​K
🟨​TestAccept/bundle/generate/alert/DATABRICKS_BUNDLE_ENGINE=terraform💚​R🟨​K💚​R🟨​K💚​R🟨​K💚​R🟨​K💚​R🟨​K
💚​TestAccept/bundle/resources/alerts/basic💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R
💚​TestAccept/bundle/resources/alerts/basic/DATABRICKS_BUNDLE_ENGINE=direct💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R
💚​TestAccept/bundle/resources/alerts/basic/DATABRICKS_BUNDLE_ENGINE=terraform💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R
💚​TestAccept/bundle/resources/alerts/with_file💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R
💚​TestAccept/bundle/resources/alerts/with_file/DATABRICKS_BUNDLE_ENGINE=direct💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R
💚​TestAccept/bundle/resources/alerts/with_file/DATABRICKS_BUNDLE_ENGINE=terraform💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R
🙈​TestAccept/bundle/resources/permissions🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S
🟨​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions🟨​K🟨​K🟨​K🟨​K🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S
🟨​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions/DATABRICKS_BUNDLE_ENGINE=direct🟨​K🟨​K🟨​K🟨​K
🟨​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions/DATABRICKS_BUNDLE_ENGINE=terraform🟨​K🟨​K💚​R💚​R
🟨​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions🟨​K🟨​K🔄​f💚​R🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S
🟨​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions/DATABRICKS_BUNDLE_ENGINE=direct🟨​K🟨​K💚​R💚​R
🟨​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions/DATABRICKS_BUNDLE_ENGINE=terraform🟨​K🟨​K🔄​f💚​R
🔄​TestAccept/bundle/resources/quality_monitors/create🙈​s🙈​s✅​p🔄​f🙈​s🙈​s✅​p✅​p🙈​s🙈​s
🔄​TestAccept/bundle/resources/quality_monitors/create/DATABRICKS_BUNDLE_ENGINE=direct✅​p🔄​f✅​p✅​p
💚​TestAccept/ssh/connection💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R
Top 48 slowest tests (at least 2 minutes):
durationenvtestname
7:07aws-ucws linuxTestAccept/bundle/resources/synced_database_tables/basic/DATABRICKS_BUNDLE_ENGINE=terraform
5:59aws-ucws windowsTestAccept/bundle/resources/synced_database_tables/basic/DATABRICKS_BUNDLE_ENGINE=direct
5:53aws-ucws linuxTestAccept/bundle/resources/synced_database_tables/basic/DATABRICKS_BUNDLE_ENGINE=direct
5:44aws-ucws linuxTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=terraform
5:43aws windowsTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=direct
5:42aws-ucws windowsTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=terraform
5:38gcp linuxTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=terraform
5:37aws-ucws windowsTestAccept/bundle/resources/synced_database_tables/basic/DATABRICKS_BUNDLE_ENGINE=terraform
5:32gcp linuxTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=direct
5:31gcp windowsTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=direct
5:30gcp windowsTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=terraform
5:28aws-ucws windowsTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=direct
5:25aws-ucws linuxTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=direct
5:21aws linuxTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=terraform
5:16aws linuxTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=direct
4:41azure linuxTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=terraform
4:26azure-ucws linuxTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=terraform
4:10azure-ucws windowsTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=terraform
4:07gcp linuxTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
4:01azure linuxTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=direct
3:49gcp linuxTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:49azure-ucws windowsTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=direct
3:42azure-ucws linuxTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=direct
3:36azure-ucws windowsTestAccept/bundle/resources/synced_database_tables/basic/DATABRICKS_BUNDLE_ENGINE=terraform
3:35azure-ucws linuxTestAccept/bundle/resources/synced_database_tables/basic/DATABRICKS_BUNDLE_ENGINE=terraform
3:34azure-ucws linuxTestAccept/bundle/resources/synced_database_tables/basic/DATABRICKS_BUNDLE_ENGINE=direct
3:27azure-ucws windowsTestAccept/bundle/resources/synced_database_tables/basic/DATABRICKS_BUNDLE_ENGINE=direct
3:05gcp windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:55aws-ucws windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:47aws windowsTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=terraform
2:45aws-ucws windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:42gcp windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:42aws windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:41azure-ucws windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:40aws linuxTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:39azure-ucws windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:37aws linuxTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:32aws windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:21azure-ucws linuxTestAccept
2:19gcp linuxTestAccept
2:15azure windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:14azure linuxTestAccept
2:11azure-ucws linuxTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:10azure-ucws linuxTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:08azure linuxTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:04aws-ucws linuxTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:03azure linuxTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:02azure windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct

@lennartkats-dblennartkats-db left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice! One comment

Comment threadlibs/agent/agent.go
claudeCodeEnvVar = "CLAUDECODE"
geminiCliEnvVar = "GEMINI_CLI"
cursorAgentEnvVar = "CURSOR_AGENT"
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As discussed offline, Codex seems to set CODEX_SANDBOX.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I'll submit a separate PR for this.

@pietern
pietern merged commit 48d2d47 into mainJan 19, 2026
21 checks passed
@pietern
pietern deleted the agent-ua branch January 19, 2026 12:21
pietern added a commit that referenced this pull request Jan 19, 2026
This packages was added in #4287 and centralizes agent detection.
@eng-dev-ecosystem-bot

Copy link
Copy Markdown
Collaborator

Commit: 48d2d47

Run: 21137292758

Env🪲​BUG❌​FAIL🟨​KNOWN💚​RECOVERED🙈​SKIP✅​pass🙈​skipTime
🪲​aws linux226710341968057:18
🪲​aws windows224116342367849:58
🪲​aws-ucws linux2213614260254881:53
🪲​aws-ucws windows2213119260454687:52
🪲​azure linux2212113441367970:32
🪲​azure windows224410442367767:22
🪲​azure-ucws linux2219413359254793:27
🪲​azure-ucws windows2213710360054574:41
🪲​gcp linux20131440768852:30
🪲​gcp windows20131440968644:00
72 interesting tests: 26 FAIL, 23 KNOWN, 22 BUG, 1 SKIP
Test Nameaws linuxaws windowsaws-ucws linuxaws-ucws windowsazure linuxazure windowsazure-ucws linuxazure-ucws windowsgcp linuxgcp windows
🟨​TestAccept🟨​K🟨​K🟨​K🟨​K🟨​K🟨​K🟨​K🟨​K🟨​K🟨​K
🟨​TestAccept/bundle/deployment/bind/alert🙈​S🙈​S🙈​S🙈​S💚​R💚​R💚​R💚​R🟨​K🟨​K
🟨​TestAccept/bundle/deployment/bind/alert/DATABRICKS_BUNDLE_ENGINE=direct💚​R💚​R💚​R💚​R🟨​K🟨​K
🟨​TestAccept/bundle/deployment/bind/alert/DATABRICKS_BUNDLE_ENGINE=terraform💚​R💚​R💚​R💚​R🟨​K🟨​K
🟨​TestAccept/bundle/generate/alert💚​R🟨​K💚​R🟨​K💚​R🟨​K💚​R🟨​K🟨​K🟨​K
🟨​TestAccept/bundle/generate/alert/DATABRICKS_BUNDLE_ENGINE=direct💚​R🟨​K💚​R🟨​K💚​R🟨​K💚​R🟨​K🟨​K🟨​K
🟨​TestAccept/bundle/generate/alert/DATABRICKS_BUNDLE_ENGINE=terraform💚​R🟨​K💚​R🟨​K💚​R🟨​K💚​R🟨​K🟨​K🟨​K
🪲​TestAccept/bundle/integration_whl/base🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B
🪲​TestAccept/bundle/integration_whl/base/DATABRICKS_BUNDLE_ENGINE=direct🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B
🪲​TestAccept/bundle/integration_whl/base/DATABRICKS_BUNDLE_ENGINE=terraform🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B
🪲​TestAccept/bundle/integration_whl/custom_params🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B
🪲​TestAccept/bundle/integration_whl/custom_params/DATABRICKS_BUNDLE_ENGINE=direct🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B
🪲​TestAccept/bundle/integration_whl/custom_params/DATABRICKS_BUNDLE_ENGINE=terraform🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B
🪲​TestAccept/bundle/integration_whl/interactive_cluster🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B
🪲​TestAccept/bundle/integration_whl/interactive_cluster/DATABRICKS_BUNDLE_ENGINE=direct🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B
🪲​TestAccept/bundle/integration_whl/interactive_cluster/DATABRICKS_BUNDLE_ENGINE=terraform🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B
🪲​TestAccept/bundle/integration_whl/interactive_cluster_dynamic_version🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B
🪲​TestAccept/bundle/integration_whl/interactive_cluster_dynamic_version/DATABRICKS_BUNDLE_ENGINE=direct/DATA_SECURITY_MODE=SINGLE_USER🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B
🪲​TestAccept/bundle/integration_whl/interactive_cluster_dynamic_version/DATABRICKS_BUNDLE_ENGINE=direct/DATA_SECURITY_MODE=USER_ISOLATION🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B
🪲​TestAccept/bundle/integration_whl/interactive_cluster_dynamic_version/DATABRICKS_BUNDLE_ENGINE=terraform/DATA_SECURITY_MODE=SINGLE_USER🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B
🪲​TestAccept/bundle/integration_whl/interactive_cluster_dynamic_version/DATABRICKS_BUNDLE_ENGINE=terraform/DATA_SECURITY_MODE=USER_ISOLATION🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B
🪲​TestAccept/bundle/integration_whl/interactive_single_user🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B
🪲​TestAccept/bundle/integration_whl/interactive_single_user/DATABRICKS_BUNDLE_ENGINE=direct🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B
🪲​TestAccept/bundle/integration_whl/interactive_single_user/DATABRICKS_BUNDLE_ENGINE=terraform🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B
❌​TestAccept/bundle/integration_whl/serverless🙈​s🙈​s❌​F❌​F🙈​s🙈​s❌​F❌​F🙈​s🙈​s
❌​TestAccept/bundle/integration_whl/serverless/DATABRICKS_BUNDLE_ENGINE=direct❌​F❌​F❌​F❌​F
❌​TestAccept/bundle/integration_whl/serverless/DATABRICKS_BUNDLE_ENGINE=terraform❌​F❌​F❌​F❌​F
❌​TestAccept/bundle/integration_whl/serverless_custom_params🙈​s🙈​s❌​F❌​F🙈​s🙈​s❌​F❌​F🙈​s🙈​s
❌​TestAccept/bundle/integration_whl/serverless_custom_params/DATABRICKS_BUNDLE_ENGINE=direct❌​F❌​F❌​F❌​F
❌​TestAccept/bundle/integration_whl/serverless_custom_params/DATABRICKS_BUNDLE_ENGINE=terraform❌​F❌​F❌​F❌​F
❌​TestAccept/bundle/integration_whl/serverless_dynamic_version🙈​s🙈​s❌​F❌​F🙈​s🙈​s❌​F❌​F🙈​s🙈​s
❌​TestAccept/bundle/integration_whl/serverless_dynamic_version/DATABRICKS_BUNDLE_ENGINE=direct❌​F❌​F❌​F❌​F
❌​TestAccept/bundle/integration_whl/serverless_dynamic_version/DATABRICKS_BUNDLE_ENGINE=terraform❌​F❌​F❌​F❌​F
🪲​TestAccept/bundle/integration_whl/wrapper🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🙈​s🙈​s
❌​TestAccept/bundle/integration_whl/wrapper/DATABRICKS_BUNDLE_ENGINE=direct❌​F❌​F❌​F❌​F❌​F❌​F❌​F❌​F
❌​TestAccept/bundle/integration_whl/wrapper/DATABRICKS_BUNDLE_ENGINE=terraform❌​F❌​F❌​F❌​F❌​F❌​F❌​F❌​F
🪲​TestAccept/bundle/integration_whl/wrapper_custom_params🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🙈​s🙈​s
❌​TestAccept/bundle/integration_whl/wrapper_custom_params/DATABRICKS_BUNDLE_ENGINE=direct❌​F❌​F❌​F❌​F❌​F❌​F❌​F❌​F
❌​TestAccept/bundle/integration_whl/wrapper_custom_params/DATABRICKS_BUNDLE_ENGINE=terraform❌​F❌​F❌​F❌​F❌​F❌​F❌​F❌​F
🟨​TestAccept/bundle/resources/alerts/basic💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R🟨​K🟨​K
🟨​TestAccept/bundle/resources/alerts/basic/DATABRICKS_BUNDLE_ENGINE=direct💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R🟨​K🟨​K
🟨​TestAccept/bundle/resources/alerts/basic/DATABRICKS_BUNDLE_ENGINE=terraform💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R🟨​K🟨​K
🟨​TestAccept/bundle/resources/alerts/with_file💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R🟨​K🟨​K
🟨​TestAccept/bundle/resources/alerts/with_file/DATABRICKS_BUNDLE_ENGINE=direct💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R🟨​K🟨​K
🟨​TestAccept/bundle/resources/alerts/with_file/DATABRICKS_BUNDLE_ENGINE=terraform💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R🟨​K🟨​K
❌​TestAccept/bundle/resources/clusters/deploy/update-after-create✅​p✅​p✅​p✅​p❌​F✅​p❌​F✅​p✅​p✅​p
❌​TestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=direct✅​p✅​p✅​p✅​p❌​F✅​p✅​p✅​p✅​p✅​p
❌​TestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=terraform✅​p✅​p✅​p✅​p✅​p✅​p❌​F✅​p✅​p✅​p
🪲​TestAccept/bundle/resources/clusters/run/spark_python_task🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B
🪲​TestAccept/bundle/resources/clusters/run/spark_python_task/DATABRICKS_BUNDLE_ENGINE=direct🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B
🪲​TestAccept/bundle/resources/clusters/run/spark_python_task/DATABRICKS_BUNDLE_ENGINE=terraform🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B🪲​B
🙈​TestAccept/bundle/resources/permissions🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S
❌​TestAccept/bundle/resources/permissions/factcheck✅​p✅​p✅​p✅​p❌​F✅​p❌​F✅​p🙈​s🙈​s
❌​TestAccept/bundle/resources/permissions/factcheck/DATABRICKS_BUNDLE_ENGINE=terraform✅​p✅​p✅​p✅​p❌​F✅​p❌​F✅​p
🟨​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions🟨​K🟨​K🟨​K🟨​K🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S
🟨​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions/DATABRICKS_BUNDLE_ENGINE=direct🟨​K🟨​K🟨​K🟨​K
🟨​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions/DATABRICKS_BUNDLE_ENGINE=terraform🟨​K🟨​K💚​R💚​R
🟨​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions🟨​K🟨​K💚​R🟨​K🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S
🟨​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions/DATABRICKS_BUNDLE_ENGINE=direct🟨​K🟨​K💚​R💚​R
🟨​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions/DATABRICKS_BUNDLE_ENGINE=terraform🟨​K🟨​K💚​R🟨​K
🟨​TestAccept/bundle/resources/synced_database_tables/basic🙈​S🙈​S🟨​K🟨​K🙈​S🙈​S🟨​K🟨​K🙈​S🙈​S
🟨​TestAccept/bundle/resources/synced_database_tables/basic/DATABRICKS_BUNDLE_ENGINE=direct🟨​K🟨​K🟨​K🟨​K
🟨​TestAccept/bundle/resources/synced_database_tables/basic/DATABRICKS_BUNDLE_ENGINE=terraform🟨​K🟨​K🟨​K🟨​K
❌​TestAccept/bundle/run/app-with-job❌​F✅​p✅​p✅​p✅​p✅​p✅​p✅​p✅​p✅​p
❌​TestAccept/bundle/run/app-with-job/DATABRICKS_BUNDLE_ENGINE=direct❌​F✅​p✅​p✅​p✅​p✅​p✅​p✅​p✅​p✅​p
❌​TestAccept/bundle/templates/default-python/combinations/classic✅​p✅​p✅​p✅​p❌​F✅​p✅​p✅​p✅​p✅​p
❌​TestAccept/bundle/templates/default-python/combinations/classic/DATABRICKS_BUNDLE_ENGINE=direct/DLT=no/NBOOK=no/PY=yes/READPLAN=✅​p✅​p✅​p✅​p❌​F✅​p✅​p✅​p✅​p✅​p
❌​TestAccept/bundle/templates/default-python/combinations/classic/DATABRICKS_BUNDLE_ENGINE=direct/DLT=no/NBOOK=no/PY=yes/READPLAN=1✅​p✅​p✅​p✅​p❌​F✅​p✅​p✅​p✅​p✅​p
❌​TestAccept/bundle/templates/default-python/combinations/classic/DATABRICKS_BUNDLE_ENGINE=direct/DLT=no/NBOOK=yes/PY=no/READPLAN=✅​p✅​p✅​p✅​p❌​F✅​p✅​p✅​p✅​p✅​p
❌​TestAccept/bundle/templates/default-python/combinations/serverless✅​p✅​p✅​p✅​p✅​p✅​p❌​F✅​p✅​p✅​p
❌​TestAccept/bundle/templates/default-python/combinations/serverless/DATABRICKS_BUNDLE_ENGINE=direct/DLT=yes/NBOOK=no/PY=yes/READPLAN=1🙈​s🙈​s✅​p✅​p🙈​s🙈​s❌​F✅​p🙈​s🙈​s
🟨​TestAccept/ssh/connection💚​R🟨​K💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R
Top 50 slowest tests (at least 2 minutes):
durationenvtestname
16:08azure-ucws windowsTestAccept/bundle/resources/permissions/factcheck/DATABRICKS_BUNDLE_ENGINE=terraform
15:12aws linuxTestSparkJarTaskDeployAndRunOnWorkspace/Databricks_Runtime_15.4_LTS
13:55azure-ucws linuxTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=direct
13:10azure windowsTestAccept/bundle/resources/permissions/factcheck/DATABRICKS_BUNDLE_ENGINE=terraform
12:42aws-ucws linuxTestAccept/bundle/resources/model_serving_endpoints/running-endpoint/DATABRICKS_BUNDLE_ENGINE=terraform
12:37aws-ucws windowsTestAccept/bundle/resources/model_serving_endpoints/running-endpoint/DATABRICKS_BUNDLE_ENGINE=terraform
12:27aws-ucws windowsTestAccept/bundle/resources/model_serving_endpoints/running-endpoint/DATABRICKS_BUNDLE_ENGINE=direct
12:21azure linuxTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=terraform
11:25aws-ucws linuxTestAccept/bundle/resources/model_serving_endpoints/running-endpoint/DATABRICKS_BUNDLE_ENGINE=direct
9:58azure windowsTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=terraform
8:22aws-ucws linuxTestSparkJarTaskDeployAndRunOnVolumes/Databricks_Runtime_15.4_LTS
8:16gcp windowsTestSparkJarTaskDeployAndRunOnWorkspace/Databricks_Runtime_15.4_LTS
7:56aws-ucws linuxTestSparkJarTaskDeployAndRunOnVolumes/Databricks_Runtime_13.3_LTS
7:43aws-ucws windowsTestAccept/bundle/resources/database_instances/single-instance/DATABRICKS_BUNDLE_ENGINE=direct
7:37aws-ucws linuxTestSparkJarTaskDeployAndRunOnVolumes/Databricks_Runtime_14.3_LTS
7:34azure-ucws linuxTestSparkJarTaskDeployAndRunOnVolumes/Databricks_Runtime_15.4_LTS
7:29gcp windowsTestAccept/bundle/run/app-with-job/DATABRICKS_BUNDLE_ENGINE=terraform
7:28aws-ucws linuxTestAccept/bundle/resources/database_instances/single-instance/DATABRICKS_BUNDLE_ENGINE=direct
7:19aws-ucws windowsTestAccept/bundle/resources/database_catalogs/basic/DATABRICKS_BUNDLE_ENGINE=direct
7:08azure linuxTestAccept/bundle/run/app-with-job/DATABRICKS_BUNDLE_ENGINE=terraform
7:07aws-ucws linuxTestAccept/bundle/resources/database_catalogs/basic/DATABRICKS_BUNDLE_ENGINE=direct
7:02aws-ucws windowsTestSparkJarTaskDeployAndRunOnVolumes/Databricks_Runtime_14.3_LTS
6:59aws-ucws windowsTestSparkJarTaskDeployAndRunOnVolumes/Databricks_Runtime_13.3_LTS
6:57gcp windowsTestAccept/bundle/run/app-with-job/DATABRICKS_BUNDLE_ENGINE=direct
6:56gcp linuxTestAccept/bundle/run/app-with-job/DATABRICKS_BUNDLE_ENGINE=direct
6:55azure windowsTestAccept/bundle/run/app-with-job/DATABRICKS_BUNDLE_ENGINE=direct
6:54azure linuxTestAccept/bundle/run/app-with-job/DATABRICKS_BUNDLE_ENGINE=direct
6:35aws-ucws linuxTestAccept/bundle/resources/database_instances/single-instance/DATABRICKS_BUNDLE_ENGINE=terraform
6:34azure-ucws windowsTestSparkJarTaskDeployAndRunOnVolumes/Databricks_Runtime_13.3_LTS
6:31gcp linuxTestAccept/bundle/run/app-with-job/DATABRICKS_BUNDLE_ENGINE=terraform
6:22azure windowsTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=direct
6:15aws-ucws windowsTestAccept/bundle/resources/database_instances/single-instance/DATABRICKS_BUNDLE_ENGINE=terraform
6:11aws-ucws linuxTestAccept/bundle/resources/database_catalogs/basic/DATABRICKS_BUNDLE_ENGINE=terraform
5:59azure-ucws windowsTestAccept/bundle/resources/model_serving_endpoints/running-endpoint/DATABRICKS_BUNDLE_ENGINE=terraform
5:59aws-ucws windowsTestAccept/bundle/run/app-with-job/DATABRICKS_BUNDLE_ENGINE=terraform
5:45azure-ucws linuxTestAccept/bundle/resources/model_serving_endpoints/running-endpoint/DATABRICKS_BUNDLE_ENGINE=direct
5:41aws linuxTestAccept/bundle/run/app-with-job/DATABRICKS_BUNDLE_ENGINE=terraform
5:41aws windowsTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=direct
5:37aws linuxTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=terraform
5:36aws windowsTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=terraform
5:34aws-ucws linuxTestAccept/bundle/run/app-with-job/DATABRICKS_BUNDLE_ENGINE=direct
5:31azure-ucws linuxTestSparkJarTaskDeployAndRunOnVolumes/Databricks_Runtime_13.3_LTS
5:29aws-ucws windowsTestAccept/bundle/resources/database_catalogs/basic/DATABRICKS_BUNDLE_ENGINE=terraform
5:26azure-ucws linuxTestSparkJarTaskDeployAndRunOnVolumes/Databricks_Runtime_14.3_LTS
5:25aws linuxTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=direct
5:24azure-ucws windowsTestAccept/bundle/resources/model_serving_endpoints/running-endpoint/DATABRICKS_BUNDLE_ENGINE=direct
5:22azure-ucws linuxTestAccept/bundle/run/app-with-job/DATABRICKS_BUNDLE_ENGINE=terraform
5:19azure-ucws linuxTestAccept/bundle/resources/model_serving_endpoints/running-endpoint/DATABRICKS_BUNDLE_ENGINE=terraform
5:18gcp windowsTestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=terraform
5:10aws windowsTestSparkJarTaskDeployAndRunOnWorkspace/Databricks_Runtime_15.4_LTS

pietern added a commit that referenced this pull request Jan 19, 2026
## Why
This packages was added in #4287 and centralizes agent detection.
## Tests
Manually confirmed install with `CLAUDECODE=1` and `CURSOR_AGENT=1`.
vikrantpuppala added a commit to vikrantpuppala/databricks-jdbc that referenced this pull request Feb 24, 2026
Detect when the JDBC driver is invoked by an AI coding agent (e.g.
Claude Code, Cursor, Gemini CLI) by checking well-known environment
variables, and append `agent/<product>` to the User-Agent string.
This enables Databricks to understand how much driver usage originates
from AI coding agents. Detection only succeeds when exactly one agent
is detected to avoid ambiguous attribution.
Mirrors the approach in databricks/cli#4287.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
vikrantpuppala added a commit to vikrantpuppala/databricks-sql-python that referenced this pull request Feb 24, 2026
Detect when the Python SQL connector is invoked by an AI coding agent
(e.g. Claude Code, Cursor, Gemini CLI) by checking well-known
environment variables, and append `agent/<product>` to the User-Agent
string.
This enables Databricks to understand how much driver usage originates
from AI coding agents. Detection only succeeds when exactly one agent
is detected to avoid ambiguous attribution.
Mirrors the approach in databricks/cli#4287.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
vikrantpuppala added a commit to vikrantpuppala/databricks-sql-go that referenced this pull request Feb 24, 2026
Detect when the Go SQL driver is invoked by an AI coding agent (e.g.
Claude Code, Cursor, Gemini CLI) by checking well-known environment
variables, and append `agent/<product>` to the User-Agent string.
This enables Databricks to understand how much driver usage originates
from AI coding agents. Detection only succeeds when exactly one agent
is detected to avoid ambiguous attribution.
Mirrors the approach in databricks/cli#4287.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
vikrantpuppala added a commit to vikrantpuppala/databricks-sql-nodejs that referenced this pull request Feb 24, 2026
Detect when the Node.js SQL driver is invoked by an AI coding agent
(e.g. Claude Code, Cursor, Gemini CLI) by checking well-known
environment variables, and append `agent/<product>` to the User-Agent
string.
This enables Databricks to understand how much driver usage originates
from AI coding agents. Detection only succeeds when exactly one agent
is detected to avoid ambiguous attribution.
Mirrors the approach in databricks/cli#4287.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
vikrantpuppala added a commit to vikrantpuppala/databricks-jdbc that referenced this pull request Feb 24, 2026
Detect when the JDBC driver is invoked by an AI coding agent (e.g.
Claude Code, Cursor, Gemini CLI) by checking well-known environment
variables, and append `agent/<product>` to the User-Agent string.
This enables Databricks to understand how much driver usage originates
from AI coding agents. Detection only succeeds when exactly one agent
is detected to avoid ambiguous attribution.
Mirrors the approach in databricks/cli#4287.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
vikrantpuppala added a commit to vikrantpuppala/databricks-sql-python that referenced this pull request Feb 24, 2026
Detect when the Python SQL connector is invoked by an AI coding agent
(e.g. Claude Code, Cursor, Gemini CLI) by checking well-known
environment variables, and append `agent/<product>` to the User-Agent
string.
This enables Databricks to understand how much driver usage originates
from AI coding agents. Detection only succeeds when exactly one agent
is detected to avoid ambiguous attribution.
Mirrors the approach in databricks/cli#4287.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
vikrantpuppala added a commit to vikrantpuppala/databricks-sql-go that referenced this pull request Feb 24, 2026
Detect when the Go SQL driver is invoked by an AI coding agent (e.g.
Claude Code, Cursor, Gemini CLI) by checking well-known environment
variables, and append `agent/<product>` to the User-Agent string.
This enables Databricks to understand how much driver usage originates
from AI coding agents. Detection only succeeds when exactly one agent
is detected to avoid ambiguous attribution.
Mirrors the approach in databricks/cli#4287.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
vikrantpuppala added a commit to vikrantpuppala/databricks-sql-nodejs that referenced this pull request Feb 24, 2026
Detect when the Node.js SQL driver is invoked by an AI coding agent
(e.g. Claude Code, Cursor, Gemini CLI) by checking well-known
environment variables, and append `agent/<product>` to the User-Agent
string.
This enables Databricks to understand how much driver usage originates
from AI coding agents. Detection only succeeds when exactly one agent
is detected to avoid ambiguous attribution.
Mirrors the approach in databricks/cli#4287.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
vikrantpuppala added a commit to vikrantpuppala/databricks-jdbc that referenced this pull request Apr 13, 2026
Detect when the JDBC driver is invoked by an AI coding agent (e.g.
Claude Code, Cursor, Gemini CLI) by checking well-known environment
variables, and append `agent/<product>` to the User-Agent string.
This enables Databricks to understand how much driver usage originates
from AI coding agents. Detection only succeeds when exactly one agent
is detected to avoid ambiguous attribution.
Mirrors the approach in databricks/cli#4287.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
vikrantpuppala added a commit to databricks/databricks-sql-python that referenced this pull request Apr 13, 2026
Detect when the Python SQL connector is invoked by an AI coding agent
(e.g. Claude Code, Cursor, Gemini CLI) by checking well-known
environment variables, and append `agent/<product>` to the User-Agent
string.
This enables Databricks to understand how much driver usage originates
from AI coding agents. Detection only succeeds when exactly one agent
is detected to avoid ambiguous attribution.
Mirrors the approach in databricks/cli#4287.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
vikrantpuppala added a commit to vikrantpuppala/databricks-sql-go that referenced this pull request Apr 13, 2026
Detect when the Go SQL driver is invoked by an AI coding agent (e.g.
Claude Code, Cursor, Gemini CLI) by checking well-known environment
variables, and append `agent/<product>` to the User-Agent string.
This enables Databricks to understand how much driver usage originates
from AI coding agents. Detection only succeeds when exactly one agent
is detected to avoid ambiguous attribution.
Mirrors the approach in databricks/cli#4287.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
vikrantpuppala added a commit to databricks/databricks-sql-nodejs that referenced this pull request Apr 13, 2026
Detect when the Node.js SQL driver is invoked by an AI coding agent
(e.g. Claude Code, Cursor, Gemini CLI) by checking well-known
environment variables, and append `agent/<product>` to the User-Agent
string.
This enables Databricks to understand how much driver usage originates
from AI coding agents. Detection only succeeds when exactly one agent
is detected to avoid ambiguous attribution.
Mirrors the approach in databricks/cli#4287.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
vikrantpuppala added a commit to databricks/databricks-sql-go that referenced this pull request Apr 13, 2026
## Summary
- Adds `internal/agent` package that detects 7 AI coding agents (Claude
Code, Cursor, Gemini CLI, Cline, Codex, OpenCode, Antigravity) by
checking well-known environment variables they set in spawned shell
processes
- Integrates detection into `InitThriftClient` to append
`agent/<product>` to the User-Agent header
- Uses exactly-one detection rule: if zero or multiple agent env vars
are set, no agent is attributed (avoids ambiguity)
## Approach
Mirrors the implementation in
[databricks/cli#4287](databricks/cli#4287) and
aligns with the latest agent list in
[`libs/agent/agent.go`](https://github.com/databricks/cli/blob/main/libs/agent/agent.go#L35).
| Agent | Product String | Environment Variable |
|-------|---------------|---------------------|
| Google Antigravity | `antigravity` | `ANTIGRAVITY_AGENT` |
| Claude Code | `claude-code` | `CLAUDECODE` |
| Cline | `cline` | `CLINE_ACTIVE` |
| OpenAI Codex | `codex` | `CODEX_CI` |
| Cursor | `cursor` | `CURSOR_AGENT` |
| Gemini CLI | `gemini-cli` | `GEMINI_CLI` |
| OpenCode | `opencode` | `OPENCODE` |
Adding a new agent requires only a new constant and a new entry in
`knownAgents`.
## Changes
- **New**: `internal/agent/agent.go` — environment-variable-based agent
detection with injectable env lookup for testability
- **New**: `internal/agent/agent_test.go` — 11 test cases covering all
agents, no agent, multiple agents, empty values, and real `os.Getenv`
- **Modified**: `internal/client/client.go` — calls `agent.Detect()`
when building User-Agent in `InitThriftClient`
## Test plan
- [x] `internal/agent` — 11 tests pass
- [x] `internal/client` — all existing tests continue to pass
- [x] Manual: verified User-Agent contains `agent/claude-code` when run
from Claude Code via `GODEBUG=http2debug=2`
```
http2: Transport encoding header "user-agent" =
"godatabrickssqlconnector/1.10.0 agent/claude-code"
```
- [x] Executed `SELECT 1` successfully against dogfood warehouse with
the new header
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
vikrantpuppala added a commit to databricks/databricks-jdbc that referenced this pull request Apr 13, 2026
)
## Summary
- Adds `AgentDetector` utility class that detects 7 AI coding agents
(Claude Code, Cursor, Gemini CLI, Cline, Codex, OpenCode, Antigravity)
by checking well-known environment variables they set in spawned shell
processes
- Integrates detection into `UserAgentManager` to append
`agent/<product>` to the User-Agent header on both SDK-based and
connector-service UA paths
- Uses exactly-one detection rule: if zero or multiple agent env vars
are set, no agent is attributed (avoids ambiguity)
## Approach
Mirrors the implementation in
[databricks/cli#4287](databricks/cli#4287) and
aligns with the latest agent list in
[`libs/agent/agent.go`](https://github.com/databricks/cli/blob/main/libs/agent/agent.go#L35).
| Agent | Product String | Environment Variable |
|-------|---------------|---------------------|
| Google Antigravity | `antigravity` | `ANTIGRAVITY_AGENT` |
| Claude Code | `claude-code` | `CLAUDECODE` |
| Cline | `cline` | `CLINE_ACTIVE` |
| OpenAI Codex | `codex` | `CODEX_CI` |
| Cursor | `cursor` | `CURSOR_AGENT` |
| Gemini CLI | `gemini-cli` | `GEMINI_CLI` |
| OpenCode | `opencode` | `OPENCODE` |
Adding a new agent requires only a new constant and a new entry in the
`KNOWN_AGENTS` array.
## Changes
- **New**: `AgentDetector.java` — environment-variable-based agent
detection with injectable env lookup for testability
- **Modified**: `UserAgentManager.java` — calls `AgentDetector.detect()`
in both `setUserAgent()` and `buildUserAgentForConnectorService()`
- **New**: `AgentDetectorTest.java` — 12 test cases covering single
agent, no agent, multiple agents, empty values, null values, and full
coverage of all known agents
## Test plan
- [x] `AgentDetectorTest` — 12 tests pass (single agent detection for
all 7 agents, no agent, multiple agents, empty/null values)
- [x] `UserAgentManagerTest` — all 7 existing tests continue to pass
- [x] Manual: verify User-Agent header contains `agent/claude-code` when
run from Claude Code
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
vikrantpuppala added a commit to databricks/databricks-sql-nodejs that referenced this pull request Apr 13, 2026
Add AI coding agent detection to User-Agent header
Detect when the Node.js SQL driver is invoked by an AI coding agent
(e.g. Claude Code, Cursor, Gemini CLI) by checking well-known
environment variables, and append `agent/<product>` to the User-Agent
string.
This enables Databricks to understand how much driver usage originates
from AI coding agents. Detection only succeeds when exactly one agent
is detected to avoid ambiguous attribution.
Mirrors the approach in databricks/cli#4287.
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
vikrantpuppala added a commit to databricks/databricks-sql-python that referenced this pull request Apr 13, 2026
Detect when the Python SQL connector is invoked by an AI coding agent
(e.g. Claude Code, Cursor, Gemini CLI) by checking well-known
environment variables, and append `agent/<product>` to the User-Agent
string.
This enables Databricks to understand how much driver usage originates
from AI coding agents. Detection only succeeds when exactly one agent
is detected to avoid ambiguous attribution.
Mirrors the approach in databricks/cli#4287.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
vikrantpuppala added a commit to databricks/databricks-sql-python that referenced this pull request Apr 13, 2026
Add AI coding agent detection to User-Agent header
Detect when the Python SQL connector is invoked by an AI coding agent
(e.g. Claude Code, Cursor, Gemini CLI) by checking well-known
environment variables, and append `agent/<product>` to the User-Agent
string.
This enables Databricks to understand how much driver usage originates
from AI coding agents. Detection only succeeds when exactly one agent
is detected to avoid ambiguous attribution.
Mirrors the approach in databricks/cli#4287.
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
jiabin-hu pushed a commit to jiabin-hu/databricks-sql-nodejs that referenced this pull request Apr 28, 2026
…tabricks#333)
Add AI coding agent detection to User-Agent header
Detect when the Node.js SQL driver is invoked by an AI coding agent
(e.g. Claude Code, Cursor, Gemini CLI) by checking well-known
environment variables, and append `agent/<product>` to the User-Agent
string.
This enables Databricks to understand how much driver usage originates
from AI coding agents. Detection only succeeds when exactly one agent
is detected to avoid ambiguous attribution.
Mirrors the approach in databricks/cli#4287.
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Jiabin Hu <jiabin.hu@databricks.com>
denik pushed a commit that referenced this pull request May 20, 2026
## Changes
Adds libs/agent package to detect AI agents (Claude Code, Gemini CLI,
Cursor) via environment variables. Used in user agent tracking and
available for telemetry and (future, optional) conditional behavior.
Detection only succeeds when exactly one agent environment variable is
set, preventing ambiguous detection in environments with multiple
agents.
Implementation:
- libs/agent: Detection logic with Detect(), Product(), and Mock()
- cmd/root: Integrated agent detection into command execution
Environment variable sources:
- CLAUDECODE=1: anthropics/claude-code#531
- GEMINI_CLI=1:
https://github.com/google-gemini/gemini-cli/blob/main/docs/cli/commands.md
- CURSOR_AGENT=1:
https://forum.cursor.com/t/cursor-cli-is-not-setting-cursor-agent-1-environment-variable-while-executing-bash-commands/132427
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
denik pushed a commit that referenced this pull request May 20, 2026
## Why
This packages was added in #4287 and centralizes agent detection.
## Tests
Manually confirmed install with `CLAUDECODE=1` and `CURSOR_AGENT=1`.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@pietern@eng-dev-ecosystem-bot@fjakobs@lennartkats-db