Skip to content

Commit e34e097

Browse files
wpfleger96npub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7
andauthored
fix(buzz-agent): support max effort for gpt-5.6 family (#1806)
Signed-off-by: Will Pfleger <[email protected]> Co-authored-by: npub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7 <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@sprout-oss.stage.blox.sqprod.co>
1 parent bc14052 commit e34e097

4 files changed

Lines changed: 182 additions & 77 deletions

File tree

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

Lines changed: 121 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ pub const PROTOCOL_VERSION: u32 = 2;
1212
/// - **Anthropic adaptive**: `low|medium|high|xhigh|max` (model-dependent; see `anthropic_thinking_config`).
1313
/// `none`/`minimal` are not Anthropic values — rejected at startup.
1414
/// - **Anthropic manual budget** (claude-3*, opus-4-5): `low|medium|high`; `xhigh`/`max` clamp to high budget.
15-
/// - **OpenAI Responses / Chat Completions**: `none|minimal|low|medium|high|xhigh` (provider pass-through).
16-
/// `max` is not an OpenAI value — rejected at startup.
15+
/// - **OpenAI Responses / Chat Completions**: effort support is model-dependent and normalized at
16+
/// request time; `max` is valid for documented max-supporting families such as GPT-5.6.
1717
/// - **Databricks**: routed by model family (Claude → Anthropic mapping, GPT-5 → Responses, MLflow → Chat).
1818
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
1919
pub enum ThinkingEffort {
@@ -310,27 +310,37 @@ fn gpt5_base_matches(lower_model: &str, token: &str) -> bool {
310310
/// | Model | Supported effort values |
311311
/// |-------------|-------------------------------------------|
312312
/// | gpt-5-pro | `high` only |
313+
/// | gpt-5.6 | `none, low, medium, high, xhigh, max` |
313314
/// | gpt-5.5 | `none, low, medium, high, xhigh` |
314315
/// | gpt-5.4 | `none, low, medium, high, xhigh` |
315316
/// | gpt-5.1 | `none, low, medium, high` |
316317
/// | gpt-5 (base)| `minimal, low, medium, high` |
317-
/// | unknown | not doc-verified — pass through unchanged |
318+
/// | unknown | not doc-verified — `max` clamps to `xhigh` |
318319
///
319320
/// Note the `none` vs `minimal` split: `gpt-5` (base) supports `minimal` but not `none`;
320-
/// `gpt-5.1`/`gpt-5.4`/`gpt-5.5` support `none` but not `minimal`. These are matched via
321+
/// `gpt-5.1`/`gpt-5.4`/`gpt-5.5`/`gpt-5.6` support `none` but not `minimal`. These are matched via
321322
/// nearest-supported fallback in `normalize_effort_for_openai_route`.
322323
///
323324
/// Match order: `-pro` variant checked before versioned strings to prevent `gpt-5-pro` from
324325
/// falling into the `gpt-5` base bucket (substring "gpt-5" is shared).
325326
///
326327
/// `model` is a raw model name (may include Databricks gateway prefixes or date suffixes).
327-
/// Unknown models return `None` — caller treats `None` as "server-validated pass-through".
328+
/// Unknown models return `None` — callers pass through values except `max`, which clamps to
329+
/// `xhigh` until support is confirmed.
328330
/// Versioned tokens use `gpt5_token_matches` (end-of-string or `-` boundary, blocking digit
329331
/// and letter continuations). The base token uses `gpt5_base_matches`, which additionally
330332
/// rejects short `-<1-3 digit>` suffixes that look like two-digit version numbers.
331333
fn openai_efforts_for_model(model: &str) -> Option<&'static [ThinkingEffort]> {
332334
// Effort ordered from lowest to highest for each family.
333335
const GPT5_PRO: &[ThinkingEffort] = &[ThinkingEffort::High];
336+
const GPT5_6: &[ThinkingEffort] = &[
337+
ThinkingEffort::None,
338+
ThinkingEffort::Low,
339+
ThinkingEffort::Medium,
340+
ThinkingEffort::High,
341+
ThinkingEffort::XHigh,
342+
ThinkingEffort::Max,
343+
];
334344
const GPT5_5_AND_5_4: &[ThinkingEffort] = &[
335345
ThinkingEffort::None,
336346
ThinkingEffort::Low,
@@ -356,6 +366,12 @@ fn openai_efforts_for_model(model: &str) -> Option<&'static [ThinkingEffort]> {
356366
// matching the base "gpt-5" prefix first.
357367
if gpt5_token_matches(&lower, "gpt-5-pro") || gpt5_token_matches(&lower, "gpt5-pro") {
358368
Some(GPT5_PRO)
369+
} else if gpt5_token_matches(&lower, "gpt-5.6")
370+
|| gpt5_token_matches(&lower, "gpt5.6")
371+
|| gpt5_token_matches(&lower, "gpt-5-6")
372+
|| gpt5_token_matches(&lower, "gpt5-6")
373+
{
374+
Some(GPT5_6)
359375
} else if gpt5_token_matches(&lower, "gpt-5.5")
360376
|| gpt5_token_matches(&lower, "gpt5.5")
361377
|| gpt5_token_matches(&lower, "gpt-5-5")
@@ -443,8 +459,8 @@ pub fn anthropic_efforts_for_model(
443459
/// model families means the "closest analogue" is the other form before jumping to `low`).
444460
/// - Above that pair: upward clamp first, then downward (prefer more thinking over less).
445461
/// - `xhigh` falls back to `high` when not supported (no model skips from `high` to `xhigh`).
446-
/// - `max` is first clamped to `xhigh` by `normalize_effort_for_openai_route` before this
447-
/// function is reached; this function never sees `max`.
462+
/// - `max` passes through for model families whose table includes it; otherwise it resolves to
463+
/// the nearest supported level.
448464
///
449465
/// Logs a `warn!` on every substitution.
450466
fn resolve_openai_effort(
@@ -505,42 +521,32 @@ fn resolve_openai_effort(
505521

506522
/// Normalize the effort value for an OpenAI-shaped request body (Chat Completions or Responses).
507523
///
508-
/// Two normalizations are applied in order:
509-
///
510-
/// 1. **`max` → `xhigh` clamp**: `max` is not a valid OpenAI reasoning effort value; clamped
511-
/// at this step. The pure-OpenAI startup validator already rejects `max` at startup, so this
512-
/// clamp only fires on `DatabricksV2` sessions that routed to the OpenAI path.
513-
///
514-
/// 2. **Per-model effort availability**: for doc-verified OpenAI model families, the requested
515-
/// level (post-clamp) is checked against the model's supported set. If not supported, the
516-
/// nearest supported level is substituted (see `resolve_openai_effort` for preference order).
517-
/// Unknown/unverified models are passed through unchanged — the server validates.
524+
/// Per-model effort availability is applied for doc-verified OpenAI model families. A requested
525+
/// level not in the model's supported set is substituted with the nearest supported level (see
526+
/// `resolve_openai_effort` for preference order). For unknown/unverified models, `max` is clamped
527+
/// to `xhigh` because its support cannot be confirmed; all other values pass through unchanged.
518528
///
519529
/// Applies to pure-OpenAI request paths AND DBv2 OpenAI-shaped routes.
520530
///
521531
/// Doc-verified model table (July 2025):
522532
/// - `gpt-5-pro`: `high` only
533+
/// - `gpt-5.6`: `none, low, medium, high, xhigh, max`
523534
/// - `gpt-5.5`, `gpt-5.4`: `none, low, medium, high, xhigh`
524535
/// - `gpt-5.1`: `none, low, medium, high`
525536
/// - `gpt-5` (base): `minimal, low, medium, high`
526-
/// - unknown: pass through (server-validated)
537+
/// - unknown: `max` clamps to `xhigh`; other values pass through
527538
pub fn normalize_effort_for_openai_route(effort: ThinkingEffort, model: &str) -> ThinkingEffort {
528-
// Step 1: clamp max → xhigh (max is not a valid OpenAI value).
529-
let clamped = if effort == ThinkingEffort::Max {
530-
tracing::warn!(
531-
requested = "max",
532-
resolved = "xhigh",
533-
"BUZZ_AGENT_THINKING_EFFORT=max is not valid for OpenAI-shaped requests; clamping to xhigh"
534-
);
535-
ThinkingEffort::XHigh
536-
} else {
537-
effort
538-
};
539-
540-
// Step 2: per-model effort availability check.
541539
match openai_efforts_for_model(model) {
542-
Some(supported) => resolve_openai_effort(model, clamped, supported),
543-
None => clamped, // unknown model — pass through
540+
Some(supported) => resolve_openai_effort(model, effort, supported),
541+
None if effort == ThinkingEffort::Max => {
542+
tracing::warn!(
543+
requested = "max",
544+
resolved = "xhigh",
545+
"BUZZ_AGENT_THINKING_EFFORT=max not confirmed for unknown OpenAI model; clamping to xhigh"
546+
);
547+
ThinkingEffort::XHigh
548+
}
549+
None => effort,
544550
}
545551
}
546552

@@ -925,19 +931,13 @@ impl Config {
925931
}
926932
// Provider-level effort validation (fail-fast, clear error).
927933
// `none`/`minimal` are not Anthropic values — rejected at startup.
928-
// `max` is not an OpenAI value — rejected at startup.
929-
// Model-level clamping (e.g. xhigh on Opus 4.6) is dynamic: happens at request
930-
// build time because `session/set_model` can change the model after startup.
931934
//
932-
// DatabricksV2 is intentionally EXCLUDED from startup validation: it dispatches
933-
// across Anthropic Messages, OpenAI Responses, and MLflow Chat routes at request
934-
// build time based on the effective model. No single effort value is invalid for
935-
// all three routes, so provider-wide startup rejection is wrong. Route-aware effort
936-
// normalization is applied instead via `normalize_effort_for_openai_route` /
937-
// `normalize_effort_for_anthropic_route` at request build time in `llm.rs`.
935+
// OpenAI, Databricks, and DatabricksV2 defer effort validation to request-time routing:
936+
// availability is model-dependent, and `session/set_model` can change the effective model
937+
// after startup. `normalize_effort_for_openai_route` / `normalize_effort_for_anthropic_route`
938+
// apply route-aware normalization in `llm.rs` when building each request.
938939
if let Some(effort) = self.thinking_effort {
939940
let is_pure_anthropic = matches!(self.provider, Provider::Anthropic);
940-
let is_pure_openai = matches!(self.provider, Provider::OpenAi | Provider::Databricks);
941941
if is_pure_anthropic && matches!(effort, ThinkingEffort::None | ThinkingEffort::Minimal)
942942
{
943943
return Err(format!(
@@ -946,13 +946,6 @@ impl Config {
946946
effort.openai_effort_str()
947947
));
948948
}
949-
if is_pure_openai && matches!(effort, ThinkingEffort::Max) {
950-
return Err(
951-
"config: BUZZ_AGENT_THINKING_EFFORT=max is not valid for OpenAI/Databricks \
952-
providers (allowed: none|minimal|low|medium|high|xhigh)"
953-
.into(),
954-
);
955-
}
956949
}
957950
Ok(())
958951
}
@@ -1910,30 +1903,43 @@ mod tests {
19101903
}
19111904

19121905
#[test]
1913-
fn validate_rejects_max_effort_for_openai() {
1914-
let cfg = make_config_for_validation(Provider::OpenAi, Some(ThinkingEffort::Max));
1915-
let err = cfg.validate().unwrap_err();
1916-
assert!(
1917-
err.contains("BUZZ_AGENT_THINKING_EFFORT=max"),
1918-
"error must name the value: {err}"
1919-
);
1920-
assert!(
1921-
err.contains("not valid for OpenAI"),
1922-
"error must name the provider: {err}"
1923-
);
1924-
assert!(
1925-
err.contains("none|minimal|low|medium|high|xhigh"),
1926-
"error must name allowed values: {err}"
1927-
);
1906+
fn validate_accepts_all_efforts_for_openai() {
1907+
// OpenAI effort support is model-dependent and normalized at request build time.
1908+
for effort in [
1909+
ThinkingEffort::None,
1910+
ThinkingEffort::Minimal,
1911+
ThinkingEffort::Low,
1912+
ThinkingEffort::Medium,
1913+
ThinkingEffort::High,
1914+
ThinkingEffort::XHigh,
1915+
ThinkingEffort::Max,
1916+
] {
1917+
let cfg = make_config_for_validation(Provider::OpenAi, Some(effort));
1918+
assert!(
1919+
cfg.validate().is_ok(),
1920+
"OpenAI must accept {effort:?} at startup (route-aware normalization at request build)"
1921+
);
1922+
}
19281923
}
19291924

19301925
#[test]
1931-
fn validate_rejects_max_effort_for_databricks() {
1932-
// Databricks legacy uses OpenAI Chat wire format — same rejection.
1933-
let cfg = make_config_for_validation(Provider::Databricks, Some(ThinkingEffort::Max));
1934-
let err = cfg.validate().unwrap_err();
1935-
assert!(err.contains("BUZZ_AGENT_THINKING_EFFORT=max"), "{err}");
1936-
assert!(err.contains("not valid for OpenAI/Databricks"), "{err}");
1926+
fn validate_accepts_all_efforts_for_databricks() {
1927+
// Legacy Databricks effort support is model-dependent and normalized at request build time.
1928+
for effort in [
1929+
ThinkingEffort::None,
1930+
ThinkingEffort::Minimal,
1931+
ThinkingEffort::Low,
1932+
ThinkingEffort::Medium,
1933+
ThinkingEffort::High,
1934+
ThinkingEffort::XHigh,
1935+
ThinkingEffort::Max,
1936+
] {
1937+
let cfg = make_config_for_validation(Provider::Databricks, Some(effort));
1938+
assert!(
1939+
cfg.validate().is_ok(),
1940+
"Databricks must accept {effort:?} at startup (route-aware normalization at request build)"
1941+
);
1942+
}
19371943
}
19381944

19391945
#[test]
@@ -2195,6 +2201,26 @@ mod tests {
21952201
);
21962202
}
21972203

2204+
#[test]
2205+
fn openai_efforts_for_model_gpt5_6_includes_max() {
2206+
let expected: &[ThinkingEffort] = &[
2207+
ThinkingEffort::None,
2208+
ThinkingEffort::Low,
2209+
ThinkingEffort::Medium,
2210+
ThinkingEffort::High,
2211+
ThinkingEffort::XHigh,
2212+
ThinkingEffort::Max,
2213+
];
2214+
2215+
for model in ["gpt-5.6", "gpt-5.6-sol", "gpt-5-6-sol", "goose-gpt-5-6-sol"] {
2216+
assert_eq!(
2217+
openai_efforts_for_model(model),
2218+
Some(expected),
2219+
"{model} must match the gpt-5.6 effort table"
2220+
);
2221+
}
2222+
}
2223+
21982224
#[test]
21992225
fn openai_efforts_for_model_gpt5_5_includes_xhigh() {
22002226
let supported = openai_efforts_for_model("gpt-5.5").expect("gpt-5.5 must be in table");
@@ -2420,6 +2446,26 @@ mod tests {
24202446
);
24212447
}
24222448

2449+
#[test]
2450+
fn normalize_openai_route_passes_max_through_for_gpt5_6() {
2451+
for model in ["gpt-5.6", "gpt-5-6-sol"] {
2452+
assert_eq!(
2453+
normalize_effort_for_openai_route(ThinkingEffort::Max, model),
2454+
ThinkingEffort::Max,
2455+
"{model} must preserve max"
2456+
);
2457+
}
2458+
}
2459+
2460+
#[test]
2461+
fn normalize_openai_route_gpt5_5_max_becomes_xhigh() {
2462+
assert_eq!(
2463+
normalize_effort_for_openai_route(ThinkingEffort::Max, "gpt-5.5"),
2464+
ThinkingEffort::XHigh,
2465+
"gpt-5.5 must clamp max to xhigh"
2466+
);
2467+
}
2468+
24232469
#[test]
24242470
fn normalize_openai_route_gpt5_5_minimal_becomes_none() {
24252471
// gpt-5.5 supports none but not minimal. minimal → none (peer fallback).
@@ -2576,6 +2622,10 @@ mod tests {
25762622
// gpt-5 family check mirrors gpt5FamilyModel in TS.
25772623
let is_gpt5 = gpt5_token_matches(&m, "gpt-5-pro")
25782624
|| gpt5_token_matches(&m, "gpt5-pro")
2625+
|| gpt5_token_matches(&m, "gpt-5.6")
2626+
|| gpt5_token_matches(&m, "gpt5.6")
2627+
|| gpt5_token_matches(&m, "gpt-5-6")
2628+
|| gpt5_token_matches(&m, "gpt5-6")
25792629
|| gpt5_token_matches(&m, "gpt-5.5")
25802630
|| gpt5_token_matches(&m, "gpt5.5")
25812631
|| gpt5_token_matches(&m, "gpt-5.4")

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

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,10 @@ impl Llm {
9191
}
9292
Provider::OpenAi | Provider::Databricks => {
9393
self.openai_request(cfg, effective_model, |use_responses| {
94-
// Normalize effort for model-specific availability (per-model table; max is
95-
// already rejected at startup for pure OpenAI, but other per-model corrections
96-
// like none→minimal on gpt-5 base still apply).
94+
// Normalize effort for model-specific availability. Startup no longer rejects
95+
// `max` for pure OpenAI/Databricks; this per-model table is the single authority
96+
// — it keeps `max` for gpt-5.6, clamps `max`→`xhigh` for other OpenAI-shaped
97+
// models, and still applies corrections like none→minimal on the gpt-5 base.
9798
let e = effort.map(|ef| normalize_effort_for_openai_route(ef, effective_model));
9899
if use_responses {
99100
(
@@ -112,7 +113,7 @@ impl Llm {
112113
Provider::DatabricksV2 => {
113114
self.databricks_v2_request(cfg, effective_model, |route| match route {
114115
DatabricksV2Route::OpenAiResponses => {
115-
// OpenAI Responses path: normalize effort (max → xhigh, per-model table).
116+
// OpenAI Responses path: normalize effort against the per-model table.
116117
let e =
117118
effort.map(|ef| normalize_effort_for_openai_route(ef, effective_model));
118119
(
@@ -129,7 +130,7 @@ impl Llm {
129130
)
130131
}
131132
DatabricksV2Route::MlflowChatCompletions => {
132-
// MLflow Chat path (OpenAI-shaped): normalize effort (max → xhigh, per-model table).
133+
// MLflow Chat path (OpenAI-shaped): normalize effort against the per-model table.
133134
let e =
134135
effort.map(|ef| normalize_effort_for_openai_route(ef, effective_model));
135136
(
@@ -1982,6 +1983,24 @@ mod tests {
19821983
);
19831984
}
19841985

1986+
#[test]
1987+
fn dbv2_openai_route_max_effort_passes_through_for_gpt5_6() {
1988+
let normalized =
1989+
crate::config::normalize_effort_for_openai_route(ThinkingEffort::Max, "gpt-5.6-sol");
1990+
let body = responses_body(
1991+
&cfg_responses(),
1992+
"system",
1993+
&[HistoryItem::User("hi".into())],
1994+
&[],
1995+
"gpt-5.6-sol",
1996+
Some(normalized),
1997+
);
1998+
assert_eq!(
1999+
body["reasoning"]["effort"], "max",
2000+
"DBv2 GPT-5.6 route must serialize max to the Responses API"
2001+
);
2002+
}
2003+
19852004
#[test]
19862005
fn dbv2_mlflow_route_max_effort_clamped_to_xhigh_in_openai_body() {
19872006
// DBv2 MLflow route (unknown model): max → clamped to xhigh by normalize_effort_for_openai_route.

‎desktop/src/features/agents/ui/buzzAgentConfig.ts‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,10 @@ function gpt5FamilyModel(m: string): boolean {
227227
return (
228228
gpt5TokenMatches(m, "gpt-5-pro") ||
229229
gpt5TokenMatches(m, "gpt5-pro") ||
230+
gpt5TokenMatches(m, "gpt-5.6") ||
231+
gpt5TokenMatches(m, "gpt5.6") ||
232+
gpt5TokenMatches(m, "gpt-5-6") ||
233+
gpt5TokenMatches(m, "gpt5-6") ||
230234
gpt5TokenMatches(m, "gpt-5.5") ||
231235
gpt5TokenMatches(m, "gpt5.5") ||
232236
gpt5TokenMatches(m, "gpt-5.4") ||
@@ -243,6 +247,17 @@ function openaiConfig(m: string): ProviderEffortConfig {
243247
if (gpt5TokenMatches(m, "gpt-5-pro") || gpt5TokenMatches(m, "gpt5-pro")) {
244248
return { validValues: ["high"], defaultValue: "high" };
245249
}
250+
if (
251+
gpt5TokenMatches(m, "gpt-5.6") ||
252+
gpt5TokenMatches(m, "gpt5.6") ||
253+
gpt5TokenMatches(m, "gpt-5-6") ||
254+
gpt5TokenMatches(m, "gpt5-6")
255+
) {
256+
return {
257+
validValues: ["none", "low", "medium", "high", "xhigh", "max"],
258+
defaultValue: "medium",
259+
};
260+
}
246261
if (
247262
gpt5TokenMatches(m, "gpt-5.5") ||
248263
gpt5TokenMatches(m, "gpt5.5") ||
@@ -275,7 +290,7 @@ function openaiConfig(m: string): ProviderEffortConfig {
275290
defaultValue: "medium",
276291
};
277292
}
278-
// Unknown OpenAI model — show all except max (OpenAI doesn't accept max).
293+
// Unknown OpenAI model — conservative fallback; max is enabled only for families whose table includes it.
279294
return {
280295
validValues: ["none", "minimal", "low", "medium", "high", "xhigh"],
281296
defaultValue: "medium",

0 commit comments

Comments
 (0)