@@ -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 ) ]
1919pub 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.
331333fn 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.
450466fn 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
527538pub 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" )
0 commit comments