{"record":{"id":"b45d7245457e3341","repo":"Hmbown/CodeWhale","slug":"maxoutputtokens-requires-an-exact-model-auto-routing-is","errorCode":null,"errorMessage":"maxOutputTokens requires an exact model; Auto routing is unsupported","messagePattern":"maxOutputTokens requires an exact model; Auto routing is unsupported","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/runtime_threads.rs","lineNumber":9880,"sourceCode":"        }\n        let cfg_snapshot = self.config.read().clone();\n        let configured_reasoning_preference = cfg_snapshot\n            .reasoning_effort()\n            .map(crate::reasoning_preference::ReasoningEffort::from_setting);\n        // Runtime API precedence is explicit and stable: a turn override wins\n        // over its persisted thread default, which wins over normal config.\n        let reasoning_preference = turn_reasoning_preference\n            .or(thread_reasoning_preference)\n            .or(configured_reasoning_preference);\n        let allow_shell = req.allow_shell.unwrap_or(thread.allow_shell);\n        let trust_mode = req.trust_mode.unwrap_or(thread.trust_mode);\n        let auto_approve = policy.auto_approve();\n        let allowed_tools = req\n            .allowed_tools\n            .clone()\n            .or_else(|| thread.allowed_tools.clone());\n        if req.max_output_tokens.is_some() && auto_model {\n            bail!(\"maxOutputTokens requires an exact model; Auto routing is unsupported\");\n        }\n        let operation = if let Some(operation_key) = req.operation_key.as_deref() {\n            validate_runtime_turn_operation_key(operation_key)?;\n            let request_fingerprint = runtime_turn_request_fingerprint(\n                &thread,\n                &prompt,\n                req.input_summary.as_deref(),\n                &requested_model,\n                reasoning_preference,\n                allowed_tools.as_deref(),\n                policy,\n                allow_shell,\n                trust_mode,\n                &req.dynamic_tools,\n                req.environment_id.as_deref(),\n                &req.images,\n                req.max_output_tokens,\n            )?;","sourceCodeStart":9862,"sourceCodeEnd":9898,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/runtime_threads.rs#L9862-L9898","documentation":"The turn handler rejects max_output_tokens together with the \"auto\" model. Auto routing may pick different providers/protocols with different output-token budget support, so an explicit token limit is only honored for an exactly named model.","triggerScenarios":"Setting ThreadTurnRequest::max_output_tokens to Some(..) while req.model / thread.model resolves to \"auto\" (case-insensitive).","commonSituations":"Scripts that set a token budget for cost control but leave model unset/Auto; combining a UI token-limit slider with an Auto model picker; older clients that always set max_output_tokens.","solutions":["Name an exact model in req.model when setting max_output_tokens.","Clear max_output_tokens (None) if you want Auto routing.","Verify the chosen model's transport supports output limits via route_supports_output_token_limit."],"exampleFix":"// before\nreq.max_output_tokens = Some(4096); // model left as \"auto\"\n// after\nreq.model = \"gpt-4.1\".into();\nreq.max_output_tokens = Some(4096);","handlingStrategy":"validation","validationCode":"if req.max_output_tokens.is_some() && req.model.as_deref().unwrap_or_default().eq_ignore_ascii_case(\"auto\") {\n    return Err(\"max_output_tokens needs an exact model\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat max_output_tokens and model=\"auto\" as mutually exclusive options.","Default max_output_tokens to None unless an explicit model is set.","Centralize request building so the pair is validated once."],"tags":["model-routing","token-limit","validation"],"backgroundTag":"conflicting-config-options","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}