diff --git a/AGENTS.md b/AGENTS.md index 09a84908..35c668c8 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,5 +1,7 @@ # Agent Workbench项目执行规范 +1.25.5补验发现并修复混合池和16K小源码正文丢失:共同输入按成员自身context/output配对,累计仍预留最大输出;仅包装超预算时用latest反馈v4保留完整小读取原文,常规v3和旧历史投影不改。原16K/2048/90000两响应回放最终11998/12352保留三源码/目标/六工具事实,分页按1536状态增长预留和真实字节核算,短分页不再当完整小文件优先保留;四关键边界4/4、池原证据2/2通过,不靠放宽预算。相关回归与独立发行仍在进行。用户已在模型中心补好三条Key,仅公开hasKey核对,当前选择legacy-default保持;正式仍1.25.4/PID55352/instance029df044,后续升级保留这个新Provider。首全量中断、两轮修复回归失败和不完整候选都保留;真实推理0,自主交付/网络/重复读取/真实预留/Purge未知保持,不续跑原项目、不委派/推送、不触Key。 + 1.25.5发行首轮被用户退出Codex中断:原36552与源码/打包进程退出(无正式安装命令);首全量299顶层结果/1诊断夹具失败、无终态,不完整候选20261105172742201保留。诊断测试改测新完整历史契约、原断言含义保持,13/13通过;旧16K压缩独立覆盖。由原安装入口恢复正式1.25.4/PID55352/instance029df044,原Provider已无法保持,三临时Key已丢失/hasKey=false,用户仅在模型中心补填。85项目101会话和全部工件保持;一个旧Run checkpoint账本重建及Task/Session保存/+1恢复事件单列核对,严格exact首失败保持。后续升级保留此新PID/Provider/实际凭据状态。三目录5/9/2已获取,DeepSeek声明1048576/393216、其余无容量;声明不是能力验证,采用时须明示累计预算相容。详见QA-PROJECT-GENERATION-REPAIR.md;本轮真实推理0,不续跑原任务,不委派/推送或触Key。 用户项目“引航演示”排查与透传/缓存修复源码已阶段提交:2b178211修合法Messages流起始签名和plan_task工具枚举,72115647贯通模型容量/完整历史/前缀事实与长文件分段,并修复并列否定检查误判。102相关、边界13/14+接口名修正1/1、任务控制10/10、网页/Electron各3组6图及旧预算2组通过;未知容量初始128K/16384不是能力验证,池输出各发成员额度、输入仍共同窗口保守规划。原9真实请求/75666tokens/5截断/0交付完整保留,不续跑原项目,不碰Key。当前准备1.25.5完整源码/独立发行/实际安装/保留原PID36552和Provider升级;正式仍1.25.4,不能把源码修复当已部署。本阶段真实模型0,网络间歇/普遍重复读取/真实预留边界/自主交付/Purge未知保持。见docs/QA-PROJECT-GENERATION-REPAIR.md。 diff --git a/docs/QA-PROJECT-GENERATION-REPAIR.md b/docs/QA-PROJECT-GENERATION-REPAIR.md index 7fc07454..c64a2bf9 100644 --- a/docs/QA-PROJECT-GENERATION-REPAIR.md +++ b/docs/QA-PROJECT-GENERATION-REPAIR.md @@ -22,7 +22,7 @@ 已实现: - 新安装默认按连接容量,未知容量的可编辑初始值128000/16384明确不是已验证能力。上游声明直接带入新连接;已有连接的覆盖值保持,编辑时可明确采用上游容量。去掉本地16000输出/200000上下文的通用clamp;安全整数、真实容量和累计预算仍核对。 -- 模型模式消除全局第二层裁低,自动池按实际成员发送各自输出额度,不再把大模型降到最小成员。池输入仍采用共同窗口及最大输出预留,是保守预算规划;容量不足暂停,不删原文。手动模式保留显式取小策略。旧配置保持manual/compact,旧Run、旧实验和旧用量不迁改。 +- 模型模式消除全局第二层裁低,自动池按实际成员发送各自输出额度,不再把大模型降到最小成员。共同输入按每条连接自己的上下文减去自己的输出核算;累计预算仍预留最大输出,容量不足暂停,不删原文。手动模式保留显式取小策略。旧配置保持manual/compact,旧Run、旧实验和旧用量不迁改。 - `propose_file_chunk`保存所属Task的不可变片段,核对基线SHA、原草稿SHA和偏移,重启后可续接;最后完整组装才走原文件提案/审查流程。半截JSON、重复/乱序、源文件变化、异Task、Unicode损坏、保存失败均不能发布半完成提案。未完成草稿不能完成任务或Git交付;放弃也保留原片段。原512KB文件提案边界保持,不等于token截断。 相关回归102/102通过;新容量/前缀/草稿边界14项首轮13通过,新增池测试误用不存在的upsertPool,改用原pool接口后原断言精确补验1/1通过。其中长文件保存失败与重启5/5,实际HTTP完整30000+字符答复与原响应保持、三协议131072输出字段、池4096/32768各自发送已核对。测试夹具显式保持旧16K/2048/manual/compact,避免把既有有限预算/压缩回归改测成新默认;新安装行为另由modernDefaults独立覆盖。 @@ -56,3 +56,19 @@ Chat/Responses/DeepSeek及Messages的上游缓存用量按实际回执保留原 正式服务由原1.25.4安装入口恢复为PID55352、instance029df044;新Provider不等于原Provider保持。85项目/101会话与全部工件/原磁盘配置保持;启动恢复核对发现一个旧Run的checkpoint按持久工具账本重建,连同其Task/Session保存和1条session.recovered事件,严格全行exact首断言被拒,随后单独核对差异,不回滚恢复。原停止理由token_limit、原工具和模型尝试保持。三条临时Key随退出丢失,hasKey=false;未读取、复制、解密或重存凭据,已请用户仅在模型中心补填。后续发行升级绑定此新基线PID/instance和实际凭据有无,不继续声称保留36552。 退出前另以原凭据内部复用获取三目录:apikey5、Claude9、DeepSeek2,当前型号均在列,未应用目录或发送推理请求。DeepSeek声明context1048576/output393216;另两条不声明容量。该声明不是实测能力;采用声明时单次输出预留393216超过原Run累计200000,必须明确调整可审查额度,不能暗中裁低输出,也不能让默认请求在发送前被自己的预算挡住。真实缓存命中/自主交付仍未在本阶段测试。 + +## 切片四:真实容量声明揭露的混合池与小窗口缺陷 + +用户已在模型中心补好Key;仅公开字段核对三条连接hasKey=true,保留用户改选legacy-default,不读取或重存Key。尚无新真实推理请求。 + +按目录声明复算发现旧池算法将128000窗口与另一成员393216输出相减,导致合法混合池本地拒发。真实本机HTTP先失败后通过:两成员128000/16384与1048576/393216分别按自身窗口核算共同输入,故障切换仍原样发送各自输出;200000累计预算依然拒绝不足额度。此前37/37相关、构建、网页/Electron各3组6图通过;两种桌面宽度原图已目视核对。 + +追加上下文回归12项首轮11通过,原两响应回放第三请求漏掉summary/report原源码。必需反馈v3移除了所有读取正文,重复的工作依据包装又占满16K预算。这是产品缺陷,未用增加预算或改变测试掩盖。新反馈v4保留有界的read_file原文摘录,仅在摘录逐字覆盖完整小片段时省去重复工作依据;大文件、聚合区间和旧视图仍保持原有来源核验。下一页为这些小源码保留独立额度,保留策略v2不再同时计入将被替换的latest反馈。v1–v3历史文档与消息投影不变。 + +首修单独12143/12352通过,但74项相关回归65通过9失败;常驻摘录影响分页/旧工作依据布局。收紧后又发现大页仍未完整入下一请求、旧历史夹具携带新增前缀证明,原两轮日志全部保留。最终只在完整小来源包装确实超预算时使用v4,常规仍用v3;长文件短分页不再占完整小源码的优先保留额度,新增1536tokens状态增长预留参与实际页字节计算,去掉这类新计划的额外2000字符页长限制。原固定窗口、输出与累计预算均未增大,原文件和工具结果不重写。 + +最终原四边界4/4通过:第三请求11998/12352,三个完整源码分别51/93/52字符及六项最新事实在;Chat多语言/CRLF完整新页、长文件分页读完、1.6.1原视图均通过。旧视图夹具仅移除1.6.1当时不存在的prefixAudit,仍验证现代证明拒绝改写正文及历史来源/篡改拒绝。另发现池证据核验旧假设每个输出等于最大额度,新增两个实际HTTP后原证据核验先2/2失败;改成对照Run冻结成员各自额度、同时核对最大预留后2/2通过。 + +实际请求、计划、首失败和本机只读观察在`.qa/capacity-cache-1.25.5/`,未改产品测试预算、期限或原历史。最后相关回归、完整源码和独立发行仍在进行;正式仍1.25.4/PID55352,阶段真实模型0。不得把首修的局部通过写成完整发行成功。 + +阶段收口:最终相关58项55通过3失败,均为原until等待超时(runtime HTTP审批、工作依据重开、历史大页后四模块);相同源码/原断言/原期限精确补验1/1与2/2通过。未放宽期限,首失败保持,唯一超时根因与高负载稳定性未证明。最终构建通过;池证据核验最后修改另有2/2通过。下一从本次干净提交冻结625输入及明确9项相对首轮变更,完整源码先独立运行,避免打包扫描与等待用例争用。所有发行及正式状态结论留给实际结果。 diff --git a/progress.md b/progress.md index de9edad4..56bf0886 100644 --- a/progress.md +++ b/progress.md @@ -1,5 +1,7 @@ # 统一执行进度 +2026-11-06接续:用户已在模型中心补好Key,仅公开核对hasKey,用户当前legacy选择保持。混合池context/output错配、小窗口小源码正文丢失、长文件短分页优先级/新状态增长和池证据核验均先复现后修复;原16K/2048/90000第三请求最终11998/12352保留三模块全部原字节/目标/六工具事实,四边界4/4、池核验2/2通过。首74项65通过9失败及后续首失败保留;最后58项55通过3等待超时,原断言/期限单独1/1+2/2通过,唯一超时根因未知。最终构建与diff核对通过。阶段提交后另冻source-hardened完整源码,再不可变发行/独立重建/归档/安装及保留55352/新Provider升级;正式仍1.25.4,真实推理0,不续跑原项目、不触Key、不委派/推送,历史真实交付/网络/重复读取/预留/Purge未知保持。 + ## 用户项目“引航演示”错误排查 - 用户退出Codex使原正式36552及首完整测试/打包中断,首299顶层结果含1失败、无终态,不完整候选不删除/不使用。诊断旧16K夹具归档后强取tool导致失败,改测新完整历史语义,diagnostics13/13通过。原1.25.4安装入口恢复PID55352,Provider新建/三临时Key丢失,已请用户在模型中心补填;85/101和工件保持,单旧Run checkpoint账本重建/Task/Session保存和1恢复事件精确单列。下一重新冻结完整回归与独立发行,后续原PID指55352,不能再宣称36552保持。 diff --git a/src/client/ModelBudgetSettings.tsx b/src/client/ModelBudgetSettings.tsx index e321afb7..d0b8117c 100644 --- a/src/client/ModelBudgetSettings.tsx +++ b/src/client/ModelBudgetSettings.tsx @@ -14,7 +14,7 @@ export function ModelBudgetSettings({ value, disabled, onSave }: { value: Config

完整传递保留历史原文及顺序;固定规则放在前部,动态状态放在末尾,减少缓存前缀变化。缓存是否命中以上游实际报告为准。

-

{draft.capacityMode === 'model' ? '输出按实际所选连接的额度传递,全局不再额外裁低。上游提供容量时从目录带入;未提供时请在连接中核对。混合池输入按共同窗口、最大输出预留核算,容量不足时暂停。' : '本次手动额度与连接额度取较小值。推理可能占用输出额度;较小输出容易截断代码。'}

+

{draft.capacityMode === 'model' ? '输出按实际所选连接的额度传递,全局不再额外裁低。上游提供容量时从目录带入;未提供时请在连接中核对。混合池按每条连接的上下文与输出额度核算共同输入;累计预算仍保留最大输出预留,额度不足时暂停。' : '本次手动额度与连接额度取较小值。推理可能占用输出额度;较小输出容易截断代码。'}

{fields.filter(([key]) => draft.capacityMode === 'manual' || !['contextLimit', 'maxOutputTokens'].includes(key)).map(([key, label, min, max]) => )}
diff --git a/src/core/context/read-budget.mjs b/src/core/context/read-budget.mjs index 1951281f..ae5d211a 100644 --- a/src/core/context/read-budget.mjs +++ b/src/core/context/read-budget.mjs @@ -46,7 +46,7 @@ export function readMessageBudget(plan, message) { // read. Mixed batches and historical plans retain the original 2560 reserve. // This is page sizing, never dispatch authorization: the complete next wire // request and observed-usage reservation are still checked independently. - const growth = pureReads ? 512 + Math.min(2048, Math.max(0, calls - 1) * 256) : 2560; + const growth = Math.max(plan.readStateGrowthTokens ?? 0, pureReads ? 512 + Math.min(2048, Math.max(0, calls - 1) * 256) : 2560); const tokens = plan.budget.inputBudget - (plan.nextReadFixedInputTokens ?? plan.mandatoryInputTokens) - (plan.workingRetentionTokens ?? 0) - assistantTokens - calls * 8 - growth; return Math.max(1024, Math.floor(tokens * 3 / calls)); } diff --git a/src/core/context/request-plan.mjs b/src/core/context/request-plan.mjs index c2e40d89..1b694b53 100644 --- a/src/core/context/request-plan.mjs +++ b/src/core/context/request-plan.mjs @@ -14,6 +14,9 @@ const hash = value => createHash('sha256').update(typeof value === 'string' ? va const PLACEHOLDER_ID = '00000000-0000-0000-0000-000000000000'; const PLACEHOLDER_SHA = '0'.repeat(64); const ARCHIVE_CHARACTERS = 1_000_000; +const completeSmallSource = candidate => candidate.observation.kind === 'file' && candidate.observation.content.length <= 6000 + && (candidate.observation.offset === undefined || candidate.observation.offset === 0 + && candidate.observation.next_offset === candidate.observation.total_characters); function protocolError(message) { const error = new Error('请求上下文协议需要核对:' + message); @@ -57,12 +60,21 @@ export function budgetFor(config, run, task, transportReservationTokens = 0) { const remaining = (maximum, usage) => maximum > 0 ? Math.max(0, maximum - accountedTokens(usage)) : null; const runRemainingTokens = remaining(run?.budget?.maxTokens, run?.usage); const taskRemainingTokens = remaining(task?.budget?.maxTokens, task?.usage); - let limit = config.contextLimit, reason = 'context_limit'; - if (runRemainingTokens !== null && runRemainingTokens < limit) { limit = runRemainingTokens; reason = 'token_limit'; } - if (taskRemainingTokens !== null && taskRemainingTokens < limit) { limit = taskRemainingTokens; reason = 'task_token_limit'; } if(!Number.isSafeInteger(transportReservationTokens)||transportReservationTokens<0)throw new Error('请求封装预留无效。'); - const inputBudget = limit - outputReservation - safetyTokens - transportReservationTokens; + // A shared prompt must fit every route, but each context window is paired + // with that route's own output. Combining one member's small context with + // another member's large output can reject a pool that actually fits. + const routeInputBudgets = config.capacityMode === 'model' && config.modelRouting?.members?.length + ? config.modelRouting.members.map(member => ({ connectionId: member.id, contextLimit: member.contextLimit, + outputReservation: member.maxOutputTokens, inputBudget: member.contextLimit - member.maxOutputTokens - safetyTokens - transportReservationTokens })) : null; + let inputBudget = routeInputBudgets ? Math.min(...routeInputBudgets.map(route => route.inputBudget)) + : config.contextLimit - outputReservation - safetyTokens - transportReservationTokens; + let reason = 'context_limit'; + const afterOutput = credit => credit - outputReservation - safetyTokens - transportReservationTokens; + if (runRemainingTokens !== null && afterOutput(runRemainingTokens) < inputBudget) { inputBudget = afterOutput(runRemainingTokens); reason = 'token_limit'; } + if (taskRemainingTokens !== null && afterOutput(taskRemainingTokens) < inputBudget) { inputBudget = afterOutput(taskRemainingTokens); reason = 'task_token_limit'; } return { contextLimit: config.contextLimit, outputReservation, safetyTokens, ...(transportReservationTokens?{transportReservationTokens}:{}), inputBudget, targetInputTokens: config.capacityMode === 'model' ? inputBudget : Math.min(16000, inputBudget), + ...(routeInputBudgets ? { routeInputBudgets } : {}), runRemainingTokens, taskRemainingTokens, limitingReason: reason }; } @@ -190,7 +202,8 @@ export class RequestPlanner { if (preserve && before.estimatedInputTokens > budget.inputBudget) throw pause(budget, before, breakdown); const selected = new Set(groups.map(group => group.index)); let omitted = [], reference = null, workingReference = null, latestReference = null; - const latestDocument = latestToolDocument(this.store, session, run, groups, 3); + let latestViewVersion = 3; + let latestDocument = latestToolDocument(this.store, session, run, groups, latestViewVersion); const entries = []; let retainedSources = []; // A read locator already carried in raw history, latest feedback or the @@ -206,17 +219,34 @@ export class RequestPlanner { const metricsFor = (indices, includeNotice = true, currentEntries = entries, includeLatest = true) => { const missing = groups.filter(group => !indices.has(group.index)); const messages = [fixed, ...(missing.length && includeNotice ? [notice({ id: PLACEHOLDER_ID, sha256: PLACEHOLDER_SHA }, missing, descriptions, unsentEvidence(indices, currentEntries, includeLatest))] : []), - ...(includeLatest && latestDocument && !indices.has(latestDocument.group_index) ? [latestToolMessage({ id: PLACEHOLDER_ID, sha256: PLACEHOLDER_SHA }, latestDocument, 3)] : []), + ...(includeLatest && latestDocument && !indices.has(latestDocument.group_index) ? [latestToolMessage({ id: PLACEHOLDER_ID, sha256: PLACEHOLDER_SHA }, latestDocument, latestViewVersion)] : []), ...(currentEntries.length ? [workingMessage({ id: PLACEHOLDER_ID, sha256: PLACEHOLDER_SHA }, workingDocument(session, run, currentEntries, 3), 4)] : []), ...groups.filter(group => indices.has(group.index)).flatMap(group => group.messages), ...tail]; return requestMetrics(completionBody(config, messages, tools)); }; if (!preserve && before.estimatedInputTokens > budget.targetInputTokens) { selected.clear(); if (lastUser) selected.add(lastUser.index); + const observed = workingCandidates(this.store, session, run, groups, 3); + // Keep the established compact layout whenever complete small sources + // fit. Under pressure the latest-result envelope can itself carry small + // original reads, avoiding an extra working envelope for each of them. + const smallSources = observed.filter(completeSmallSource) + .slice(0, 12).map(candidate => workingEntry(candidate, candidate.observation.content.length)); + if (smallSources.length && metricsFor(selected, true, smallSources).estimatedInputTokens > budget.inputBudget) { + const withExcerpts = latestToolDocument(this.store, session, run, groups, 4); + if (withExcerpts?.entries.some(entry => typeof entry.result.content_excerpt === 'string')) { + latestViewVersion = 4; latestDocument = withExcerpts; + } + } const mandatory = metricsFor(selected); if (mandatory.estimatedInputTokens > budget.inputBudget) throw pause(budget, mandatory, breakdown); - const observed = workingCandidates(this.store, session, run, groups, 3); const coveredByRaw = entry => (entry.fragments ?? [entry.source]).every(source => selected.has(source.group_index)); + // A complete small read can travel with its latest result. Do not spend + // another provenance envelope to repeat those same source bytes. Longer + // reads and assembled ranges still need their own working observation. + const coveredByLatest = entry => entry.observation.kind === 'file' && !entry.fragments + && latestDocument?.entries.some(latest => latest.source.call_id === entry.source.call_id + && latest.result.content_excerpt === entry.observation.content); // Admit complete small source observations before optional raw history. // A reservation alone does not keep code in the actual sent request. const newest = groups.at(-1); @@ -227,13 +257,15 @@ export class RequestPlanner { selected.add(newest.index); if (metricsFor(selected).estimatedInputTokens > budget.inputBudget) selected.delete(newest.index); } - for (const candidate of observed.filter(candidate => candidate.observation.kind === 'file' && candidate.observation.content.length <= 6000)) { + for (const candidate of observed.filter(completeSmallSource)) { if (entries.length >= 12) break; if (coveredByRaw(candidate)) continue; const entry = workingEntry(candidate, candidate.observation.content.length); if (metricsFor(selected, true, [...entries, entry]).estimatedInputTokens <= retentionTarget) entries.push(entry); } - retainedSources = [...entries]; + retainedSources = [...entries, ...observed.filter(candidate => coveredByLatest(candidate) + && !entries.some(entry => entry.source.call_id === candidate.source.call_id)) + .map(candidate => workingEntry(candidate, candidate.observation.content.length))]; const newestUseful = newest?.messages.every(message => { if (message.role !== 'tool') return true; try { const result = JSON.parse(message.content); return !result.kind?.startsWith('context-') && result.kind !== 'tool-result'; } catch { return true; } @@ -253,12 +285,12 @@ export class RequestPlanner { }; // A small result in a mixed large group must remain usable. It is a // separate, provenance-checked observation, never a broken tool pair. - const candidates = observed.filter(candidate => !coveredByRaw(candidate) + const candidates = observed.filter(candidate => !coveredByRaw(candidate) && !coveredByLatest(candidate) && !entries.some(entry => entry.source.call_id === candidate.source.call_id)); for (const [index, candidate] of candidates.entries()) { if (entries.length >= 12) break; const remaining = target - metricsFor(selected).estimatedInputTokens; - const smallFile = candidate.observation.kind === 'file' && candidate.observation.content.length <= 6000; + const smallFile = completeSmallSource(candidate); const share = Math.max(128, Math.floor(remaining / Math.max(1, candidates.length - index))); const maximum = Math.min(candidate.observation.content.length, 12000, smallFile ? candidate.observation.content.length : share * 2); let low = 0, high = maximum; @@ -291,7 +323,7 @@ export class RequestPlanner { if (entries.length) workingReference = this.artifact(session, run, workingDocument(session, run, entries, 3), 'context-working-set'); if (latestDocument && !selected.has(latestDocument.group_index)) latestReference = this.artifact(session, run, latestDocument, 'context-latest-tools'); const messages = [fixed, ...(reference ? [notice(reference, omitted, descriptions, unsentEvidence(selected, entries, true))] : []), - ...(latestReference ? [latestToolMessage(latestReference, latestDocument, 3)] : []), + ...(latestReference ? [latestToolMessage(latestReference, latestDocument, latestViewVersion)] : []), ...(workingReference ? [workingMessage(workingReference, workingDocument(session, run, entries, 3), 4)] : []), ...structuredClone(groups.filter(group => selected.has(group.index)).flatMap(group => group.messages)), ...tail]; let mcpReference = null, mcpDocument = null; @@ -366,16 +398,20 @@ export class RequestPlanner { // The next result replaces the current latest-result feedback. Do not // reserve both views when sizing that result's actual protocol page. nextReadFixedInputTokens: metricsFor(new Set(lastUser ? [lastUser.index] : []), true, [], false).estimatedInputTokens, - workingRetentionTokens: Math.max(0, metricsFor(new Set(lastUser ? [lastUser.index] : []), true, retainedSources).estimatedInputTokens - - metricsFor(new Set(lastUser ? [lastUser.index] : []), true, []).estimatedInputTokens), - workingRetentionPolicyVersion: 1, + workingRetentionTokens: Math.max(0, metricsFor(new Set(lastUser ? [lastUser.index] : []), true, retainedSources, latestViewVersion === 3).estimatedInputTokens + - metricsFor(new Set(lastUser ? [lastUser.index] : []), true, [], latestViewVersion === 3).estimatedInputTokens), + workingRetentionPolicyVersion: latestViewVersion === 4 ? 2 : 1, readBudgetPolicyVersion: 3, + // Routing, read coverage and recent-tool state grow after a reply. Page + // sizing reserves that observed framing growth before returning bytes; + // the next complete request is still checked against its original limit. + readStateGrowthTokens: 1536, originalMessages: session.providerMessages.length, retainedMessages: messages.length - 1 - tail.length - (reference ? 1 : 0) - (workingReference ? 1 : 0) - (latestReference ? 1 : 0) - (memoryReference ? 1 : 0) - (skillReference ? 1 : 0) - (mcpReference ? 1 : 0), archivedGroups: omitted.length, retainedGroups: groups.filter(group => selected.has(group.index)).map(group => group.index), historyIndexArtifactId: reference?.id ?? null, historyIndexSha256: reference?.sha256 ?? null, actualUsage: null, workingSetArtifactId: workingReference?.id ?? null, workingSetSha256: workingReference?.sha256 ?? null, workingSetEntries: entries.length, workingSetViewVersion: 4, - latestToolsViewVersion: 3, + latestToolsViewVersion: latestViewVersion, latestToolsArtifactId: latestReference?.id ?? null, latestToolsSha256: latestReference?.sha256 ?? null, latestToolsEntries: latestReference ? latestDocument.entries.length : 0, projectMemoryArtifactId: memoryReference?.id ?? null, projectMemorySha256: memoryReference?.sha256 ?? null, projectMemoryEntries: memoryReference ? memoryDocument.entries.length : 0, @@ -409,10 +445,15 @@ export function verifyPlanEvidence(store, session, plan, cache = new Map()) { }; const request = get(plan.requestArtifactId, 'model-request', plan.requestSha256); const body = JSON.parse(store.artifactStore.read(request)), metrics = requestMetrics(body); + const runModel = store.owned('run', plan.runId, session.id).model; if(plan.tokenReservation)verifyModelReservation(store,session,plan.taskId,{...store.owned('run',plan.runId,session.id).model, modelRouting:store.owned('run',plan.runId,session.id).model.routing},body,plan.tokenReservation); + const invalidOutput = body.kind === 'model-route-plan' && runModel.capacityMode === 'model' + ? body.variants.some(variant => outputReservation(variant.body) !== runModel.routing?.members.find(member => member.id === variant.connectionId)?.maxOutputTokens) + || Math.max(...requestVariants(body).map(outputReservation)) !== plan.budget.outputReservation + : requestVariants(body).some(value => outputReservation(value) !== plan.budget.outputReservation); if (metrics.bytes !== plan.requestBytes || metrics.estimatedInputTokens !== plan.estimatedInputTokens - || requestVariants(body).some(value => outputReservation(value) !== plan.budget.outputReservation) || metrics.estimatedInputTokens > plan.budget.inputBudget) throw new Error('请求预算与原正文不匹配。'); + || invalidOutput || metrics.estimatedInputTokens > plan.budget.inputBudget) throw new Error('请求预算与原正文不匹配。'); historyGroups(requestHistory(body)); for (const variant of requestVariants(body)) historyGroups(requestHistory(variant)); const frozen = JSON.parse(store.artifactStore.read(get(plan.artifactId, 'context-plan'))); @@ -465,6 +506,7 @@ export function verifyPlanEvidence(store, session, plan, cache = new Map()) { if ((frozen.nextReadFixedInputTokens ?? null) !== (plan.nextReadFixedInputTokens ?? null)) throw new Error('下一工具页的固定预算与封存记录不匹配。'); if ((frozen.readBudgetPolicyVersion ?? 1) !== (plan.readBudgetPolicyVersion ?? 1) || (frozen.latestToolsViewVersion ?? 1) !== (plan.latestToolsViewVersion ?? 1)) throw new Error('读取或最新反馈视图版本与封存记录不匹配。'); + if ((frozen.readStateGrowthTokens ?? null) !== (plan.readStateGrowthTokens ?? null)) throw new Error('读取状态增长预留与封存记录不匹配。'); if ((frozen.latestToolsArtifactId ?? null) !== (plan.latestToolsArtifactId ?? null) || (frozen.latestToolsSha256 ?? null) !== (plan.latestToolsSha256 ?? null) || (frozen.latestToolsEntries ?? 0) !== (plan.latestToolsEntries ?? 0)) throw new Error('最新工具反馈与发送前的封存记录不匹配。'); diff --git a/src/core/context/tool-feedback.mjs b/src/core/context/tool-feedback.mjs index bfcd6d3b..678e215c 100644 --- a/src/core/context/tool-feedback.mjs +++ b/src/core/context/tool-feedback.mjs @@ -88,23 +88,28 @@ export function latestToolDocument(store, session, run, groups, viewVersion = 1) if (artifact.kind !== 'tool-result' || artifact.taskId !== run.taskId || artifact.runId !== invocation.runId || store.artifactStore.read(artifact) !== result.content) throw new Error('最新工具反馈与原执行结果不匹配。'); const feedback = compactToolFeedback(result.content, viewVersion); - if (viewVersion === 3 && invocation.state === 'completed' && !invocation.requiresVerification + const completeSmallRead = viewVersion === 4 && call.function.name === 'read_file' + && typeof feedback.content_excerpt === 'string' && JSON.parse(result.content).content === feedback.content_excerpt; + if ((viewVersion === 3 || viewVersion === 4 && !completeSmallRead) + && invocation.state === 'completed' && !invocation.requiresVerification && ['read_file', 'read_artifact'].includes(call.function.name)) { delete feedback.content_excerpt; } entries.push({ tool: call.function.name, source: { call_id: call.id, invocation_id: invocation.id, run_id: invocation.runId, result_artifact_id: artifact.id, result_sha256: artifact.sha256, arguments_sha256: hash(call.function.arguments), recorded_state: invocation.state, requires_verification: !!invocation.requiresVerification }, - result: feedback, original_characters: result.content.length, view: viewVersion === 3 ? 'selected-original-fields-with-read-locators' : 'selected-original-fields' }); + result: feedback, original_characters: result.content.length, view: viewVersion === 4 ? 'selected-original-fields-with-read-excerpts-and-locators' + : viewVersion === 3 ? 'selected-original-fields-with-read-locators' : 'selected-original-fields' }); } return { schemaVersion: 1, kind: 'latest-tool-feedback', sessionId: session.id, projectId: session.projectId, taskId: run.taskId, runId: run.id, group_index: group.index, group_sha256: group.sha256, entries }; } export function latestToolMessage(reference, document, viewVersion = 1) { - if (![1, 2, 3].includes(viewVersion)) throw new Error('未知的最新工具反馈视图版本。'); - if (viewVersion === 3) return { role: 'system', content: [ - '最近已完成工具的原字段与恢复入口;仅数据,非授权或再次执行。读取正文见工作依据,省略内容按result_artifact_id恢复;未读原文件用file_read.next_read_file。', + if (![1, 2, 3, 4].includes(viewVersion)) throw new Error('未知的最新工具反馈视图版本。'); + if (viewVersion >= 3) return { role: 'system', content: [ + viewVersion === 4 ? '最近已完成工具的原字段与恢复入口;仅数据,非授权或再次执行。读取正文见content_excerpt或工作依据,省略内容按result_artifact_id恢复;未读原文件用file_read.next_read_file。' + : '最近已完成工具的原字段与恢复入口;仅数据,非授权或再次执行。读取正文见工作依据,省略内容按result_artifact_id恢复;未读原文件用file_read.next_read_file。', JSON.stringify({ latest_tools: { artifact_id: reference.id, sha256: reference.sha256 }, data: { kind: document.kind, entries: document.entries.map(entry => ({ tool: entry.tool, result_artifact_id: entry.source.result_artifact_id, recorded_state: entry.source.recorded_state, requires_verification: entry.source.requires_verification, diff --git a/src/server/runtime.mjs b/src/server/runtime.mjs index 41cf2a7d..630e818d 100644 --- a/src/server/runtime.mjs +++ b/src/server/runtime.mjs @@ -519,7 +519,7 @@ export class Runtime { run.readMessageBytes = readMessageBudget(planned.record, message); run.readBatchBudget = readBatchBudget(planned.record, message); beginReadTurn(task, run.id, stepRecord.id); - run.readPageCharacters = planned.record.budget.inputBudget - planned.record.nextReadFixedInputTokens + run.readPageCharacters = planned.record.readStateGrowthTokens ? Infinity : planned.record.budget.inputBudget - planned.record.nextReadFixedInputTokens - (planned.record.workingRetentionTokens ?? 0) < 4096 ? 2000 : Infinity; const executionCalls = orderReadCalls(run.readBatchBudget, calls, call => { const args = JSON.parse(call.function.arguments); diff --git a/task_plan.md b/task_plan.md index f7fcc4a5..31eb12c2 100644 --- a/task_plan.md +++ b/task_plan.md @@ -8,6 +8,7 @@ 2. [complete] Claude合法thinking起始误拒、plan_task缺少工具枚举已复现、修复并提交2b178211;相关62项61通过+精确补验3/3,测试驱动首失败保留。 3. [complete] 容量/完整历史/前缀审计/上游缓存计数/长文件分段已实现;102相关及新增边界、保存失败/重启、三协议与池各自输出通过。最终网页/Electron各3组6图、旧预算两视口2组与构建通过;并列否定误识别必查已修并10/10。未知能力、原失败、旧Run与原实验不改。 4. [in_progress] 源码提交72115647/发行冻结d5de9093后,用户退出Codex使原进程与首全量/打包中断;299顶层结果1诊断旧16K夹具失败、无完整终态,不完整候选保持。诊断改测新完整历史契约13/13通过;新正式基线1.25.4/PID55352/instance029df044,临时Key丢失如实提示。重冻后完整回归、独立构建/归档/安装,再保留新Provider升级;单列恢复checkpoint差异与采用容量配置,不推送,真实自主交付/网络/重复读取/真实预留/Purge未知保持。 +5. [in_progress] 用户已补好三条Key,公开核对hasKey与当前legacy选择保持。混合池跨成员错扣输出、小窗口小源码丢失、长页状态增长/短分页优先级及池证据核验已修复;原预算下第三请求11998/12352保留三源码及六工具事实,四边界4/4及池核验2/2通过,旧投影保持。首74项65通过9失败及收紧后失败保留。完成相关回归及阶段提交后另冻source-hardened,不覆盖两个中断候选;之后完整源码、发行、保留新Provider升级和显式容量采纳。 ## 当前:AB 已验证低强度模式的新工程验证 diff --git a/tests/model-capacity.test.mjs b/tests/model-capacity.test.mjs index 68174eea..85249ed6 100644 --- a/tests/model-capacity.test.mjs +++ b/tests/model-capacity.test.mjs @@ -7,7 +7,7 @@ import { DEFAULT_CONFIG, cleanConfig } from '../src/core/storage/legacy-import.m import { validateRuntimeBudgets } from '../src/core/models/runtime-settings.mjs'; import { capacitySettings } from '../src/shared/contracts/model-capacity.mjs'; import { completionBody } from '../src/shared/contracts/model-request.mjs'; -import { budgetFor } from '../src/core/context/request-plan.mjs'; +import { budgetFor, verifyPlanEvidence } from '../src/core/context/request-plan.mjs'; test('fresh capacity defaults are independent from legacy frozen budgets; valid large capacities are not clamped', () => { assert.equal(DEFAULT_CONFIG.capacityMode, 'model'); @@ -79,4 +79,32 @@ test('automatic routing sends each member own output capacity rather than the sm for (const request of server.requests) assert.equal(request.input.max_tokens, members.find(member => member.model === request.input.model).maxOutputTokens); assert.equal(new Set(server.requests.map(row => row.input.max_tokens)).size, 2); assert.equal([...f.store.core.context_plan.values()][0].budget.outputReservation, 32768); + for (const plan of f.store.core.context_plan.values()) verifyPlanEvidence(f.store, f.session, plan); +}); + +test('mixed windows reserve each route own output without subtracting a different member output from the smallest context', async t => { + const f = fixture(t, { modernDefaults: true }); let count = 0; + const server = await compatibleFixture(t, () => ++count === 1 + ? { status: 503, body: { error: { message: 'Owned mixed-window failover' }, usage: { prompt_tokens: 20, completion_tokens: 0, total_tokens: 20 } } } + : completion([], 'Complete mixed-window answer.')); + const provider = new Provider(), hub = provider.modelHub(f.store); + const members = [[128000, 16384], [1048576, 393216]].map(([contextLimit, maxOutputTokens], index) => hub.upsert({ + name: 'Owned mixed window ' + index, model: 'mixed-' + index, baseUrl: server.baseUrl, requiresKey: false, contextLimit, maxOutputTokens, + })); + const pool = hub.pool({ name: 'Owned mixed windows', members: members.map(member => ({ connectionId: member.id })), sticky: false, maxAttempts: 2 }); + hub.select({ type: 'pool', id: pool.id }); + f.store.config.maxRunTokens = 2000000; f.store.config.maxTaskTokens = 10000000; + const runtime = new Runtime(f.store, provider); f.onCleanup(() => runtime.stopAll()); + runtime.start(f.session.id, 'Answer only; do not modify files or run checks.'); + await until(() => !runtime.isActive(f.session.id), 15000); + assert.equal(f.session.status, 'completed', JSON.stringify(f.session.failure)); + assert.equal(server.requests.length, 2); + for (const request of server.requests) assert.equal(request.input.max_tokens, members.find(member => member.model === request.input.model).maxOutputTokens); + const budget = [...f.store.core.context_plan.values()][0].budget; + assert.equal(budget.inputBudget, 128000 - 16384 - budget.safetyTokens); + assert.equal(budget.outputReservation, 393216); + const prepared = hub.prepare(f.store.config); + const smallCumulative = budgetFor(prepared, { budget: { maxTokens: 200000 } }); + assert.ok(smallCumulative.inputBudget < 0); assert.equal(smallCumulative.limitingReason, 'token_limit'); + for (const plan of f.store.core.context_plan.values()) verifyPlanEvidence(f.store, f.session, plan); }); diff --git a/tests/working-set.test.mjs b/tests/working-set.test.mjs index 45994a05..d25779e0 100644 --- a/tests/working-set.test.mjs +++ b/tests/working-set.test.mjs @@ -341,6 +341,9 @@ test('a 1.6.1 full-provenance sent view remains verifiable after introducing the // the sent view must fail; genuine 1.6.1 records predate these fields. assert.throws(() => verifyPlanEvidence(f.store, f.session, record), /模型预算预留与原估算\/用量\/实际线路不一致/); delete record.tokenReservation; delete record.maxBudgetAttempts; + // Prefix auditing was introduced long after 1.6.1 and binds the modern wire + // bytes too. A genuine historical record cannot contain this modern proof. + delete record.prefixAudit; delete record.workingSetViewVersion; delete record.workingRetentionTokens; const frozen = f.planner.artifact(f.session, f.run, record, 'context-plan'); record.artifactId = frozen.id; assert.notEqual(oldMessage.content, currentMessage.content); assert.ok(oldMessage.content.includes('invocation_id'));