fix(models): accept streamed thinking signatures and publish valid plan tools
This commit is contained in:
@@ -22,9 +22,13 @@ export function messagesStream() {
|
||||
const block = event.content_block;
|
||||
if (!object(block) || !['text', 'tool_use', 'thinking', 'redacted_thinking'].includes(block.type)) fail('未接入的内容块类型。');
|
||||
if (block.type === 'text' && typeof block.text !== 'string' || block.type === 'tool_use' && (!object(block.input) || typeof block.id !== 'string' || !block.id || typeof block.name !== 'string' || !block.name)
|
||||
|| block.type === 'thinking' && (typeof block.thinking !== 'string' || typeof block.signature !== 'string') || block.type === 'redacted_thinking' && typeof block.data !== 'string') fail('初始内容块格式无效。');
|
||||
|| block.type === 'thinking' && (typeof block.thinking !== 'string' || block.signature !== undefined && typeof block.signature !== 'string') || block.type === 'redacted_thinking' && typeof block.data !== 'string') fail('初始内容块格式无效。');
|
||||
if (block.type === 'tool_use' && (++toolCount > 12 || blocks.some(item => item.block.id === block.id))) fail('工具数量超限或身份重复。');
|
||||
blocks.push({ block: structuredClone(block), json: '', jsonSeen: false, closed: false }); active = event.index;
|
||||
// Thinking signatures normally arrive in a later signature_delta.
|
||||
// Final protocol normalization still requires a complete signature.
|
||||
const initial = structuredClone(block);
|
||||
if (initial.type === 'thinking') initial.signature ??= '';
|
||||
blocks.push({ block: initial, json: '', jsonSeen: false, closed: false }); active = event.index;
|
||||
if (block.type === 'text') text += block.text;
|
||||
} else if (event.type === 'content_block_delta') {
|
||||
if (active === null || event.index !== active || deltaSeen || !object(event.delta)) fail('内容片段缺少所属未完成块。');
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import { PLAN_READ_TOOLS } from './task-plans.mjs';
|
||||
|
||||
export const taskPlanToolDefinitions = [
|
||||
{ type: 'function', function: { name: 'plan_task', description: '为当前复杂任务保存1–12步有依赖的计划。每步固定通过条件及实际证据类别,规划不执行操作。expected_revision首次为0;以后保留全部原步骤并追加,不能删改条件掩盖失败。原用户要求或计划变化后重新封存并核验仍有效的原证据,不重跑已完成工具。', parameters: {
|
||||
type: 'object', additionalProperties: false, required: ['expected_revision', 'steps'], properties: { expected_revision: { type: 'integer', minimum: 0 }, steps: { type: 'array', minItems: 1, maxItems: 12, items: {
|
||||
type: 'object', additionalProperties: false, required: ['key', 'title', 'criterion', 'kind'], properties: {
|
||||
key: { type: 'string', pattern: '^[a-z][a-z0-9_-]{0,39}$' }, title: { type: 'string', maxLength: 100 }, criterion: { type: 'string', maxLength: 300 },
|
||||
kind: { type: 'string', enum: ['analysis', 'changes', 'results', 'checks', 'browser'] }, depends_on: { type: 'array', items: { type: 'string' }, maxItems: 12 },
|
||||
tools: { type: 'array', description: 'analysis必填,只读工具名称,例如inspect_project/read_file/query_code。', items: { type: 'string' } },
|
||||
tools: { type: 'array', description: 'analysis必填,仅限枚举中的只读工具;运行命令不属于读取证据。', items: { type: 'string', enum: PLAN_READ_TOOLS }, minItems: 1, maxItems: PLAN_READ_TOOLS.length, uniqueItems: true },
|
||||
paths: { type: 'array', description: 'changes/results必填,项目相对文件路径。changes仅核验本Task实际应用;results核验verify_existing_files的当前文件成果。', items: { type: 'string' }, maxItems: 32 },
|
||||
checks: { type: 'array', description: 'checks必填,仅核验当前源码的最新通过结果,名称如test/build/python:test。基线失败仍保留在检查日志,不设为checks计划步骤;改动后的通过验收再设此步骤。', items: { type: 'string' }, maxItems: 6 },
|
||||
viewport_width: { type: 'integer', description: 'browser必填,固定桌面/手机视口宽度。', minimum: 320, maximum: 1440 },
|
||||
|
||||
Reference in New Issue
Block a user