{"record":{"id":"50b932b0d96b518a","repo":"Hmbown/CodeWhale","slug":"output-limit-truncated-checked-above","errorCode":null,"errorMessage":"output_limit_truncated checked above","messagePattern":"output_limit_truncated checked above","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/core/engine/turn_loop.rs","lineNumber":1573,"sourceCode":"            let thinking_only_no_sendable = !has_sendable_assistant_content;\n\n            // Add assistant message to session\n            if has_sendable_assistant_content {\n                self.add_session_message(Message {\n                    role: \"assistant\".to_string(),\n                    content: content_blocks,\n                })\n                .await;\n            }\n\n            // A truncated response with no tool call cannot continue through\n            // tool execution: surface the truncation as a bounded observation\n            // and resume the loop so the model can act on it instead of the\n            // turn silently ending on a cut-off answer.\n            if output_limit_truncated.is_some() && tool_uses.is_empty() {\n                let reason = output_limit_truncated\n                    .take()\n                    .expect(\"output_limit_truncated checked above\");\n                self.add_session_message(\n                    self.runtime_text_message_with_turn_metadata(\n                        format!(\n                            \"[runtime] The provider stopped generation at its output limit (`{reason}`) before completing. Your last response was cut off. Continue from where you left off; do not repeat content already delivered.\"\n                        ),\n                        UserInputProvenance::Runtime,\n                    ),\n                )\n                .await;\n                let _ = self\n                    .tx_event\n                    .send(Event::status(\n                        \"Continuing — provider output limit reached; asking the model to continue\"\n                            .to_string(),\n                    ))\n                    .await;\n                turn.next_step();\n                continue;","sourceCodeStart":1555,"sourceCodeEnd":1591,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/core/engine/turn_loop.rs#L1555-L1591","documentation":"Invariant in run_turn(): whether the response was truncated by the output limit (output_limit_truncated) was decided earlier in the loop body; a later branch asserts that flag was already computed. Firing indicates control flow was reordered or a path skips the earlier check — a code bug.","triggerScenarios":"Thrown at crates/tui/src/core/engine/turn_loop.rs:1573 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Restore the earlier truncation check on every path that reaches this point","Restructure the loop so truncation state is computed before any consumer"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}