{"record":{"id":"028739f66496a1b0","repo":"Hmbown/CodeWhale","slug":"maxoutputtokens-is-unsupported-by-the-selected-provider","errorCode":null,"errorMessage":"maxOutputTokens is unsupported by the selected provider transport","messagePattern":"maxOutputTokens is unsupported by the selected provider transport","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/runtime_threads.rs","lineNumber":9920,"sourceCode":"                request_fingerprint,\n                reserved_turn_id,\n            )?\n        } else {\n            None\n        };\n        if let Some(operation) = operation.as_ref()\n            && let Some(original_turn) = self.replay_turn_for_operation(operation)?\n        {\n            return Ok((original_turn, true));\n        }\n        if !image_blocks.is_empty() || req.max_output_tokens.is_some() {\n            let identity = self.provider_identity_for_thread(&cfg_snapshot, &thread)?;\n            let route = resolve_runtime_thread_route_for_identity(&cfg_snapshot, &identity, Some(&requested_model))?;\n            if !image_blocks.is_empty() && route.candidate.capabilities().image_input != codewhale_config::route::CapabilityState::Supported {\n                bail!(\"image inputs require a model with explicitly supported image input\");\n            }\n            if req.max_output_tokens.is_some() && !crate::route_budget::route_supports_output_token_limit(route.identity.provider, route.candidate.protocol()) {\n                bail!(\"maxOutputTokens is unsupported by the selected provider transport\");\n            }\n        }\n        let engine = self.ensure_engine_loaded(&thread).await?;\n\n        let client_preflight_required = {\n            let active = self.active.lock().await;\n            if let Some(active_thread) = active.engines.get(thread_id)\n                && active_thread.active_turn.is_some()\n            {\n                bail!(\"Thread already has an active turn\");\n            }\n            active\n                .engines\n                .get(thread_id)\n                .is_none_or(|state| state.client_preflight_required)\n        };\n\n        // Resolve the concrete provider/model before persisting a turn. Auto","sourceCodeStart":9902,"sourceCodeEnd":9938,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/runtime_threads.rs#L9902-L9938","documentation":"When max_output_tokens is set, the runtime checks the resolved route's provider/protocol via route_supports_output_token_limit; if that transport cannot carry an output-token cap (provider + protocol combination), the turn is rejected rather than silently dropping the budget.","triggerScenarios":"Setting req.max_output_tokens with an exact model whose resolved route's provider/protocol pair is not in route_supports_output_token_limit (e.g. a protocol without token-budget parameters).","commonSituations":"Pointing a thread at a provider transport (custom/OAuth protocol variant) that has no max_tokens field; switching a thread from OpenAI-compatible to a protocol lacking budget support while keeping token limits configured.","solutions":["Choose a model/provider whose transport supports output token limits.","Drop max_output_tokens from the request for this transport.","Extend route_supports_output_token_limit if the transport actually supports budgets but is unlisted."],"exampleFix":"// before\nreq.model = \"custom-protocol-model\".into();\nreq.max_output_tokens = Some(2048);\n// after\nreq.model = \"openai-compatible-model\".into();\nreq.max_output_tokens = Some(2048);","handlingStrategy":"validation","validationCode":"if req.max_output_tokens.is_some() && !route_supports_output_token_limit(route.identity.provider, route.candidate.protocol()) {\n    req.max_output_tokens = None; // drop the budget for this transport\n}","typeGuard":"fn transport_supports_token_limit(route: &Route) -> bool { route_supports_output_token_limit(route.identity.provider, route.candidate.protocol()) }","tryCatchPattern":null,"preventionTips":["Check route_supports_output_token_limit before exposing token-limit settings.","Drop or warn on token budgets when switching to unsupported transports.","Test token-limit paths for every provider protocol you enable."],"tags":["token-limit","provider-transport","capabilities"],"backgroundTag":"unsupported-operation","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"}