Repository navigation
v0.1.8
cell 0.1.8
修复:空回复诊断 + 上下文溢出自动压缩
小本地模型(gemma4 / qwen 等,经 Ollama)在对话超出上下文窗口后,仍回 HTTP 200 + 空 choices + 完整 usage——旧版本把这种「成功外衣下的失败」吞成一句泛化的 empty reply,并丢失了 provider 的 finish_reason / prompt_tokens。
- 三个流式客户端(openai-chat / Responses / Anthropic)现在都捕获
finish_reason/stop_reason;空完成时构造可读诊断,明确写出finish_reason与prompt_tokens。 - 当
finish_reason=length或prompt_tokens ≥ 3072(也认 Anthropic / Responses 的input_tokens)时判为上下文压力:置err含context window且ok=false,run_turn据此自动压缩历史并重试,而不是以死路告终。 - openai-chat 增加「单 JSON body」回退,兼容忽略
stream:true的 Ollama / 代理(直接回一整个 JSON 而非 SSE 帧)。 run_turn的空回复守卫改用 provider 诊断作turn_error;前端失败气泡与 SSEerror事件现在携带完整 provider 信息(例如provider returned an empty completion (finish_reason=stop); prompt_tokens=3969 — the conversation likely exceeded the model context window; auto-compacting and retrying)。
测试
- 新增 6 个
empty_completion_diagnosticselftest:finish_reason=length(压力 + 命名 finish_reason + prompt_tokens)、大prompt_tokens+stop(压力)、小prompt_tokens(非压力但报告 token)、unknown(非压力 + 报告 unknown)、content_filter(非压力 + 命名 filtered)、input_tokens代理(Anthropic / Responses 客户端)。
提交
7c73e00fix: surface the provider's real empty-completion diagnostic and auto-compact on context-window pressure3131c33test: assert the empty-completion diagnostic names finish_reason and flags context pressure (incl. input_tokens for Anthropic/Responses)