{"record":{"id":"f0ee260c83465f9e","repo":"Hmbown/CodeWhale","slug":"model-response-incomplete-provider-stop-reason","errorCode":null,"errorMessage":"Model response incomplete: provider stop reason `{}`; the partial response was printed but the command did not succeed.","messagePattern":"Model response incomplete: provider stop reason `(.+?)`; the partial response was printed but the command did not succeed\\.","errorType":"error_code","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/lib.rs","lineNumber":11783,"sourceCode":"        metadata: None,\n        thinking: None,\n        reasoning_effort,\n        stream: Some(false),\n        temperature: None,\n        top_p: None,\n    };\n\n    let response = client.create_message(request).await?;\n    let stop_reason = response.stop_reason.clone();\n\n    for block in response.content {\n        if let ContentBlock::Text { text, .. } = block {\n            println!(\"{text}\");\n        }\n    }\n\n    if is_incomplete_stop_reason(stop_reason.as_deref()) {\n        anyhow::bail!(\n            \"Model response incomplete: provider stop reason `{}`; the partial response was printed but the command did not succeed.\",\n            stop_reason_detail(stop_reason.as_deref())\n        );\n    }\n\n    Ok(())\n}\n\nasync fn run_one_shot_json(\n    config: &Config,\n    model: &str,\n    prompt: &str,\n    force_configured_route: bool,\n) -> Result<()> {\n    use crate::client::CodewhaleClient;\n    use codewhale_models::{\n        ContentBlock, Message, MessageRequest, SystemPrompt, is_incomplete_stop_reason,\n        stop_reason_detail,","sourceCodeStart":11765,"sourceCodeEnd":11801,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/lib.rs#L11765-L11801","documentation":"In the one-shot text output path, after printing the model's response blocks, the stop reason returned by the provider is checked with `is_incomplete_stop_reason`; if the response was cut short (e.g. max tokens, length), the command bails so scripts treat it as failed even though partial text was printed.","triggerScenarios":"A one-shot model request completes HTTP-wise but the provider reports an incomplete stop reason (such as max_tokens/length) in the text-printing code path.","commonSituations":"Long generations hitting the provider's max-output-token limit, truncation from a small configured output budget, or provider-side cutoffs.","solutions":["Increase the max output tokens / output budget for the request.","Shorten the task or split it into multiple requests to fit the limit.","Inspect the reported stop reason in the message to confirm the cause and adjust request parameters accordingly."],"exampleFix":"// before\ncodewhale ask --model k3 --max-output-tokens 256 --prompt \"...long task...\"\n// after\ncodewhale ask --model k3 --max-output-tokens 8192 --prompt \"...long task...\"","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match run_one_shot_text(args) {\n    Err(e) if e.to_string().contains(\"Model response incomplete\") => {\n        // partial output already printed; raise token budget or split task and retry\n    }\n    other => other?,\n}\n","preventionTips":["Set a max-output-token budget comfortably above expected answer size.","Treat printed partial text as untrusted until the command exits 0.","Split long tasks into chunked requests instead of one giant generation."],"tags":["model","stop-reason","truncation","cli"],"backgroundTag":"unexpected-response-shape","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"}