{"record":{"id":"3b2d514643ee4480","repo":"Hmbown/CodeWhale","slug":"maxoutputtokens-requires-an-exact-model","errorCode":null,"errorMessage":"maxOutputTokens requires an exact model","messagePattern":"maxOutputTokens requires an exact model","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/app-server/src/lib.rs","lineNumber":1651,"sourceCode":"            .await?;\n        let current = providers\n            .get(\"current\")\n            .and_then(Value::as_str)\n            .context(\"Runtime provider is unavailable\")?;\n        let provider = providers\n            .get(\"providers\")\n            .and_then(Value::as_array)\n            .and_then(|providers| {\n                providers\n                    .iter()\n                    .find(|provider| provider.get(\"id\").and_then(Value::as_str) == Some(current))\n            })\n            .context(\"Runtime provider is unavailable\")?;\n        let model = requested_model\n            .or_else(|| provider.get(\"default_model\").and_then(Value::as_str))\n            .context(\"maxOutputTokens requires an exact model\")?;\n        if model.trim().is_empty() || model.eq_ignore_ascii_case(\"auto\") {\n            bail!(\"maxOutputTokens requires an exact model\");\n        }\n        if !current\n            .bytes()\n            .all(|byte| byte.is_ascii_lowercase() || byte.is_ascii_digit() || byte == b'-')\n        {\n            bail!(\"Runtime provider identity is invalid\");\n        }\n        let mut cursor = None;\n        let mut seen = std::collections::HashSet::new();\n        loop {\n            let mut url =\n                reqwest::Url::parse(&format!(\"{}/v1/providers/{current}/models\", self.base_url))?;\n            url.query_pairs_mut().append_pair(\"limit\", \"250\");\n            if let Some(cursor) = cursor.as_deref() {\n                url.query_pairs_mut().append_pair(\"cursor\", cursor);\n            }\n            let catalog = self.request_json(self.authed(self.client.get(url))).await?;\n            if let Some(entry) =","sourceCodeStart":1633,"sourceCodeEnd":1669,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/app-server/src/lib.rs#L1633-L1669","documentation":"Setting `maxOutputTokens` requires resolving an exact model identifier: the caller's requested model, or the provider's `default_model`. If neither exists, or the resolved value is empty/`auto`, the app-server cannot look up the model's output-token capability and refuses. `auto` is not a concrete model, so no catalog lookup is possible.","triggerScenarios":"Calling the one-shot prompt path with `max_output_tokens` set while the requested model is None and the Runtime provider's `default_model` is absent, empty, or literally \"auto\".","commonSituations":"Clients passing maxOutputTokens without pinning a model while the runtime provider is left on automatic model selection.","solutions":["Pass an explicit model with the request (e.g. `model: \"gpt-5\"` style identifier accepted by the provider).","Set the provider's `default_model` in the Runtime configuration.","Drop maxOutputTokens if automatic model selection is intended."],"exampleFix":"// before\n{ \"prompt\": \"hi\", \"maxOutputTokens\": 1024 }\n// after\n{ \"prompt\": \"hi\", \"model\": \"qwen3-coder\", \"maxOutputTokens\": 1024 }","handlingStrategy":"validation","validationCode":"// client-side guard before sending maxOutputTokens\nfunction canSendMaxOutputTokens(model, provider) {\n  const resolved = model ?? provider?.default_model;\n  return typeof resolved === 'string' && resolved.trim() !== '' && resolved.toLowerCase() !== 'auto';\n}","typeGuard":"function isExactModel(v) {\n  return typeof v === 'string' && v.trim().length > 0 && v.toLowerCase() !== 'auto';\n}","tryCatchPattern":null,"preventionTips":["Always pin an explicit model when sending token-limit options.","Configure default_model in the Runtime provider config.","Treat \"auto\" as 'no model selected' in client code and reject it early."],"tags":["api","configuration","model","validation"],"backgroundTag":"missing-required-argument","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"}