Skip to content

reasoning_content 字段名硬编码导致 OpenRouter 风格 provider 的截断重试完全失效 #476

Description

@HarfordNova

现象
使用 Nous inference-api(deepseek/deepseek-v4-flash-0731)时,后台任务(kg_extraction、daily_briefing、thread_synced、memory_created)大面积报:
the model completed without returning final answer text
error_kind=other status=partial

换成小米 MiMo(mimo-v2.5)后同样的任务、同样的预算全部成功。

根因(已用脚本直连两个 endpoint 实测验证)
nmem 的 escalation 重试逻辑绑定在 reasoning_only=true 上,而这个判定依赖从 reasoning_content 字段读取思考内容。rig-core 的 Message 结构体只声明了 reasoning_content,没有 reasoning。

但业界存在两种字段命名:

Nous inference-api(OpenRouter 风格,实测)

message keys: ['content', 'reasoning', 'reasoning_details', 'refusal', 'role']
reasoning: LEN=8146 ← nmem 读不到,反序列化时丢弃
finish_reason: length
usage.completion_tokens_details.reasoning_tokens: 2102

小米 MiMo(DeepSeek/OpenAI 风格,实测)

message keys: ['content', 'reasoning_content', 'role', 'tool_calls']
reasoning_content: LEN=1225 ← nmem 读得到
content: LEN=0
finish_reason: length

于是:Nous 的响应在 nmem 眼里"既没有 reasoning、content 也不完整" → reasoning_only=false → escalation 分支跳过 → 任务直接失败。MiMo 则能正常触发扩容重试。

日志对照
MiMo,兜底生效:
17:44:11 scheduler LLM attempt finished attempt=0 task_type=memory_created output_budget=900 ok=true input_tokens=4611 output_tokens=900 reasoning_only=true
17:44:11 WARN model used the output budget for reasoning without a final answer; retrying once previous_output_budget=900 expanded_output_budget=16384
17:45:15 scheduler LLM attempt finished attempt=0 task_type=memory_created output_budget=16384 ok=true output_tokens=1546 reasoning_only=false
17:45:15 scheduler task finished task_type=memory_created status=success

Nous,兜底失效:
01:41:39 scheduler LLM attempt starting attempt=0 task_type=kg_extraction_backfill output_budget=3072
01:42:30 scheduler LLM attempt finished attempt=0 task_type=kg_extraction_backfill output_budget=3072 ok=true input_tokens=3127 output_tokens=3072 reasoning_only=false
01:42:30 WARN KG extraction failed for memory; recorded per-memory retry state memory_id=5dc89cb8-7a34-4edf-b132-4c35f8001dfb error=the model completed without returning final answer text failure_count=1 error_kind=other dead_letter=false retry_after="2026-08-06T18:12:30.231591+00:00"

output_tokens=3072 == output_budget=3072,标准长度截断,连续 20+ 条同一模式,全部进 30 分钟后重试队列,重试再撞同一堵墙。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions