Hmbown/CodeWhale · error · anyhow::Error
maxOutputTokens requires an exact model
Error message
maxOutputTokens requires an exact model
What it means
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.
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.
Example fix
// before
{ "prompt": "hi", "maxOutputTokens": 1024 }
// after
{ "prompt": "hi", "model": "qwen3-coder", "maxOutputTokens": 1024 } Defensive patterns
Strategy: validation
Validate before calling
// client-side guard before sending maxOutputTokens
function canSendMaxOutputTokens(model, provider) {
const resolved = model ?? provider?.default_model;
return typeof resolved === 'string' && resolved.trim() !== '' && resolved.toLowerCase() !== 'auto';
} Type guard
function isExactModel(v) {
return typeof v === 'string' && v.trim().length > 0 && v.toLowerCase() !== 'auto';
} Prevention
- 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.
When it happens
Trigger: 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".
Common situations: Clients passing maxOutputTokens without pinning a model while the runtime provider is left on automatic model selection.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- A pinned task provider requires an explicit model
- agent profile reasoning_effort must be one of: inherit…
- At least one thread field is required
- Choose both a provider and a model.
- Codewhale credentials path must be a directory
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/3b2d514643ee4480.
Report an issue: GitHub.
Appendix: source
Thrown at crates/app-server/src/lib.rs:1651
.await?;
let current = providers
.get("current")
.and_then(Value::as_str)
.context("Runtime provider is unavailable")?;
let provider = providers
.get("providers")
.and_then(Value::as_array)
.and_then(|providers| {
providers
.iter()
.find(|provider| provider.get("id").and_then(Value::as_str) == Some(current))
})
.context("Runtime provider is unavailable")?;
let model = requested_model
.or_else(|| provider.get("default_model").and_then(Value::as_str))
.context("maxOutputTokens requires an exact model")?;
if model.trim().is_empty() || model.eq_ignore_ascii_case("auto") {
bail!("maxOutputTokens requires an exact model");
}
if !current
.bytes()
.all(|byte| byte.is_ascii_lowercase() || byte.is_ascii_digit() || byte == b'-')
{
bail!("Runtime provider identity is invalid");
}
let mut cursor = None;
let mut seen = std::collections::HashSet::new();
loop {
let mut url =
reqwest::Url::parse(&format!("{}/v1/providers/{current}/models", self.base_url))?;
url.query_pairs_mut().append_pair("limit", "250");
if let Some(cursor) = cursor.as_deref() {
url.query_pairs_mut().append_pair("cursor", cursor);
}
let catalog = self.request_json(self.authed(self.client.get(url))).await?;
if let Some(entry) =View on GitHub (pinned to 73e0f67d83)