Skip to content

Commit 7d64ca7

Browse files
atishpatelclaude
andauthored
fix(agents): run live Databricks discovery instead of the fallback list (#2890)
## Problem The Databricks model dropdown offers a handful of stale models — and there's no way to tell that list apart from the real one. The AI Gateway exposes **66** chat/embedding endpoints on `block-lakehouse-production`, but the picker was showing a short list that includes models the gateway no longer serves and embedding endpoints that can't chat at all. Three independent defects, all on the discovery path: **1. Live discovery never ran for agents with no saved provider.** `get_agent_models` gates every in-process discovery attempt on the provider (`is_openai_compatible_provider` / `is_anthropic_provider` / `is_databricks_provider`), reading it straight from `record.provider`. That field is `null` for every agent record created before provider persistence — and for any agent that inherits its provider from the build. So all three gates saw `None`, no HTTP discovery ran, and the request fell through to the `buzz-acp models` subprocess. On the Databricks path that subprocess returns `discovery_failure_fallback` — the small hardcoded `DATABRICKS_V2_KNOWN_MODELS` catalog — which the frontend renders exactly like a live catalog. An internal DMG that bakes `BUZZ_AGENT_PROVIDER=databricks_v2` and a `DATABRICKS_HOST` still got the fallback. **2. The fallback list couldn't represent the running model.** When discovery genuinely fails, the picker should at minimum be able to show what the agent is actually configured with. For `DatabricksV2` it couldn't: the fallback returned only the hardcoded slate, so a model like `databricks-gpt-5-5` wasn't selectable in its own picker. **3. Embedding endpoints were offered as chat models.** `databricks-bge-large-en` was selectable (visible in the dialog today). The v2 endpoints payload carries no `task` or `state` field, so there is nothing to filter on but the name. ## Changes - **`effective_discovery_provider`** (new, `desktop/src-tauri/src/commands/agent_models_env.rs`) — an explicit provider (saved record value, or the create/edit dialog's current form value) still always wins; when there is none, discovery falls back to the runtime's own provider env var (`GOOSE_PROVIDER`, `BUZZ_AGENT_PROVIDER`, …) read off the merged env, which by that point already carries the baked build floor and the process env. Wired into both `get_agent_models` and `discover_agent_models`. `SavedAgentModelDiscoveryConfig` now carries `provider_env_var` from `known_acp_runtime`, so each runtime reads *its own* key rather than a shared guess. - The relay-mesh branches in `discover_agent_models` deliberately keep using `input.provider`: those key off a deliberate provider selection, never a baked default. - **Asserted vs inferred matters for missing credentials.** The OpenAI and Anthropic gates error on a missing API key, while the Databricks gate falls through; an inferred provider hitting the first two would have replaced a working subprocess catalog with `config: ANTHROPIC_API_KEY required` (`export GOOSE_PROVIDER=anthropic` is goose's documented way to pick a provider, and it keeps the key in its own keyring). So `effective_discovery_provider` returns a `DiscoveryProvider` that remembers how the value was resolved, and `required_env` only reports a missing credential for an asserted provider. A wrong guess declines and lets the subprocess answer. - **`is_chat_capable_endpoint`** (new, `crates/buzz-agent/src/catalog.rs`) — applied in `parse_v2_endpoints_page`. Drops `*embedding*` and segment-matched `bge` / `gte` endpoints; keeps everything unrecognised (fail-open, so a new model family is never hidden). Segment matching is why it's `split('-')` and not `contains`: a substring check would swallow legitimate names. - **`discovery_failure_fallback`** for `Provider::DatabricksV2` now leads with the configured model (deduped against the known slate, blank-tolerant), so a failed discovery still yields a picker that can show the running model. The configured model is trimmed once up front — `resolve_model` doesn't trim, so a padded `DATABRICKS_MODEL` used to slip past the dedupe and appear twice. - **`sort_v2_endpoints_newest_first`** (new, second commit) — the catalog is now ordered newest-first on each endpoint's `created_timestamp`, ties broken by name. Previously Buzz sorted nothing, so the gateway's own order reached the picker: it pages in two phases (Databricks-managed, then workspace-created — the page token decodes to `{"phase":"user"}`), each alphabetical, which buried `databricks-claude-opus-5` 8th behind five older Claude endpoints and `goose-claude-opus-5` — the newest endpoint in the catalog — 55th of 63. Sorting in `fetch_v2_models` means both discovery paths inherit it with no wire or type changes, and the combobox filter preserves incoming order. Endpoints with an absent or unparseable timestamp sort last rather than first, so a wire-shape change degrades to "unordered at the bottom" instead of "shuffled to the top". - The name tiebreak is load-bearing: eleven managed endpoints share one placeholder timestamp (`1699610000000`), so without it their relative order would vary between runs. That placeholder is also not always accurate — a few genuinely recent endpoints (`databricks-kimi-k2-7-code`, `databricks-llama-4-maverick`) land at the bottom with the 2023 batch. The gateway offers nothing better to sort on. - Env/provider lookup helpers moved out of `agent_models.rs` into `agent_models_env.rs`. This keeps the command module under the file-size limit **without ratcheting the override up** — the existing 1079 entry is untouched (file is now 1066 lines). ## Verification Live against `block-lakehouse-production`, release build: ``` BUZZ_ACP_AGENT_COMMAND=$PWD/target/release/buzz-agent \ BUZZ_AGENT_PROVIDER=databricks_v2 \ DATABRICKS_HOST=https://block-lakehouse-production.cloud.databricks.com \ DATABRICKS_MODEL=databricks-gpt-5-5 \ ./target/release/buzz-acp models --json ``` - before: 66 endpoints, including `databricks-bge-large-en`, `databricks-gte-large-en`, `databricks-qwen3-embedding-0-6b` - after: **63** endpoints, `[.models[] | select(.id | test("embedding|-bge-|-gte-"))]` → `[]` Top of the list after the sort commit: ``` goose-claude-opus-5 2026-07-24 databricks-claude-opus-5 2026-07-23 databricks-gemini-3-6-flash 2026-07-20 databricks-gemini-3-5-flash-lite 2026-07-20 databricks-inkling 2026-07-14 ``` Tests: 15 new (8 in `catalog.rs` — including the two-wire-shape timestamp parse, the sort's tiebreak/no-timestamp cases, and the padded-model dedupe — and 7 plus one assertion in `agent_models_tests.rs`, 3 of them covering the asserted/inferred credential split), two existing tests updated. `just check`, `just test-unit`, and `just desktop-tauri-test` all pass (1636 desktop-tauri tests, 274 buzz-agent lib tests). Not run locally: the Docker-backed integration suite (`just test`) — this diff touches neither `buzz-relay`, `buzz-db`, nor `buzz-auth`. ## Follow-ups (deliberately out of scope) Two inference-path defects found while investigating, both reproduced live against the gateway and both independent of discovery: 1. **Gemini thought signatures are dropped.** The gateway returns a bare `thoughtSignature` on tool calls; the external-model serving endpoints return it nested as `extra_content.google.thought_signature`. Neither shape is round-tripped, so multi-turn tool use on `databricks-gemini-*` fails with a 400 on the second turn. 2. **Array-shaped `content` is silently discarded.** Some models return OpenAI `content` as a block array rather than a string; `parse_openai`'s `str_field` returns `None` and the text is dropped. The legacy `serving-endpoints` path does not work around either one, and costs reasoning support on the GPT-5 family. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
1 parent dba1ba5 commit 7d64ca7

6 files changed

Lines changed: 583 additions & 96 deletions

File tree

‎crates/buzz-agent/src/catalog.rs‎

Lines changed: 260 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -37,34 +37,74 @@ pub const DATABRICKS_V2_KNOWN_MODELS: &[&str] =
3737
/// This is the list of models advertised by `session/new` when
3838
/// `discover_databricks_models` returns an error (e.g., no token available).
3939
///
40-
/// - `DatabricksV2` falls back to [`DATABRICKS_V2_KNOWN_MODELS`] so the
41-
/// model-picker is always populated for AI Gateway v2 users.
40+
/// - `DatabricksV2` falls back to the configured model plus
41+
/// [`DATABRICKS_V2_KNOWN_MODELS`] so the model-picker is always populated for
42+
/// AI Gateway v2 users. The configured model leads: without it a fallback
43+
/// catalog can omit the very model the agent is running, leaving the picker
44+
/// unable to represent the current selection.
4245
/// - Legacy `Databricks` falls back to only the configured model — the
4346
/// `DATABRICKS_V2_KNOWN_MODELS` IDs are AI Gateway v2 endpoints that the
4447
/// `/serving-endpoints/{model}/invocations` API may not serve.
4548
///
4649
/// Extracting this as a pure function makes the split testable without
4750
/// spawning an async runtime or making network calls.
4851
pub fn discovery_failure_fallback(provider: Provider, configured_model: &str) -> Vec<ModelEntry> {
52+
// `resolve_model` does not trim, so a padded `DATABRICKS_MODEL` reaches here:
53+
// normalize once, or the dedupe below misses and the picker lists the model
54+
// twice (once padded, once from the known slate).
55+
let configured_model = configured_model.trim();
56+
let configured = ModelEntry {
57+
id: configured_model.to_string(),
58+
name: configured_model.to_string(),
59+
};
4960
match provider {
50-
Provider::DatabricksV2 => DATABRICKS_V2_KNOWN_MODELS
51-
.iter()
52-
.map(|id| ModelEntry {
53-
id: id.to_string(),
54-
name: id.to_string(),
55-
})
56-
.collect(),
57-
Provider::Databricks => vec![ModelEntry {
58-
id: configured_model.to_string(),
59-
name: configured_model.to_string(),
60-
}],
61-
_ => vec![ModelEntry {
62-
id: configured_model.to_string(),
63-
name: configured_model.to_string(),
64-
}],
61+
Provider::DatabricksV2 => {
62+
let mut entries = Vec::with_capacity(DATABRICKS_V2_KNOWN_MODELS.len() + 1);
63+
if !configured_model.is_empty() {
64+
entries.push(configured);
65+
}
66+
entries.extend(
67+
DATABRICKS_V2_KNOWN_MODELS
68+
.iter()
69+
.filter(|id| **id != configured_model)
70+
.map(|id| ModelEntry {
71+
id: id.to_string(),
72+
name: id.to_string(),
73+
}),
74+
);
75+
entries
76+
}
77+
Provider::Databricks => vec![configured],
78+
_ => vec![configured],
6579
}
6680
}
6781

82+
/// Heuristic: `true` when a v2 AI Gateway endpoint name looks like it serves
83+
/// chat/completions traffic.
84+
///
85+
/// The v1 `serving-endpoints` payload carries `task`, so [`parse_v1_endpoints`]
86+
/// can filter on it directly. The v2 `ai-gateway/v2/endpoints` payload carries
87+
/// no task or readiness field at all, so the only signal available here is the
88+
/// endpoint name. Embedding endpoints are the one family that reliably cannot
89+
/// serve a chat request — they reject it with
90+
/// `API type 'mlflow/v1/chat/completions' is not supported by '<name>'` — so
91+
/// they are dropped rather than offered as selectable models.
92+
///
93+
/// Deliberately narrow: image-capable endpoints (e.g.
94+
/// `databricks-gemini-3-pro-image`) do answer chat requests, so they stay. Any
95+
/// name this heuristic does not recognise is kept — preferring to include over
96+
/// silently dropping, matching [`parse_v1_endpoints`].
97+
pub(crate) fn is_chat_capable_endpoint(name: &str) -> bool {
98+
let lower = name.to_ascii_lowercase();
99+
if lower.contains("embedding") {
100+
return false;
101+
}
102+
// Segment match so `bge`/`gte` cannot fire on a substring of a longer word.
103+
!lower
104+
.split('-')
105+
.any(|segment| matches!(segment, "bge" | "gte"))
106+
}
107+
68108
/// Discover available models for a Databricks provider.
69109
///
70110
/// Returns a non-empty `Vec<ModelEntry>` on success. Returns
@@ -197,7 +237,7 @@ async fn fetch_v2_models(
197237
host: &str,
198238
bearer: &str,
199239
) -> Result<Vec<ModelEntry>, AgentError> {
200-
let mut all_models: Vec<ModelEntry> = Vec::new();
240+
let mut all_endpoints: Vec<V2Endpoint> = Vec::new();
201241
let mut page_token: Option<String> = None;
202242
let base_url = format!("{host}/api/ai-gateway/v2/endpoints");
203243

@@ -235,8 +275,8 @@ async fn fetch_v2_models(
235275
))
236276
})?;
237277

