{"record":{"id":"0754b038a02b48ac","repo":"SubtitleEdit/subtitleedit","slug":"no-usable-translation-in-name-reply-error","errorCode":null,"errorMessage":"No usable translation in {Name} reply{Error}","messagePattern":"No usable translation in (.+?) reply(.+?)","errorType":"http","errorClass":"HttpRequestException","httpStatus":null,"severity":"error","filePath":"src/ui/Features/Translate/LlamaCppAdvanced/AdvancedTranslatorBase.cs","lineNumber":110,"sourceCode":"            {\n                for (var i = 0; i < count; i++)\n                {\n                    var translation = map[i + 1];\n                    rows[index + i].TranslatedText = translation.Length > 0 ? translation : rows[index + i].Text;\n                }\n            });\n\n            return count;\n        }\n\n        if (count > 1)\n        {\n            // The model could not fill the full batch - translate the first half only; the outer\n            // loop calls again for the rest (with the successful half now part of the history).\n            return await TranslateChunkAsync(rows, index, count / 2, sourceLanguageCode, targetLanguageCode, cancellationToken);\n        }\n\n        throw new HttpRequestException(\"No usable translation in \" + Name + \" reply\" +\n                                       (string.IsNullOrEmpty(Error) ? string.Empty : \": \" + Error));\n    }\n\n    private async Task<Dictionary<int, string>> TranslateLinesAsync(List<LlamaCppAdvancedProtocol.BatchLine> lines, List<LlamaCppAdvancedProtocol.HistoryPair> history, string sourceLanguageCode, string targetLanguageCode, CancellationToken cancellationToken)\n    {\n        var client = _client ?? throw new InvalidOperationException(\"Initialize() not called\");\n        var settings = Se.Settings.AutoTranslate.LlamaCppAdvanced;\n        var url = GetApiUrl();\n\n        // The \"codes\" this engine receives are English language names (ListLanguages puts the\n        // name in TranslationPair.Code), which is what the prompt expects.\n        var systemPrompt = LlamaCppAdvancedProtocol.BuildSystemPrompt(sourceLanguageCode, targetLanguageCode, settings);\n        var userContent = LlamaCppAdvancedProtocol.BuildUserContent(history, lines);\n        var responseFormat = LlamaCppAdvancedProtocol.BuildResponseFormatJson(lines);\n\n        var map = new Dictionary<int, string>();\n        for (var attempt = 0; attempt < 2 && !cancellationToken.IsCancellationRequested; attempt++)\n        {","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/SubtitleEdit/subtitleedit/blob/17a9f0748781032255db3526b7215d2fb891e3af/src/ui/Features/Translate/LlamaCppAdvanced/AdvancedTranslatorBase.cs#L92-L128","documentation":"Thrown by AdvancedTranslatorBase when a LlamaCpp-based translation engine returns zero usable translations from a batch, even after the code recursively halves the batch size down to 1 line. When count <= 1 and still no translation is produced, the method gives up and throws an HttpRequestException with the engine name and any error detail accumulated in the Error property.","triggerScenarios":"TranslateChunkAsync is called with a batch; the model's response yields 0 parsed translations. The code retries with count/2 (halving). If count was already 1 (or the recursive call also gets 0), the throw fires. This happens when the LlamaCpp server returns a response the parser cannot extract any translation from.","commonSituations":"The LlamaCpp model is too small or undertrained and outputs garbage/unparseable text; the system prompt format doesn't match the model's expected chat template; the context window is exceeded and the model truncates its output; the model echoes the prompt instead of translating; a quantization artefact causes repetitive empty output; the LlamaCpp server is misconfigured (wrong chat format, no instruct template).","solutions":["Verify the LlamaCpp server's chat template matches the model (use --chat-template or the correct .gguf with baked-in template).","Try a larger or instruction-tuned model that follows the translation prompt format.","Check the Error property value (appended to the message) for parser diagnostics.","Reduce the batch size setting so each request sends fewer lines, reducing parsing complexity.","Inspect the raw model output by enabling debug/verbose logging in the LlamaCppAdvancedProtocol to see what the server actually returned.","Ensure the source and target language codes passed are English language names (as the code comment notes ListLanguages puts the name in Code)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Verify the LlamaCpp server is reachable and responding before translation\nvar healthResp = await _httpClient.GetAsync(GetApiUrl() + \"/health\", cancellationToken);\nif (!healthResp.IsSuccessStatusCode)\n    throw new InvalidOperationException(\"LlamaCpp server is not responding at \" + GetApiUrl());","typeGuard":null,"tryCatchPattern":"try { return await TranslateChunkAsync(rows, index, count, src, tgt, ct); }\ncatch (HttpRequestException ex) when (ex.Message.Contains(\"No usable translation\"))\n{ /* log Error property, skip batch, fall back to single-line translation or different model */ }","preventionTips":["Test the LlamaCpp model with a simple single-line translation before batch processing.","Verify the model's chat template is correctly configured on the server.","Use a model size and quantization level appropriate for translation tasks (7B+ instruct models).","Keep batch sizes small to isolate which lines cause parse failures."],"tags":["ai","llm","llamacpp","translate","parsing-failure"],"backgroundTag":null,"analyzedSha":"17a9f0748781032255db3526b7215d2fb891e3af","analyzedAt":"2026-08-13T18:11:43.374Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}