Repository navigation
Add DATABRICKS_NOT_AN_AGENT to turn off agent detection - #8126
simonfaltum wants to merge 9 commits into
Conversation
…calls it Agent detection reads the calling agent's own environment, so a baseline run of an eval still sees the agent and gets the agent-facing output. With DATABRICKS_NOT_AN_AGENT set to a true value, detection reports no agent: stderr hints, the group help footer, the agent quickstart, auto-install and the calling agent in MCP telemetry are all off, as they are for a person. Unset, nothing changes. Co-authored-by: Isaac <no-reply@databricks.com>
Regression test report ✅Commit: Selected 1 changed tests (limit=20, 0 not selected) 1 tests: regression=1 unreleased=0 coverage=0 failing=0
TestAccept/cmd/aitools/not-an-agent: branch ✅ | main (e6f3460) ❌ | latest (v1.28.0) ❌main (e6f3460): latest (v1.28.0): |
Claude Code's hint throttle is keyed by CLAUDE_CODE_SESSION_ID. Developer machines inherit that id, so the test passed locally, but CI has none and printed the hint on every call. Set it in the script so the output does not depend on the environment. Co-authored-by: Isaac <no-reply@databricks.com>
✅ Integration test reportCommit: 1077d97
Top 6 slowest tests (at least 2 minutes):
|
…icks-not-an-agent-makes-the-cli-ac
MaybeVersionCheckTip, PrintSkillsTip and RecommendSkillsInstall do nothing under DATABRICKS_NOT_AN_AGENT, so an eval baseline sees no install tip and no prompt. The MCP telemetry calling agent is read through agent.Provider at its source instead of being blanked after the event is built, so an explicit serve --agent value is kept. The acceptance test gives its no-hint steps a fresh Claude session id, so the positive control's throttle marker cannot hide a regression. Co-authored-by: Isaac <no-reply@databricks.com>
…ENT in hostenv callingAgentType now calls agents.CallingAgent instead of re-implementing it. The test host environment lists DATABRICKS_NOT_AN_AGENT next to the other agent variables, so a developer shell that exports it does not change the goldens. The notAnAgentEnv doc now says that agent tips and notes are suppressed too. Co-authored-by: Isaac <no-reply@databricks.com>
…icks-not-an-agent-makes-the-cli-ac Keeps main's removal of the auto-install prompt (#8135). The interactive flag now reads agent.Provider, so DATABRICKS_NOT_AN_AGENT keeps it off. Co-authored-by: Isaac <no-reply@databricks.com>
There was a problem hiding this comment.
Automated review at 8503762. Each finding was verified against the code.
No blocking issues found. 4 non-blocking comment(s) below.
This PR adds DATABRICKS_NOT_AN_AGENT, which makes the CLI's agent detection report no agent. It routes the CLI's readers through agent.Provider(ctx) and turns off the hints, tips, the help footer, the agent quickstart text and auto-install. The plumbing is consistent and I found no correctness bugs in the threaded calls. I have four smaller points. The auto-install skip happens outside Decide, so auto-install enable reports success with no warning. The acceptance test has no positive control for the root --help line. There is no changelog fragment, even though the behavior is not gated. The script sends output to /dev/null where the testing rule asks for LOG.*.
| ctx := cmd.Context() | ||
| // A run that does not notice agents (DATABRICKS_NOT_AN_AGENT) installs nothing and asks nothing, so an eval | ||
| // baseline keeps its machine as it is. | ||
| if agent.NotAnAgent(ctx) { |
There was a problem hiding this comment.
[nice to have] This skip sits outside autoinstall.Decide/Inputs, which hold every other skip reason (OnRuntime, CI, EnvOptOut, RootInUserHome), so the code that explains the setting never hears about it. With DATABRICKS_NOT_AN_AGENT=1, databricks aitools auto-install enable prints "Automatic installation of Databricks AI tools is enabled." with no warning, even though the hook never runs. printAutoInstallSetting does print a yellow warning when DATABRICKS_AITOOLS_AUTO_INSTALL is the override. Could this become a non-due Reason in Decide, plus a matching line in printAutoInstallSetting and the auto-install help? Or could the baseline just set the existing DATABRICKS_AITOOLS_AUTO_INSTALL=false?
There was a problem hiding this comment.
Took the warning route, not the Decide reason. auto-install enable now prints a yellow line when DATABRICKS_NOT_AN_AGENT still stops the hook in this environment, the same as it does for DATABRICKS_AITOOLS_AUTO_INSTALL. The skip stays at the top of AutoInstall, before the state is read, so a stopped run writes nothing. Setting the existing override in the baseline would not be enough: this switch also turns off the footer and quickstart text that the baseline needs to see as human output. The not-an-agent acceptance script covers the enable output.
|
|
||
| title "With the variable set, the help has no skills footer" | ||
| trace DATABRICKS_NOT_AN_AGENT=1 CLAUDECODE=1 $CLI fs --help | tail -n 3 | ||
| trace DATABRICKS_NOT_AN_AGENT=1 CLAUDECODE=1 $CLI --help | tail -n 2 |
There was a problem hiding this comment.
[nice to have] Nothing in this script runs root --help without the variable. This step would still pass if rootSkillsHint were never printed for some other reason. The fs --help and quickstart steps do have a run without the variable. Can you add trace CLAUDECODE=1 $CLI --help | tail -n 2 to the first section, so the golden shows the line there and shows it missing here?
There was a problem hiding this comment.
Done. The first section now runs CLAUDECODE=1 $CLI --help | tail -n 2, so the golden shows the skills line there, and the variable section shows it missing.
| // notAnAgentEnv makes the CLI act as if no agent calls it, for example when an eval runs a baseline arm. Agent | ||
| // detection reports no agent, so every agent-facing output is the human one, and agent tips and notes are | ||
| // suppressed too. | ||
| const notAnAgentEnv = "DATABRICKS_NOT_AN_AGENT" |
There was a problem hiding this comment.
[nice to have] The description says there is no changelog entry "while the feature is gated". But NotAnAgent reads DATABRICKS_NOT_AN_AGENT directly, with no preview or hints flag in front of it. With DATABRICKS_NOT_AN_AGENT=1 CLAUDECODE=1, bundle destroy drops its "do not retry" note, feedback --yes=false is no longer refused, and auto-install never runs. The same holds when no DATABRICKS_SKILLS_* flag is set. .agents/rules/changelog.md asks for a fragment under .nextchanges/ for a user-visible change, probably .nextchanges/cli/. Can you add one?
There was a problem hiding this comment.
No changelog fragment in this PR, as planned. This switch is part of the skills feature, which stays gated until its launch change, and the user-facing note goes with that change. With the variable unset, output is unchanged. Leaving the fragment question to the maintainers if they want it earlier.
| title "Claude Code is hinted, and its help and quickstart are the agent ones" | ||
| trace CLAUDECODE=1 $CLI jobs list | ||
| trace CLAUDECODE=1 $CLI fs --help | tail -n 3 | ||
| trace CLAUDECODE=1 $CLI quickstart | contains.py 'databricks skills list' > /dev/null |
There was a problem hiding this comment.
[nit] .agents/rules/testing.md asks for discarded output to go to LOG.<name> rather than /dev/null, so it still shows under go test -v. This line and line 29 throw away the full quickstart text after contains.py. Can they write to something like > LOG.quickstart-agent and > LOG.quickstart-human instead?
There was a problem hiding this comment.
Done. The two quickstart checks now write to LOG.quickstart-agent and LOG.quickstart-human, so the text shows under go test -v.
auto-install enable now says when DATABRICKS_NOT_AN_AGENT still stops the hook in this environment, as it already does for DATABRICKS_AITOOLS_AUTO_INSTALL. The not-an-agent acceptance script shows the --help footer line in the first section, routes the quickstart discards to LOG files, and covers the enable output. Co-authored-by: Isaac <no-reply@databricks.com>
…icks-not-an-agent-makes-the-cli-ac
rugpanov
left a comment
There was a problem hiding this comment.
Thanks for this change. The switch to agent.Provider(ctx) is complete in the files that the diff touches. The tests cover the parse rules and the skipped nudges. CI passes on this head: 28 check runs are complete, with 0 failures.
I have 1 question about safety notes, 2 nice-to-have points and 3 nits, all inline.
I do not repeat the two open review-oss-bot threads:
- The
auto-installLonghelp still does not nameDATABRICKS_NOT_AN_AGENT(#8126 (comment)). - The changelog fragment (#8126 (comment)). The description says "No changelog entry while the feature is gated", but
NotAnAgentreads the environment with no gate. The maintainers must decide on that thread.
Risk: LOW. With the variable unset, agent.Provider(ctx) returns the same value as useragent.AgentProvider(), so CLI behavior does not change. The acceptance goldens pass on Linux, macOS and Windows. The new behavior is opt-in through one environment variable, reaches only agent notes, nudges and telemetry, and ships in a CLI release that is easy to roll back.
| "", | ||
| } | ||
| if note := agent.AgentNote(agentNote); note != "" { | ||
| if note := agent.AgentNote(ctx, agentNote); note != "" { |
There was a problem hiding this comment.
[Question] Is it intended that DATABRICKS_NOT_AN_AGENT also removes this note? AgentNote now reads agent.Provider(ctx). With CLAUDECODE=1 DATABRICKS_NOT_AN_AGENT=1, the agent does not see "Do not open the URL or approve the login yourself: the user must approve it."
The same change removes the "do not retry with the flag" notes of bundle deploy, bundle destroy and bind. The "Decisions to review" section names the destroy note and the feedback refusal, but not this login note.
The answer matters because this note stops an agent from approving its own login. Also, the eval baseline then differs from the treatment arm in safety notes, not only in nudges. If this is not intended, keep the safety notes on useragent.AgentProvider(), and use agent.Provider(ctx) only for nudges.
There was a problem hiding this comment.
Not intended for this note, or for the other safety notes. In 1077d97 the notes read useragent.AgentProvider again, so the login approval note, the "do not retry with the flag" notes of bundle deploy, destroy and bind, and the feedback --yes=false refusal keep their behaviour under the variable. Only nudges and records read agent.Provider(ctx), which is what the variable is for. TestAgentNoteKeepsSafetyNoteNotAnAgent covers the note, and the PR description lists this under Decisions to review.
| "COPILOT_CLI", | ||
| "COPILOT_HOME", | ||
| "CURSOR_AGENT", | ||
| "DATABRICKS_NOT_AN_AGENT", |
There was a problem hiding this comment.
[nice to have] This entry has no effect, because isolate() already unsets every DATABRICKS_* variable. The acceptance harness needs it instead, and it does not unset it.
acceptance/acceptance_test.go unsets the agent variables and DATABRICKS_SKILLS_INVOKED. Then auth.ProcessEnv passes the rest of the host environment to each script. The new test.toml does not unset the variable either.
Result: when a developer or an eval baseline runs go test ./acceptance with DATABRICKS_NOT_AN_AGENT=1, the positive-control steps lose the hint, the help footer and the agent quickstart. The not-an-agent golden fails, and other agent goldens such as agent-hints can fail too.
Add os.Unsetenv("DATABRICKS_NOT_AN_AGENT") next to the DATABRICKS_SKILLS_INVOKED unset in acceptance/acceptance_test.go.
There was a problem hiding this comment.
Done in 1077d97. acceptance/acceptance_test.go now unsets DATABRICKS_NOT_AN_AGENT next to DATABRICKS_SKILLS_INVOKED, so go test ./acceptance starts without it whatever the host shell exports. I also removed the hostenv.go entry, since isolate() already unsets every DATABRICKS_* variable and the entry had no effect.
| // detected, several are, or the CLI cannot install into the agent. | ||
| func WithCallingAgentToolingInUserAgent(ctx context.Context) context.Context { | ||
| a := agents.CallingAgent() | ||
| a := agents.CallingAgent(ctx) |
There was a problem hiding this comment.
[nice to have] Under DATABRICKS_NOT_AN_AGENT=1, this drops the aitools-agent/<tooling> pair, but SDK requests still send agent/<name>. The comment at lines 21-22 says that this pair is "Paired with the SDK's agent/ key" to give a per-agent install rate.
Until the SDK follow-up lands, baseline traffic counts as claude-code requests with no tooling data. In the same session, the MCP proxy User-Agent (libs/aitools/mcp/proxy/run.go:54) shows no agent.
Keep the User-Agent readers on useragent.AgentProvider() until the SDK follow-up. If you keep this change, name this skew in the description.
There was a problem hiding this comment.
Kept on purpose, and the skew is now named under Decisions to review. Telemetry follows detection, as the ticket asks, so the CLI own pairs (aitools-agent and the MCP proxy agent) drop the agent under the variable. The SDK agent/ header still reads useragent.AgentProvider until the SDK follow-up in the stacked pull requests #8143 and #8144 lands. Until then a baseline request names the agent with no aitools-agent pair, so install-rate counts include baseline traffic for that agent. Keeping the pairs on the raw detection would make them match the SDK header instead, and the maintainer can choose that if preferred.
| } | ||
|
|
||
| // Provider returns the agent name that useragent.AgentProvider reports, or "" when no agent is detected or | ||
| // NotAnAgent holds. The CLI's own readers of the calling agent (output, telemetry, the User-Agent) go through it. |
There was a problem hiding this comment.
[nit] This line says that the User-Agent goes through Provider. The next line says that the SDK agent header does not. Both lines are about the same User-Agent header. Write "the CLI's own User-Agent pairs" here, so that a reader does not expect the full header to change.
There was a problem hiding this comment.
Done in 1077d97. The comment now says the CLI own User-Agent pairs go through Provider, and the SDK header is named as the one that does not.
| } else { | ||
| content = quickstartFor(cmdio.IsPromptSupported(cmd.Context()), skillsVariant) | ||
| ctx := cmd.Context() | ||
| content = quickstartFor(cmdio.IsPromptSupported(ctx) || agent.NotAnAgent(ctx), skillsVariant) |
There was a problem hiding this comment.
[nit] The Long help at lines 53-55 still says that a non-interactive caller gets the agent version. With DATABRICKS_NOT_AN_AGENT=1, this call now prints the human guide. Add one sentence about the variable to the Long text. Also think about a new name for the interactive parameter of quickstartFor, because it now means "show the human guide".
There was a problem hiding this comment.
Renamed the parameter to humanGuide in 1077d97. I did not add the variable to the Long help. It is an eval switch with no changelog entry until launch, and the help text is user-visible and ungated, so naming it there would document a switch before launch. The Long text still describes the default, which does not change with the variable unset.
| trace DATABRICKS_NOT_AN_AGENT=1 CLAUDECODE=1 $CLI aitools auto-install enable | ||
|
|
||
| title "A false value leaves agent detection on" | ||
| trace DATABRICKS_NOT_AN_AGENT=0 CODEX_CI=1 CODEX_THREAD_ID=thread-1 $CLI jobs list |
There was a problem hiding this comment.
[nit] This control uses a new agent and thread (CODEX_CI=1 CODEX_THREAD_ID=thread-1). So no step shows that the variable-set runs on session-2 wrote no throttle marker. A regression that hides the hint but still writes the marker passes this test. Add a CLAUDECODE=1 $CLI jobs list step on session-2 with the variable unset, and expect the hint.
There was a problem hiding this comment.
Done in 1077d97, and the golden is regenerated. After the variable run on session-2, a step runs CLAUDECODE=1 jobs list with the variable unset, and the golden shows the hint there, so the variable run wrote no throttle marker.
DATABRICKS_NOT_AN_AGENT hides the calling agent from nudges and records. The notes that ask an agent not to act for the user (approving a login, retrying with a flag the user has not approved) and the feedback --yes=false refusal still read the detected agent, so an eval baseline keeps them. The acceptance harness now unsets the variable, the quickstart test pins it off, and the not-an-agent script checks that the hint still shows on the same session once the variable is unset. Co-authored-by: Isaac <no-reply@databricks.com>
Add DATABRICKS_NOT_AN_AGENT to turn off agent detection
Evals compare an agent with and without the CLI's agent nudges, but a baseline run still inherits the calling agent's environment, so the CLI detects the agent and prints agent-facing output. With
DATABRICKS_NOT_AN_AGENTset to a true value, agent detection reports no agent for the nudges and records, and those outputs are the human ones.Changes
aitoolsinstall text, the skills list text, theapps initandversion --checktips, and the install prompt. Auto-install neither prompts nor runs, andauto-install enablesays the variable still stops it here.databricks quickstartprints the human guide.aitools mcp serve --agentvalue still reaches telemetry.bundle deploy,bundle destroyandbind, the login approval note, and thefeedback --yes=falserefusal still read the detected agent.Why
An eval's baseline arm needs the CLI to behave as it does for a person, while the agent's own environment stays as it is. The variable tells the CLI that no agent is calling it for nudges and records. The safety notes ask the agent not to act for the user, so they are not nudges, and the baseline keeps them.
Decisions to review
feedback --yes=falserefusal. Cost: a baseline arm still sees those lines, so it differs from a person in them.aitools-agent, and the MCP proxy's agent) follow the variable, but the Go SDK still sendsagent/<name>fromuseragent.AgentProvider, which the CLI cannot change. Cost: until the SDK follow-up lands in the stacked pull requests Drop the SDK agent token from User-Agent under DATABRICKS_NOT_AN_AGENT #8143 and Apply the not-an-agent header guard to the remaining CLI SDK clients #8144, a baseline request carriesagent/<name>with noaitools-agentpair, so install-rate counts for that agent include baseline traffic.agents.CallingAgent, which usesagent.Provider, rather than blanking the event afterwards, so an explicit--agentis recorded.Tests
TestNotAnAgentandTestNotAnAgentFromEnvironment(libs/agent) cover unset, set, false, invalid values and the environment variable.TestAgentNoteKeepsSafetyNoteNotAnAgent(libs/agent) covers a safety note that still shows under the variable.TestMaybeHint_NotAnAgentSilent,TestMaybeVersionCheckTip,TestPrintSkillsTipNotAnAgentandTestRecommendSkillsInstallNotAnAgentcover the tips and the recommendation.TestCallingAgentNotAnAgentandTestLogMcpEventKeepsExplicitAgentNotAnAgentcover a detected agent (dropped) and an explicit--agent(kept).acceptance/cmd/aitools/not-an-agentshows the hint, the skills footer and the agent quickstart without the variable, and none of them with it. Its last step shows the hint again on the same session once the variable is unset, so the variable run wrote no throttle marker.go testpasses for the packages this change touches, with the variable unset.libs/agent,cmd/quickstart,cmd/feedback,libs/aitools/agents,cmd/aitoolsandcmd/rootalso pass with it exported.TestAccept/cmd/skills,TestAccept/cmd/aitools(includingnot-an-agent),TestAccept/quickstartandTestAccept/cmd/feedback../task --force fmt-q lint-qreports no issues../task aitools-full, because they were not run for this change.TestAccept/helpandTestAccept/cmd/versionwere not re-run on this head.This pull request and its description were written by Isaac.