238-
let (page_models, next) = parse_v2_endpoints_page(&json)?;
239-
all_models.extend(page_models);
278+
let (page_endpoints, next) = parse_v2_endpoints_page(&json)?;
279+
all_endpoints.extend(page_endpoints);
240280

241281
match next {
242282
Some(tok) if Some(&tok) != page_token.as_ref() => page_token = Some(tok),
@@ -245,26 +285,74 @@ async fn fetch_v2_models(
245285
}
246286

247287
// Fall back to known-model list if the API returned nothing.
248-
if all_models.is_empty() {
249-
all_models = DATABRICKS_V2_KNOWN_MODELS
288+
if all_endpoints.is_empty() {
289+
return Ok(DATABRICKS_V2_KNOWN_MODELS
250290
.iter()
251291
.map(|id| ModelEntry {
252292
id: id.to_string(),
253293
name: id.to_string(),
254294
})
255-
.collect();
295+
.collect());
256296
}
257297

258-
Ok(all_models)
298+
sort_v2_endpoints_newest_first(&mut all_endpoints);
299+
300+
Ok(all_endpoints
301+
.into_iter()
302+
.map(|endpoint| endpoint.entry)
303+
.collect())
304+
}
305+
306+
/// A v2 gateway endpoint plus the key discovery orders the catalog by.
307+
#[derive(Debug, Clone, PartialEq, Eq)]
308+
pub(crate) struct V2Endpoint {
309+
pub(crate) entry: ModelEntry,
310+
/// `created_timestamp` as epoch milliseconds. `None` when the field is
311+
/// absent or unparseable — those sort last rather than jumping the queue.
312+
pub(crate) created_ms: Option<i64>,
313+
}
314+
315+
/// Read `created_timestamp` from one endpoint object.
316+
///
317+
/// The gateway sends epoch milliseconds as a JSON *string*
318+
/// (`"created_timestamp": "1699610000000"`); accept a bare number too, so a
319+
/// wire-shape change doesn't silently drop every endpoint to the bottom.
320+
fn endpoint_created_ms(endpoint: &serde_json::Value) -> Option<i64> {
321+
let value = endpoint.get("created_timestamp")?;
322+
value
323+
.as_i64()
324+
.or_else(|| value.as_str()?.trim().parse::<i64>().ok())
325+
}
326+
327+
/// Order the catalog newest-first, breaking ties by name.
328+
///
329+
/// The gateway returns endpoints in two phases — Databricks-managed first, then
330+
/// workspace-created — each alphabetical by name, which buries a brand-new
331+
/// frontier model deep in the list. Newest-first puts the models people are
332+
/// reaching for at the top of the picker.
333+
///
334+
/// Endpoints with no usable timestamp sort last, and the name tiebreak keeps the
335+
/// result stable: several managed endpoints share one placeholder timestamp, so
336+
/// without it their relative order would be arbitrary.
337+
pub(crate) fn sort_v2_endpoints_newest_first(endpoints: &mut [V2Endpoint]) {
338+
endpoints.sort_by(|a, b| {
339+
// `None` < `Some(_)`, so reversing puts timestamped endpoints first.
340+
b.created_ms
341+
.cmp(&a.created_ms)
342+
.then_with(|| a.entry.name.cmp(&b.entry.name))
343+
});
259344
}
260345

261346
/// Parse one page of a `GET api/ai-gateway/v2/endpoints` response.
262347
///
263-
/// Returns `(models, next_page_token)`. An empty or absent `next_page_token`
264-
/// signals the last page.
348+
/// Returns `(endpoints, next_page_token)`. An empty or absent `next_page_token`
349+
/// signals the last page. Endpoints that cannot serve chat traffic are dropped
350+
/// (see [`is_chat_capable_endpoint`]) so the model picker only offers models the
351+
/// agent can actually run. Page order is preserved here; the caller sorts once
352+
/// every page is in (see [`sort_v2_endpoints_newest_first`]).
265353
pub(crate) fn parse_v2_endpoints_page(
266354
json: &serde_json::Value,
267-
) -> Result<(Vec<ModelEntry>, Option<String>), AgentError> {
355+
) -> Result<(Vec<V2Endpoint>, Option<String>), AgentError> {
268356
let endpoints = json
269357
.get("endpoints")
270358
.and_then(|v| v.as_array())
@@ -279,9 +367,15 @@ pub(crate) fn parse_v2_endpoints_page(
279367
.iter()
280368
.filter_map(|endpoint| {
281369
let name = endpoint.get("name")?.as_str()?.to_string();
282-
Some(ModelEntry {
283-
id: name.clone(),
284-
name,
370+
if !is_chat_capable_endpoint(&name) {
371+
return None;
372+
}
373+
Some(V2Endpoint {
374+
entry: ModelEntry {
375+
id: name.clone(),
376+
name,
377+
},
378+
created_ms: endpoint_created_ms(endpoint),
285379
})
286380
})
287381
.collect();
@@ -356,7 +450,7 @@ mod tests {
356450
});
357451

358452
let (models, next) = parse_v2_endpoints_page(&json).unwrap();
359-
let ids: Vec<&str> = models.iter().map(|m| m.id.as_str()).collect();
453+
let ids: Vec<&str> = models.iter().map(|m| m.entry.id.as_str()).collect();
360454
assert_eq!(
361455
ids,
362456
vec![
@@ -399,4 +493,139 @@ mod tests {
399493
"got: {err}"
400494
);
401495
}
496+
497+
#[test]
498+
fn v2_parse_drops_embedding_endpoints() {
499+
// The v2 payload carries no `task`, so embedding endpoints are only
500+
// recognisable by name. They reject chat requests, so offering them in
501+
// the picker can only produce a 400 at send time.
502+
let json = serde_json::json!({
503+
"endpoints": [
504+
{"name": "databricks-bge-large-en"},
505+
{"name": "databricks-gte-large-en"},
506+
{"name": "databricks-qwen3-embedding-0-6b"},
507+
{"name": "databricks-claude-opus-5"},
508+
{"name": "databricks-gemini-3-pro-image"},
509+
]
510+
});
511+
512+
let (models, _) = parse_v2_endpoints_page(&json).unwrap();
513+
let ids: Vec<&str> = models.iter().map(|m| m.entry.id.as_str()).collect();
514+
// Image endpoints DO answer chat requests, so they are retained.
515+
assert_eq!(
516+
ids,
517+
vec!["databricks-claude-opus-5", "databricks-gemini-3-pro-image"]
518+
);
519+
}
520+
521+
#[test]
522+
fn v2_parse_reads_created_timestamp_in_either_wire_shape() {
523+
// The gateway sends epoch ms as a string; a bare number must work too.
524+
let json = serde_json::json!({
525+
"endpoints": [
526+
{"name": "string-ts", "created_timestamp": "1784932442251"},
527+
{"name": "number-ts", "created_timestamp": 1784932442251i64},
528+
{"name": "junk-ts", "created_timestamp": "not-a-number"},
529+
{"name": "no-ts"},
530+
]
531+
});
532+
533+
let (models, _) = parse_v2_endpoints_page(&json).unwrap();
534+
let stamps: Vec<Option<i64>> = models.iter().map(|m| m.created_ms).collect();
535+
assert_eq!(
536+
stamps,
537+
vec![Some(1784932442251), Some(1784932442251), None, None,]
538+
);
539+
}
540+
541+
#[test]
542+
fn v2_endpoints_sort_newest_first_then_by_name() {
543+
// Mirrors the real catalog: the gateway pages Databricks-managed
544+
// endpoints first, then workspace-created ones, each alphabetical — so
545+
// the newest model is buried mid-list until this sort runs.
546+
let json = serde_json::json!({
547+
"endpoints": [
548+
{"name": "databricks-claude-opus-5", "created_timestamp": "1784851200000"},
549+
{"name": "databricks-gpt-5-6-sol", "created_timestamp": "1784073600000"},
550+
{"name": "databricks-gpt-5-6-luna", "created_timestamp": "1784073600000"},
551+
{"name": "databricks-llama-4-maverick", "created_timestamp": "1699610000000"},
552+
{"name": "goose-claude-opus-5", "created_timestamp": "1784932442251"},
553+
{"name": "endpoint-without-timestamp"},
554+
]
555+
});
556+
557+
let (mut models, _) = parse_v2_endpoints_page(&json).unwrap();
558+
sort_v2_endpoints_newest_first(&mut models);
559+
560+
let ids: Vec<&str> = models.iter().map(|m| m.entry.id.as_str()).collect();
561+
assert_eq!(
562+
ids,
563+
vec![
564+
// Newest first, across both pagination phases.
565+
"goose-claude-opus-5",
566+
"databricks-claude-opus-5",
567+
// Same timestamp — the name tiebreak keeps this deterministic.
568+
"databricks-gpt-5-6-luna",
569+
"databricks-gpt-5-6-sol",
570+
"databricks-llama-4-maverick",
571+
// No usable timestamp sorts last, never first.
572+
"endpoint-without-timestamp",
573+
]
574+
);
575+
}
576+
577+
#[test]
578+
fn is_chat_capable_endpoint_keeps_unrecognised_names() {
579+
// Prefer including over silently dropping — an unknown family is kept.
580+
assert!(is_chat_capable_endpoint("databricks-glm-5-2"));
581+
assert!(is_chat_capable_endpoint("some-teams-custom-endpoint"));
582+
// `bge`/`gte` match as whole segments only, never as substrings.
583+
assert!(is_chat_capable_endpoint("databricks-budget-gtex-model"));
584+
assert!(!is_chat_capable_endpoint("databricks-bge-large-en"));
585+
assert!(!is_chat_capable_endpoint("databricks-gte-large-en"));
586+
assert!(!is_chat_capable_endpoint("databricks-qwen3-embedding-0-6b"));
587+
}
588+
589+
#[test]
590+
fn v2_discovery_failure_fallback_leads_with_configured_model() {
591+
let result = discovery_failure_fallback(Provider::DatabricksV2, "databricks-claude-opus-5");
592+
let ids: Vec<&str> = result.iter().map(|m| m.id.as_str()).collect();
593+
594+
// The running model must be representable in the picker even when
595+
// discovery failed, so it leads the fallback catalog.
596+
assert_eq!(ids.first(), Some(&"databricks-claude-opus-5"));
597+
for known in DATABRICKS_V2_KNOWN_MODELS {
598+
assert!(ids.contains(known), "fallback must retain '{known}'");
599+
}
600+
}
601+
602+
#[test]
603+
fn v2_discovery_failure_fallback_does_not_duplicate_configured_model() {
604+
let configured = DATABRICKS_V2_KNOWN_MODELS[0];
605+
let result = discovery_failure_fallback(Provider::DatabricksV2, configured);
606+
let occurrences = result.iter().filter(|m| m.id == configured).count();
607+
assert_eq!(occurrences, 1, "got: {result:?}");
608+
assert_eq!(result.len(), DATABRICKS_V2_KNOWN_MODELS.len());
609+
}
610+
611+
#[test]
612+
fn v2_discovery_failure_fallback_tolerates_blank_configured_model() {
613+
for configured in ["", " "] {
614+
let result = discovery_failure_fallback(Provider::DatabricksV2, configured);
615+
let ids: Vec<&str> = result.iter().map(|m| m.id.as_str()).collect();
616+
assert_eq!(ids, DATABRICKS_V2_KNOWN_MODELS.to_vec());
617+
}
618+
}
619+
620+
#[test]
621+
fn v2_discovery_failure_fallback_dedupes_a_padded_configured_model() {
622+
// `DATABRICKS_MODEL=" databricks-gpt-5-5 "` reaches here untrimmed, and an
623+
// untrimmed comparison would list the model twice — once padded, once from
624+
// the known slate.
625+
let configured = DATABRICKS_V2_KNOWN_MODELS[0];
626+
let result =
627+
discovery_failure_fallback(Provider::DatabricksV2, &format!(" {configured} "));
628+
let ids: Vec<&str> = result.iter().map(|m| m.id.as_str()).collect();
629+
assert_eq!(ids, DATABRICKS_V2_KNOWN_MODELS.to_vec());
630+
}
402631
}

‎crates/buzz-agent/src/lib.rs‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -920,11 +920,13 @@ mod tests {
920920
let configured = "my-configured-model";
921921
let result = discovery_failure_fallback(Provider::DatabricksV2, configured);
922922

923-
// DatabricksV2 must return the full DATABRICKS_V2_KNOWN_MODELS list.
923+
// DatabricksV2 must return the full DATABRICKS_V2_KNOWN_MODELS list,
924+
// plus the configured model so the picker can still represent the model
925+
// the agent is actually running.
924926
assert_eq!(
925927
result.len(),
926-
DATABRICKS_V2_KNOWN_MODELS.len(),
927-
"DatabricksV2 fallback must return all known models"
928+
DATABRICKS_V2_KNOWN_MODELS.len() + 1,
929+
"DatabricksV2 fallback must return all known models plus the configured model"
928930
);
929931
let result_ids: Vec<&str> = result.iter().map(|m| m.id.as_str()).collect();
930932
for known_id in DATABRICKS_V2_KNOWN_MODELS {
@@ -933,6 +935,10 @@ mod tests {
933935
"DatabricksV2 fallback must include known model '{known_id}'"
934936
);
935937
}
938+
assert!(
939+
result_ids.contains(&configured),
940+
"DatabricksV2 fallback must include the configured model"
941+
);
936942
}
937943

938944
#[test]

0 commit comments

Comments
 (0)