fix(models): reject empty Messages responses with retained evidence
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
# 推理开关、强度与空响应修复
|
||||
|
||||
起点:`b74e5edc`,工作树干净,正式服务仍为1.25.2。用户补充:推理应由使用者开启并选择强度,不能只接入DeepSeek关闭推理。沿用模型中心原生参数保存接口和每次实际请求封存,不另立配置体系。
|
||||
|
||||
1. 核对官方Chat、Responses、Messages与DeepSeek契约。按协议提供默认、关闭和开启/强度;保留高级JSON及已有参数,明确不同型号的支持范围。DeepSeek工具往返必须保留所属响应的reasoning_content,不能只发开关。
|
||||
用户进一步明确品牌与自定义兼容接口均应配套同步功能/能力:用一份可复用的参数配置档贯通品牌建议、自定义覆盖、原生参数、导入、冻结请求与界面。逐项列出已有文本/工具/流式/图像、推理及未接入能力,声明与实测保持原区分;不得把/models返回的型号列表当完整能力目录。
|
||||
2. 完整但没有文字或工具的Messages响应明确失败,保留原文、原用量、身份、停止原因;不自动重试或消耗剩余实验请求。
|
||||
3. 分阶段实现并验证参数契约、预算、JSON/SSE工具往返、历史恢复/跨线路隔离、HTTP持久化及界面保存刷新、桌面/390px和失败恢复。各阶段回顾、检查diff并本地提交。
|
||||
4. 产品修复独立发行与保留状态升级,完成前不得称正式可用;发行沿用不可变载荷、独立重建/安装及原PID/Provider保留核对。
|
||||
|
||||
本阶段真实模型请求0,不读取/复制/解密/重存真实Key,不续跑旧实验,不推送、不委派。Z3空响应、DeepSeek length、其它网络/重复读取/自主交付及Purge未知保持;本次修复不证明供应商稳定或自主工程交付。
|
||||
|
||||
## 阶段记录
|
||||
|
||||
- 起步:读取AGENTS与两份采用计划,确认现有表单只有JSON;Chat尚不接受thinking,Messages已有thinking历史但没有output_config.effort;Chat流式/历史路径待核对。一次猜测不存在的chat-stream.mjs读取失败,无文件变化,后续用rg定位。
|
||||
- 阶段一通过:Messages JSON/SSE真实本机HTTP复现空响应,原6692输入/0输出完整保留,单次protocol错误、0工具/重发。空数组、空白与仅opaque thinking拒绝,合法文字/工具保留;Messages相关28/28通过,日志.qa/reasoning-controls/messages-tests.txt。修复尚未部署。
|
||||
- 官方来源:DeepSeek既有Thinking Mode原HTML保持;OpenAI Docs查阅Chat与reasoning-effort;Claude文档重定向地区不可用页,已保存原失败,随后官方SDK原始类型取得HTTP200,确认output_config.effort支持low/medium/high/xhigh/max。一次node_repl网络等待超时、几次不存在的可选路径读取错误均无产品影响,后续改curl有界及已有实际文件定位。
|
||||
@@ -1,5 +1,7 @@
|
||||
# 汇总发现
|
||||
|
||||
推理设置补充:用户要求可开启并选择强度,不能仅支持thinking.disabled。DeepSeek官方Chat思考开关为thinking.type,强度low/high/max;携带tools的后续请求必须完整回传所有已有reasoning_content。OpenAI官方Chat/Responses强度受型号限制(none/minimal/low/medium/high/xhigh/max),不能在UI宣称所有模型都支持关闭。新增工作见docs/REASONING-CONTROLS-PLAN.md,真实请求暂0。
|
||||
|
||||
Z:Claude请求5.5/返回5-5的型号手误,用户已确认并保存新连接/凭据修订2,首样本1请求176tokens保留。DeepSeek默认high推理;预检146tokens通过,Node5请求47740tokens末轮finish_reason=length,2048输出全部reasoning_tokens,完整SSE也不能当完整答复;identity incomplete、0提案/修改/交付,原九基线失败/build通过。两轮151份82988849字节证据离线通过,原状态/预算/选线/凭据恢复,不续跑旧Task。官方Thinking Mode原HTML117778字节和SHA保存,当前Chat白名单不支持thinking是明确兼容缺口,不能假装已发送该参数或归因网络。
|
||||
|
||||
Y:1预检110tokens与8Node64500tokens全部matched,0上游失败/未知,三源码模型提案并封存应用,最后inspect_session/step_limit,未检查或Git交付。原Node收尾已恢复配置但因3条其它网络诊断追加失败;原11条诊断前缀按完整metadata行SHA精确重建。开场顺序快照池6、稍后驱动冻结池7(外部加DeepSeek)均保留;两次只读复核误判和准确时点对照不覆盖。独立对账84原导出/3777原工件/234原尝试/原行及配置通过;当前69/85/6607/13944、3857工件,原PID36552/Provider、凭据1、身份来源、9229关闭保持。用户指定apikey-Claude/DeepSeek另冻,不续跑Y。
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# 统一执行进度
|
||||
|
||||
## 推理控制与空响应修复
|
||||
|
||||
- 阶段一:Messages空响应诊断与JSON/SSE原6692/0用量回归28/28通过;用户补充品牌/自定义兼容的整套能力同步,纳入版本化参数配置档/导入/请求/界面与能力状态说明。正式尚未变更,真实请求0。
|
||||
|
||||
- b74e5edc干净接续。用户明确补充推理可开启/选择强度,扩展原disabled单项范围;沿用product-ui-ux/frontend-design/planning-with-files,查官方参数和工具历史。一次不存在的chat-stream.mjs读取失败已记计划,后续rg定位。正式仍1.25.2,本阶段不发真实模型请求。
|
||||
|
||||
## 1.25.2 可靠性闭环
|
||||
|
||||
- 发行证据及原字节索引核对后提交06674583,树干净。X initial第15行发现jojocode enabled=false/revision12,任何样本/请求前拒绝。用户明确选择当前启用apikey,另冻Y,不沿用X;Y使用93d连接/Chat SSE/原身份来源,原工程目标和预算保持。驱动/新计划先语法、同目标与预算复核提交,再实际冻结;不启用jojocode,不碰Key。
|
||||
|
||||
@@ -68,6 +68,7 @@ export function normalizeProtocolResponse(config, value) {
|
||||
} else throw protocolFailure('Messages 包含未接入或不完整的内容块:' + String(block?.type ?? '未知').slice(0, 100) + '。');
|
||||
}
|
||||
if ((value.stop_reason === 'tool_use') !== (calls.length > 0)) throw protocolFailure('Messages 停止原因与工具内容不一致。');
|
||||
if (!calls.length && !texts.join('').trim()) throw protocolFailure('Messages 返回为空:没有可用文本或工具调用。原响应及用量已保留,请核对供应商响应。');
|
||||
return { choices: [{ message: { role: 'assistant', content: texts.join(''), ...(calls.length ? { tool_calls: calls } : {}),
|
||||
providerState: { protocol: 'anthropic-messages', endpoint: config.baseUrl, model: config.model, responseId: value.id, content: structuredClone(value.content) } },
|
||||
finish_reason: calls.length ? 'tool_calls' : 'stop' }], usage: reportedUsage(config, value) };
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
5. [complete] X预冻结拒绝0请求保持;用户选择另冻Y,预检通过、Node8请求64500tokens三源码模型封存并应用,step_limit前未检查/交付。原诊断元数据收尾失败、开场外部池变化及两次只读复核错误保持;独立对账通过,不续跑Y。
|
||||
6. [complete] 用户指定Z两路线完成:Claude手误型号mismatch,DeepSeek预检通过但新Node第5请求2048输出全用于reasoning后length失败,0提案/交付;151份证据离线通过,状态恢复、原失败和回顾保持。
|
||||
7. [complete] 用户更正Claude后Z2返回GPT而停止;用户明确再试后Z3预检matched、Node首请求6692输入/0输出空内容,verification_incomplete暂停。两样本均封存并离线通过,原状态恢复、凭据3保持,不续跑。
|
||||
8. [in_progress] 实际证据支持的两处兼容修复:Messages完整但无内容应解释为空响应;Chat显式thinking.disabled支持。先自有HTTP/原预算/恢复及现有参数界面验证,再独立发行;真实模型0,旧失败保持。
|
||||
8. [in_progress] 推理开关/强度与空响应修复:用户补充使用者可开启并选择推理强度,扩展为按协议的实际控件与参数、DeepSeek推理工具历史、Messages空响应诊断。见docs/REASONING-CONTROLS-PLAN.md;先自有HTTP/预算/恢复与网页/桌面核心流程验证、阶段回顾和提交,再独立发行;真实模型0,旧失败保持。
|
||||
|
||||
细节和阶段回顾见docs/RELIABILITY-1.25.2.md。开始时session-catchup无待同步输出;计划文件首次补丁因findings标题上下文不符被拒且无文件变化,已按原标题修正。以下按历史时点理解。
|
||||
|
||||
|
||||
@@ -193,6 +193,38 @@ test('native JSON rejects incomplete stops, duplicate tools and hosted content',
|
||||
}
|
||||
});
|
||||
|
||||
test('Messages rejects empty, whitespace and thinking-only answers without rejecting valid text or tool calls', () => {
|
||||
for (const content of [[], [{ type: 'text', text: '' }], [{ type: 'text', text: ' \n ' }],
|
||||
[{ type: 'thinking', thinking: 'opaque fixture', signature: 'owned-signature' }], [{ type: 'redacted_thinking', data: 'owned-opaque' }]]) {
|
||||
assert.throws(() => normalizeProtocolResponse({ protocol }, message(content)), cause => cause.diagnostic?.kind === 'protocol' && /返回为空/.test(cause.message));
|
||||
}
|
||||
assert.equal(normalizeProtocolResponse({ protocol }, message()).choices[0].message.content, '完成。');
|
||||
assert.equal(normalizeProtocolResponse({ protocol }, message([tool])).choices[0].message.tool_calls.length, 1);
|
||||
});
|
||||
|
||||
for (const streaming of [false, true]) test('empty Messages ' + (streaming ? 'SSE' : 'JSON') + ' fails once with original response and 6692/0 usage, before verification or tools', async t => {
|
||||
const f = fixture(t), emptyUsage = { input_tokens: 338, cache_creation_input_tokens: 331, cache_read_input_tokens: 6023, output_tokens: 0 };
|
||||
const empty = message([], { usage: emptyUsage });
|
||||
const raw = streaming ? event('message_start', { message: { ...empty, stop_reason: null } })
|
||||
+ event('message_delta', { delta: { stop_reason: 'end_turn', stop_sequence: null }, usage: emptyUsage }) + event('message_stop') : JSON.stringify(empty);
|
||||
const server = streaming ? await streamingServer(t, res => res.end(raw)) : await compatibleFixture(t, () => empty);
|
||||
const provider = new Provider(), hub = provider.modelHub(f.store), connection = hub.upsert({ ...config(server.baseUrl), name: 'Owned empty Messages', requiresKey: false,
|
||||
streaming, capabilityDeclarations: { streaming: 'supported' } });
|
||||
hub.select({ type: 'connection', id: connection.id });
|
||||
const runtime = new Runtime(f.store, provider); t.after(() => runtime.stopAll());
|
||||
runtime.start(f.session.id, 'Read the project; run the required checks.'); await until(() => !runtime.isActive(f.session.id), 15000);
|
||||
assert.equal(f.session.status, 'failed'); assert.equal(f.session.failure.kind, 'protocol'); assert.match(f.session.failure.message, /返回为空/);
|
||||
assert.equal(server.requests.length, 1); assert.equal(f.session.events.filter(e => e.kind === 'tool').length, 0);
|
||||
assert.equal(f.session.providerMessages.filter(m => m.role === 'assistant').length, 0);
|
||||
const run = f.store.core.run.get(f.session.runId), attempts = hub.view().attempts;
|
||||
assert.equal(run.usage.inputTokens, 6692); assert.equal(run.usage.outputTokens, 0); assert.equal(run.usage.requests, 1);
|
||||
assert.equal(attempts.length, 1); assert.equal(attempts[0].status, 'failed'); assert.equal(attempts[0].usageStatus, 'reported');
|
||||
assert.equal(attempts[0].usage.total_tokens, 6692);
|
||||
const artifact = f.store.owned('artifact', attempts[0].responseArtifactId, f.session.id);
|
||||
assert.equal(f.store.artifactStore.read(artifact), raw); assert.equal(artifact.sha256, createHash('sha256').update(raw).digest('hex'));
|
||||
assert.equal(attempts[0].diagnostic.retryDecision, streaming ? 'stream_not_replayed' : 'not_retryable');
|
||||
});
|
||||
|
||||
test('strict SSE validates all blocks, terminal, event names, UTF8 and tool JSON before dispatch', async t => {
|
||||
const original = stream([tool]), start = event('message_start', { message: message([], { stop_reason: null }) });
|
||||
const cases = [original.replace(event('message_stop'), ''), original.replace('"partial_json":"{\\"path', '"partial_json":"!{\\"path'),
|
||||
|
||||
Reference in New Issue
Block a user