Commit f03b6da
authored
Expand AI agent detection: Goose, Amp, Augment, Copilot (VS Code), Kiro, Windsurf (#1394)
## Why
We identify which AI agent is driving the SDK via the `agent/<name>`
user-agent segment. The current list covers 9 agents. This adds 6 more
and honors the emerging `AGENT=<name>` standard from agents.md so we can
see traffic from agents we haven't individually listed yet.
## Changes
Before: presence-only matching on a fixed list of env vars; multi-match
returns empty.
Now: each agent record has a list of matchers (env var plus optional
exact value), an agent fires if any matcher fires, ambiguity is judged
by unique product (not raw matcher count), and an `AGENT=<anything>`
fallback reports `unknown` when no specific entry matched.
Implementation:
- `databricks/sdk/useragent.py`: replaced the `_KNOWN_AGENTS` dict with
a list of `_AgentRecord` dataclasses each holding a `product` and a list
of `(env_var, value)` matchers. Rewrote `agent_provider()` to count
unique agents matched, handle the single/multi/zero cases, and fall back
to `unknown` when `AGENT` is set non-empty but no specific agent
matched. Cached result (`_agent_provider`) still uses the `None` vs `""`
sentinel pattern.
- `tests/test_user_agent.py`: added coverage for each new agent (goose,
amp, augment, copilot-vscode, kiro, windsurf), both Goose signals
together (not ambiguous), both Amp signals together (not ambiguous),
unknown fallback, empty `AGENT` does not trigger fallback, and
cross-agent ambiguity (`AGENT=goose` + `CLAUDECODE=1`).
- `NEXT_CHANGELOG.md`: entry under "Internal Changes".
New detections: Goose (`GOOSE_TERMINAL` or `AGENT=goose`), Amp
(`AMP_CURRENT_THREAD_ID` or `AGENT=amp`), Augment (`AUGMENT_AGENT`), VS
Code Copilot (`COPILOT_MODEL`), Kiro (`KIRO`), Windsurf
(`WINDSURF_AGENT`).
Parallel PRs with identical behavior are being opened in
`databricks-sdk-go` and `databricks-sdk-java`.
## Test plan
- [x] `python3 -m pytest tests/test_user_agent.py -v` passes (37 tests)
- [x] `make fmt` leaves the three modified files clean
- [x] Each new product detected when its primary env var is set
- [x] `AGENT=goose` alone returns `goose`
- [x] `GOOSE_TERMINAL=1` + `AGENT=goose` returns `goose` (not ambiguity)
- [x] `AMP_CURRENT_THREAD_ID` + `AGENT=amp` returns `amp` (not
ambiguity)
- [x] `AGENT=someweirdthing` returns `unknown`
- [x] `AGENT=""` returns `""` (fallback only fires on non-empty value)
- [x] Two distinct agents set simultaneously return `""`
- [x] `AGENT=goose` + `CLAUDECODE=1` returns `""` (cross-agent
ambiguity)
---------
Signed-off-by: simon <simon.faltum@databricks.com>1 parent 5724d13 commit f03b6da
3 files changed
Lines changed: 250 additions & 27 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
17 | 19 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
224 | 225 | | |
225 | 226 | | |
226 | 227 | | |
227 | | - | |
| 228 | + | |
228 | 229 | | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
240 | 260 | | |
241 | 261 | | |
242 | 262 | | |
| |||
247 | 267 | | |
248 | 268 | | |
249 | 269 | | |
250 | | - | |
251 | | - | |
252 | | - | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
253 | 281 | | |
254 | | - | |
255 | | - | |
256 | | - | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
257 | 287 | | |
258 | 288 | | |
259 | 289 | | |
260 | 290 | | |
261 | 291 | | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
266 | 299 | | |
267 | | - | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
268 | 306 | | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
184 | 296 | | |
| 297 | + | |
| 298 | + | |
185 | 299 | | |
186 | 300 | | |
187 | 301 | | |
188 | 302 | | |
189 | | - | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
190 | 336 | | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
191 | 344 | | |
192 | | - | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
193 | 362 | | |
194 | 363 | | |
195 | 364 | | |
196 | | - | |
| 365 | + | |
197 | 366 | | |
198 | 367 | | |
199 | 368 | | |
| |||
217 | 386 | | |
218 | 387 | | |
219 | 388 | | |
220 | | - | |
| 389 | + | |
221 | 390 | | |
222 | 391 | | |
223 | 392 | | |
| |||
0 commit comments