Skip to content

Commit 62ebc94

Browse files
Duncanwpfleger96
andcommitted
fix(model-capabilities): collapse empty segments in Rust gpt-version-segment matcher
TS gptVersionSegmentMatches splits on /[^a-z0-9]+/ (collapsing), but the emitted Rust twin split(|c| !c.is_ascii_alphanumeric()) yields empty strings between adjacent delimiters. On an id like 'gpt--5' the arrays diverge: TS ['gpt','5'] vs Rust ['gpt','','5']. The next-segment-starts-with-digit lookahead then produces different results across languages (openai-responses vs mlflow-chat fallback). Add .filter(|s| !s.is_empty()) to the Rust split, matching the TS intent. Add one normative corpus vector (databricks-gpt--5) that pins both interpreters against a doubled-separator id, so CI will catch any future regression across this boundary. Co-authored-by: Will Pfleger <[email protected]> Signed-off-by: Will Pfleger <[email protected]>
1 parent 817b887 commit 62ebc94

3 files changed

Lines changed: 26 additions & 2 deletions

File tree

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2028,7 +2028,10 @@ fn gpt5_base_matches_rs(model: &str, token: &str) -> bool {
20282028
/// OR the next segment after it starts with a digit). Prevents "gpt-neox-20b" from matching
20292029
/// "gpt" because "neox" starts with a letter, while "gpt-5.5" matches because next seg "5" is digit.
20302030
fn gpt_version_segment_matches_rs(model: &str, token: &str) -> bool {
2031-
let segs: Vec<&str> = model.split(|c: char| !c.is_ascii_alphanumeric()).collect();
2031+
let segs: Vec<&str> = model
2032+
.split(|c: char| !c.is_ascii_alphanumeric())
2033+
.filter(|s| !s.is_empty())
2034+
.collect();
20322035
for (i, seg) in segs.iter().enumerate() {
20332036
if *seg == token {
20342037
// Dashless numeric form (e.g. "gpt5"): token length > 3 or starts with digit

‎scripts/generate-model-capabilities.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1240,7 +1240,7 @@ fn gpt5_base_matches_rs(model: &str, token: &str) -> bool {
12401240
/// OR the next segment after it starts with a digit). Prevents "gpt-neox-20b" from matching
12411241
/// "gpt" because "neox" starts with a letter, while "gpt-5.5" matches because next seg "5" is digit.
12421242
fn gpt_version_segment_matches_rs(model: &str, token: &str) -> bool {
1243-
let segs: Vec<&str> = model.split(|c: char| !c.is_ascii_alphanumeric()).collect();
1243+
let segs: Vec<&str> = model.split(|c: char| !c.is_ascii_alphanumeric()).filter(|s| !s.is_empty()).collect();
12441244
for (i, seg) in segs.iter().enumerate() {
12451245
if *seg == token {
12461246
// Dashless numeric form (e.g. "gpt5"): token length > 3 or starts with digit

‎scripts/normative-corpus.json‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,5 +1611,26 @@
16111611
"normalization_policy": "none",
16121612
"registry_label": null
16131613
}
1614+
},
1615+
{
1616+
"id": "dbv2-gpt-doubled-separator",
1617+
"provider": "databricks_v2",
1618+
"raw_model_id": "databricks-gpt--5",
1619+
"_note": "Doubled separator in model id. gpt-version-segment must split on runs of non-alphanumeric (collapsing), so 'gpt--5' -> ['gpt','5'] in both TS and Rust. 'gpt' is a short alpha token; next segment '5' starts with a digit -> gpt rule match -> openai-responses. Pins the Rust/TS segment-array equivalence under consecutive delimiters.",
1620+
"expect": {
1621+
"thinking_mode": "none",
1622+
"supported_efforts": [
1623+
"none",
1624+
"minimal",
1625+
"low",
1626+
"medium",
1627+
"high",
1628+
"xhigh"
1629+
],
1630+
"default_effort": "medium",
1631+
"databricks_v2_wire_route": "openai-responses",
1632+
"normalization_policy": "openai-clamp-max-to-xhigh",
1633+
"registry_label": null
1634+
}
16141635
}
16151636
]

0 commit comments

Comments
 (0)