fix markdown/pdf ai panels surfacing a truncated reply as "no reply" (#184)

A BYOK reasoning model can spend the whole output budget on thinking and
close the turn with finish_reason=length and no prose at all. The loop
already reports that as `truncated`, and docs appends aiTruncatedNote to
the bubble, but markdown and pdf destructure only
{text, cancelled, turnLimit} — so the run rendered the bare "(no reply)"
(while an empty "(no reply)" turn also made the following turns look like
the assistant had stopped listening).

Probe against api.deepseek.com/v1 (max_tokens=50/3000, thinking on by
default): completion_tokens == reasoning_tokens, content deltas never
start, finish_reason=length — reasoning tokens are billed against
max_tokens, at ~129 tok/s (≈ the agent default cap of 8192 in 60s).

Both panels now take `truncated` and append the note exactly like docs;
aiTruncatedNote is added to all 19 locales of both apps, copied from
apps/docs/src/renderer/i18n/ai/*.ts so the wording stays uniform.
This commit is contained in:
konghaojie-k2
2026-09-03 14:51:12 +08:00
committed by GitHub
parent 9f971edafa
commit 99d376b3c3
4 changed files with 62 additions and 4 deletions
+8 -2
View File
@@ -262,10 +262,16 @@ export function AiPanel({
patchLast({ streaming: false })
setChat((prev) => [...prev, { role: 'assistant', text: '', streaming: true }])
},
onDone: ({ text, cancelled, turnLimit }) => {
const final = turnLimit
onDone: ({ text, cancelled, turnLimit, truncated }) => {
const base = turnLimit
? [text, tGlobal('aiTurnLimit')].filter(Boolean).join('\n\n')
: text || (cancelled ? tGlobal('aiStopped') : '')
// A reasoning model can spend the entire output budget on thinking and close the
// turn with finish_reason=length and no prose at all — the bare "(no reply)" read
// as the assistant ignoring the user. Name the truncation, as docs already does.
const final = truncated
? [base, tGlobal('aiTruncatedNote')].filter(Boolean).join('\n\n')
: base
patchLast((last) => ({
streaming: false,
text: final || (last.tools?.length ? last.text : tGlobal('aiNoReply')),
@@ -140,6 +140,7 @@ export const strings = {
aiGroupWorking: '处理中…',
aiStopped: '已停止',
aiNoReply: '(无回复)',
aiTruncatedNote: '(回复因长度限制被截断,内容可能不完整。)',
aiTurnLimit: '已达到单次运行的步数上限,如需继续请再发一条指令。',
aiUndelivered: '未发送成功',
aiRetry: '重试',
@@ -302,6 +303,7 @@ export const strings = {
aiGroupWorking: 'Working…',
aiStopped: 'Stopped',
aiNoReply: '(no reply)',
aiTruncatedNote: '(The reply was cut off by the length limit and may be incomplete.)',
aiTurnLimit: 'Reached the per-run step limit — send another instruction to continue.',
aiUndelivered: 'Not sent',
aiRetry: 'Retry',
@@ -462,6 +464,7 @@ export const strings = {
aiGroupWorking: '処理中…',
aiStopped: '停止しました',
aiNoReply: '(返信なし)',
aiTruncatedNote: '(返信は長さ制限により途中で打ち切られ、不完全な可能性があります。)',
aiTurnLimit: '1 回の実行のステップ上限に達しました。続けるには指示をもう一度送ってください。',
aiUndelivered: '送信できませんでした',
aiRetry: '再試行',
@@ -623,6 +626,7 @@ export const strings = {
aiGroupWorking: '작업 중…',
aiStopped: '중지됨',
aiNoReply: '(응답 없음)',
aiTruncatedNote: '(응답이 길이 제한으로 잘려 내용이 불완전할 수 있습니다.)',
aiTurnLimit: '실행당 단계 한도에 도달했습니다. 계속하려면 지시를 다시 보내세요.',
aiUndelivered: '전송되지 않았습니다',
aiRetry: '다시 시도',
@@ -787,6 +791,8 @@ export const strings = {
aiGroupWorking: 'En cours…',
aiStopped: 'Arrêté',
aiNoReply: '(aucune réponse)',
aiTruncatedNote:
'(La réponse a été tronquée par la limite de longueur et peut être incomplète.)',
aiTurnLimit:
"Limite d'étapes atteinte pour cette exécution — envoyez une autre instruction pour continuer.",
aiUndelivered: 'Non envoyé',
@@ -952,6 +958,8 @@ export const strings = {
aiGroupWorking: 'In Arbeit…',
aiStopped: 'Gestoppt',
aiNoReply: '(keine Antwort)',
aiTruncatedNote:
'(Die Antwort wurde durch das Längenlimit abgeschnitten und ist möglicherweise unvollständig.)',
aiTurnLimit: 'Schrittlimit pro Lauf erreicht — senden Sie eine weitere Anweisung.',
aiUndelivered: 'Nicht gesendet',
aiRetry: 'Erneut versuchen',
@@ -1116,6 +1124,8 @@ export const strings = {
aiGroupWorking: 'En curso…',
aiStopped: 'Detenido',
aiNoReply: '(sin respuesta)',
aiTruncatedNote:
'(La respuesta fue cortada por el límite de longitud y puede estar incompleta.)',
aiTurnLimit:
'Se alcanzó el límite de pasos por ejecución; envía otra instrucción para continuar.',
aiUndelivered: 'No enviado',
@@ -1276,6 +1286,7 @@ export const strings = {
aiGroupWorking: 'กำลังทำงาน…',
aiStopped: 'หยุดแล้ว',
aiNoReply: '(ไม่มีการตอบกลับ)',
aiTruncatedNote: '(คำตอบถูกตัดเนื่องจากถึงขีดจำกัดความยาว เนื้อหาอาจไม่สมบูรณ์)',
aiTurnLimit: 'ถึงขีดจำกัดขั้นตอนต่อรอบแล้ว ส่งคำสั่งอีกครั้งเพื่อดำเนินการต่อ',
aiUndelivered: 'ส่งไม่สำเร็จ',
aiRetry: 'ลองใหม่',
@@ -1437,6 +1448,7 @@ export const strings = {
aiGroupWorking: 'Sedang bekerja…',
aiStopped: 'Dihentikan',
aiNoReply: '(tidak ada balasan)',
aiTruncatedNote: '(Balasan terpotong karena batas panjang dan mungkin tidak lengkap.)',
aiTurnLimit: 'Batas langkah per eksekusi tercapai — kirim instruksi lagi untuk melanjutkan.',
aiUndelivered: 'Tidak terkirim',
aiRetry: 'Coba lagi',
@@ -1599,6 +1611,7 @@ export const strings = {
aiGroupWorking: 'Выполняется…',
aiStopped: 'Остановлено',
aiNoReply: '(нет ответа)',
aiTruncatedNote: '(Ответ был обрезан из-за ограничения длины и может быть неполным.)',
aiTurnLimit: 'Достигнут лимит шагов за один запуск — отправьте ещё одну инструкцию.',
aiUndelivered: 'Не отправлено',
aiRetry: 'Повторить',
@@ -1758,6 +1771,7 @@ export const strings = {
aiGroupWorking: 'جارٍ العمل…',
aiStopped: 'تم الإيقاف',
aiNoReply: '(لا يوجد رد)',
aiTruncatedNote: '(تم اقتطاع الرد بسبب حد الطول وقد يكون غير مكتمل.)',
aiTurnLimit: 'تم بلوغ حد الخطوات لكل تشغيل — أرسل تعليمات أخرى للمتابعة.',
aiUndelivered: 'لم يتم الإرسال',
aiRetry: 'إعادة المحاولة',
@@ -1922,6 +1936,7 @@ export const strings = {
aiGroupWorking: 'Em andamento…',
aiStopped: 'Parado',
aiNoReply: '(sem resposta)',
aiTruncatedNote: '(A resposta foi cortada pelo limite de comprimento e pode estar incompleta.)',
aiTurnLimit: 'Limite de etapas por execução atingido — envie outra instrução para continuar.',
aiUndelivered: 'Não enviado',
aiRetry: 'Tentar novamente',
@@ -2085,6 +2100,8 @@ export const strings = {
aiGroupWorking: 'In corso…',
aiStopped: 'Interrotto',
aiNoReply: '(nessuna risposta)',
aiTruncatedNote:
'(La risposta è stata troncata dal limite di lunghezza e potrebbe essere incompleta.)',
aiTurnLimit: "Raggiunto il limite di passaggi per esecuzione — invia un'altra istruzione.",
aiUndelivered: 'Non inviato',
aiRetry: 'Riprova',
@@ -2247,6 +2264,7 @@ export const strings = {
aiGroupWorking: 'W toku…',
aiStopped: 'Zatrzymano',
aiNoReply: '(brak odpowiedzi)',
aiTruncatedNote: '(Odpowiedź została ucięta przez limit długości i może być niepełna.)',
aiTurnLimit: 'Osiągnięto limit kroków — wyślij kolejną instrukcję, aby kontynuować.',
aiUndelivered: 'Nie wysłano',
aiRetry: 'Ponów',
@@ -2410,6 +2428,7 @@ export const strings = {
aiGroupWorking: 'Bezig…',
aiStopped: 'Gestopt',
aiNoReply: '(geen antwoord)',
aiTruncatedNote: '(Het antwoord is afgekapt door de lengtelimiet en is mogelijk onvolledig.)',
aiTurnLimit: 'Stappenlimiet per run bereikt — stuur nog een instructie om door te gaan.',
aiUndelivered: 'Niet verzonden',
aiRetry: 'Opnieuw proberen',
@@ -2571,6 +2590,7 @@ export const strings = {
aiGroupWorking: 'Sedang berjalan…',
aiStopped: 'Dihentikan',
aiNoReply: '(tiada balasan)',
aiTruncatedNote: '(Balasan terpotong kerana had panjang dan mungkin tidak lengkap.)',
aiTurnLimit: 'Had langkah setiap larian dicapai — hantar arahan lain untuk teruskan.',
aiUndelivered: 'Tidak dihantar',
aiRetry: 'Cuba lagi',
@@ -2729,6 +2749,7 @@ export const strings = {
aiGroupWorking: 'בעבודה…',
aiStopped: 'נעצר',
aiNoReply: '(אין תשובה)',
aiTruncatedNote: '(התשובה נחתכה בגלל מגבלת האורך וייתכן שאינה שלמה.)',
aiTurnLimit: 'הגעתם למגבלת הצעדים להרצה — שלחו הוראה נוספת כדי להמשיך.',
aiUndelivered: 'לא נשלח',
aiRetry: 'נסו שוב',
@@ -2891,6 +2912,7 @@ export const strings = {
aiGroupWorking: 'कार्य जारी…',
aiStopped: 'रोका गया',
aiNoReply: '(कोई उत्तर नहीं)',
aiTruncatedNote: '(उत्तर लंबाई सीमा के कारण कट गया और अधूरा हो सकता है।)',
aiTurnLimit: 'प्रति रन चरण सीमा पूरी हुई — जारी रखने के लिए एक और निर्देश भेजें।',
aiUndelivered: 'भेजा नहीं गया',
aiRetry: 'पुनः प्रयास',
@@ -3048,6 +3070,7 @@ export const strings = {
aiGroupWorking: '處理中…',
aiStopped: '已停止',
aiNoReply: '(無回覆)',
aiTruncatedNote: '(回覆因長度限制被截斷,內容可能不完整。)',
aiTurnLimit: '已達到單次執行的步驟上限,如需繼續請再傳送一則指令。',
aiUndelivered: '未傳送成功',
aiRetry: '重試',
+8 -2
View File
@@ -353,10 +353,16 @@ export function AiPanel({
patchLast({ streaming: false })
setChat((prev) => [...prev, { role: 'assistant', text: '', streaming: true }])
},
onDone: ({ text, cancelled, turnLimit }) => {
const final = turnLimit
onDone: ({ text, cancelled, turnLimit, truncated }) => {
const base = turnLimit
? [text, tGlobal('aiTurnLimit')].filter(Boolean).join('\n\n')
: text || (cancelled ? tGlobal('aiStopped') : '')
// finish_reason=length with no prose (a reasoning model that spent the whole
// output budget thinking) must say so instead of showing the bare "(no reply)",
// which reads like the assistant ignored the user — same handling as docs
const final = truncated
? [base, tGlobal('aiTruncatedNote')].filter(Boolean).join('\n\n')
: base
if (cancelled) {
segTextRef.current = ''
runTextsRef.current = []
+23
View File
@@ -247,6 +247,7 @@ export const strings = {
aiWorking: '继续处理中',
aiStopped: '已停止',
aiNoReply: '(无回复)',
aiTruncatedNote: '(回复因长度限制被截断,内容可能不完整。)',
aiTurnLimit: '已达到单次任务的步数上限,回复"继续"让我接着做。',
aiUnknownError: '未知错误',
aiTimeoutError: 'AI 请求超时:网络长时间无响应,已停止。请检查网络后重试',
@@ -520,6 +521,7 @@ export const strings = {
aiWorking: 'Working',
aiStopped: 'Stopped',
aiNoReply: '(no reply)',
aiTruncatedNote: '(The reply was cut off by the length limit and may be incomplete.)',
aiTurnLimit: 'Reached the step limit for this task — say "continue" to keep going.',
aiUnknownError: 'Unknown error',
aiTimeoutError:
@@ -797,6 +799,7 @@ export const strings = {
aiWorking: '処理中',
aiStopped: '停止しました',
aiNoReply: '(応答なし)',
aiTruncatedNote: '(返信は長さ制限により途中で打ち切られ、不完全な可能性があります。)',
aiTurnLimit: 'ステップ上限に達しました。「続けて」と送ると継続します。',
aiUnknownError: '不明なエラー',
aiTimeoutError:
@@ -1075,6 +1078,7 @@ export const strings = {
aiWorking: '처리 중',
aiStopped: '중지됨',
aiNoReply: '(응답 없음)',
aiTruncatedNote: '(응답이 길이 제한으로 잘려 내용이 불완전할 수 있습니다.)',
aiTurnLimit: '단계 한도에 도달했습니다. "계속"이라고 보내면 이어서 합니다.',
aiUnknownError: '알 수 없는 오류',
aiTimeoutError:
@@ -1355,6 +1359,8 @@ export const strings = {
aiWorking: 'Traitement',
aiStopped: 'Arrêté',
aiNoReply: '(pas de réponse)',
aiTruncatedNote:
'(La réponse a été tronquée par la limite de longueur et peut être incomplète.)',
aiTurnLimit: 'Limite d’étapes atteinte — dites « continue » pour poursuivre.',
aiUnknownError: 'Erreur inconnue',
aiTimeoutError:
@@ -1637,6 +1643,8 @@ export const strings = {
aiWorking: 'Verarbeitung',
aiStopped: 'Gestoppt',
aiNoReply: '(keine Antwort)',
aiTruncatedNote:
'(Die Antwort wurde durch das Längenlimit abgeschnitten und ist möglicherweise unvollständig.)',
aiTurnLimit: 'Schrittlimit erreicht — sagen Sie „weiter", um fortzufahren.',
aiUnknownError: 'Unbekannter Fehler',
aiTimeoutError:
@@ -1917,6 +1925,8 @@ export const strings = {
aiWorking: 'Procesando',
aiStopped: 'Detenido',
aiNoReply: '(sin respuesta)',
aiTruncatedNote:
'(La respuesta fue cortada por el límite de longitud y puede estar incompleta.)',
aiTurnLimit: 'Límite de pasos alcanzado; di «continúa» para seguir.',
aiUnknownError: 'Error desconocido',
aiTimeoutError:
@@ -2198,6 +2208,7 @@ export const strings = {
aiWorking: 'กำลังดำเนินการ',
aiStopped: 'หยุดแล้ว',
aiNoReply: '(ไม่มีคำตอบ)',
aiTruncatedNote: '(คำตอบถูกตัดเนื่องจากถึงขีดจำกัดความยาว เนื้อหาอาจไม่สมบูรณ์)',
aiTurnLimit: 'ถึงขีดจำกัดขั้นตอนแล้ว พิมพ์ "ทำต่อ" เพื่อดำเนินการต่อ',
aiUnknownError: 'ข้อผิดพลาดที่ไม่รู้จัก',
aiTimeoutError:
@@ -2476,6 +2487,7 @@ export const strings = {
aiWorking: 'Memproses',
aiStopped: 'Dihentikan',
aiNoReply: '(tidak ada balasan)',
aiTruncatedNote: '(Balasan terpotong karena batas panjang dan mungkin tidak lengkap.)',
aiTurnLimit: 'Batas langkah tercapai — ketik "lanjutkan" untuk meneruskan.',
aiUnknownError: 'Kesalahan tidak dikenal',
aiTimeoutError:
@@ -2756,6 +2768,7 @@ export const strings = {
aiWorking: 'Обработка',
aiStopped: 'Остановлено',
aiNoReply: '(нет ответа)',
aiTruncatedNote: '(Ответ был обрезан из-за ограничения длины и может быть неполным.)',
aiTurnLimit: 'Достигнут лимит шагов — напишите «продолжай», чтобы продолжить.',
aiUnknownError: 'Неизвестная ошибка',
aiTimeoutError:
@@ -3035,6 +3048,7 @@ export const strings = {
aiWorking: 'جارٍ المعالجة',
aiStopped: 'تم الإيقاف',
aiNoReply: '(لا رد)',
aiTruncatedNote: '(تم اقتطاع الرد بسبب حد الطول وقد يكون غير مكتمل.)',
aiTurnLimit: 'تم بلوغ حد الخطوات — اكتب «تابع» للمواصلة.',
aiUnknownError: 'خطأ غير معروف',
aiTimeoutError:
@@ -3313,6 +3327,7 @@ export const strings = {
aiWorking: 'Processando',
aiStopped: 'Parado',
aiNoReply: '(sem resposta)',
aiTruncatedNote: '(A resposta foi cortada pelo limite de comprimento e pode estar incompleta.)',
aiTurnLimit: 'Limite de etapas atingido — diga "continuar" para prosseguir.',
aiUnknownError: 'Erro desconhecido',
aiTimeoutError:
@@ -3595,6 +3610,8 @@ export const strings = {
aiWorking: 'Elaborazione',
aiStopped: 'Interrotto',
aiNoReply: '(nessuna risposta)',
aiTruncatedNote:
'(La risposta è stata troncata dal limite di lunghezza e potrebbe essere incompleta.)',
aiTurnLimit: 'Limite di passaggi raggiunto — scrivi "continua" per proseguire.',
aiUnknownError: 'Errore sconosciuto',
aiTimeoutError:
@@ -3877,6 +3894,7 @@ export const strings = {
aiWorking: 'Przetwarzanie',
aiStopped: 'Zatrzymano',
aiNoReply: '(brak odpowiedzi)',
aiTruncatedNote: '(Odpowiedź została ucięta przez limit długości i może być niepełna.)',
aiTurnLimit: 'Osiągnięto limit kroków — napisz „kontynuuj", aby dokończyć.',
aiUnknownError: 'Nieznany błąd',
aiTimeoutError:
@@ -4159,6 +4177,7 @@ export const strings = {
aiWorking: 'Bezig met verwerken',
aiStopped: 'Gestopt',
aiNoReply: '(geen antwoord)',
aiTruncatedNote: '(Het antwoord is afgekapt door de lengtelimiet en is mogelijk onvolledig.)',
aiTurnLimit: 'Stappenlimiet bereikt — zeg "ga door" om verder te gaan.',
aiUnknownError: 'Onbekende fout',
aiTimeoutError:
@@ -4439,6 +4458,7 @@ export const strings = {
aiWorking: 'Sedang memproses',
aiStopped: 'Dihentikan',
aiNoReply: '(tiada balasan)',
aiTruncatedNote: '(Balasan terpotong kerana had panjang dan mungkin tidak lengkap.)',
aiTurnLimit: 'Had langkah dicapai — taip "teruskan" untuk menyambung.',
aiUnknownError: 'Ralat tidak diketahui',
aiTimeoutError:
@@ -4717,6 +4737,7 @@ export const strings = {
aiWorking: 'מעבד',
aiStopped: 'הופסק',
aiNoReply: '(אין תשובה)',
aiTruncatedNote: '(התשובה נחתכה בגלל מגבלת האורך וייתכן שאינה שלמה.)',
aiTurnLimit: 'הגעת למגבלת הצעדים של המשימה — כתבו "המשך" כדי שאמשיך.',
aiUnknownError: 'שגיאה לא ידועה',
aiTimeoutError: 'תם הזמן לבקשת ה-AI: אין תגובה מהרשת וההרצה הופסקה. בדוק את החיבור ונסה שוב',
@@ -4991,6 +5012,7 @@ export const strings = {
aiWorking: 'प्रोसेस हो रहा है',
aiStopped: 'रोका गया',
aiNoReply: '(कोई उत्तर नहीं)',
aiTruncatedNote: '(उत्तर लंबाई सीमा के कारण कट गया और अधूरा हो सकता है।)',
aiTurnLimit: 'इस कार्य की चरण सीमा पूरी हो गई — जारी रखने के लिए "जारी रखें" लिखें।',
aiUnknownError: 'अज्ञात त्रुटि',
aiTimeoutError:
@@ -5268,6 +5290,7 @@ export const strings = {
aiWorking: '繼續處理中',
aiStopped: '已停止',
aiNoReply: '(無回覆)',
aiTruncatedNote: '(回覆因長度限制被截斷,內容可能不完整。)',
aiTurnLimit: '已達到單次任務的步數上限,回覆「繼續」讓我接著做。',
aiUnknownError: '未知錯誤',
aiTimeoutError: 'AI 請求逾時:網路長時間無回應,已停止。請檢查網路後重試',