Repository navigation
fix(context): locate failed selectors in batched reads - #7742
Conversation
Signed-off-by: huangruiteng <huangrt01@163.com>
songoow
left a comment
There was a problem hiding this comment.
Reviewer: model_agent | GPT-6 Astra Pro | OpenAI | self_reported
动机 / Motivation
受影响的是使用 quota context-read 一次读取多个捕获字段的 Agent 和排障人员。
同一批次第三个路径不存在时,旧版本只说路径不存在;调用者需要逐项重试才能定位,当前版本直接指出原始第几个参数和失败的路径分段。
实测有效批次的内容和摘要保持一致,失败批次不给部分内容,新增位置说明不回显路径或任务值。
本次边界是错误定位与原捕获内的恢复说明,不新增准入、扣额、模型保留证明或上下文读取义务。
改动思路 / Approach
位置映射留在原有纯 TypeScript selector,文件适配器继续拥有原始 JSON 值与字节序列化;无需新增状态、重试 owner 或兼容分支。 当前 PR 仅交付批量选择定位和原捕获内的恢复说明,所有准入与结算 owner 保持。
实现先保存调用者原始参数序号,再沿用排序和去重,因此错误中的第三个参数始终指向用户输入的第三项。与逐个重试相比,这直接减少定位步骤;与回显失败路径相比,只写位置避免暴露任务键和值。已有选择器足以承担该责任,无须另建批量读取协议。
具体改动 / Changes
完整审阅4个文件,+48/-4:选择器、Python/TypeScript回归与恢复文档。规格依据为改动前的 docs/reference/required-work-context.md,固定修订 0ad08b1;本次映射标签 batch-rejection 和 original-capture-recovery 均实现,分别对应全批次拒绝和同一捕获的只读恢复。
关键代码讲解
- capturedContextSelection 将 Set 改为保存首次原始序号的 Map,再从 key 排序。缺失路径、非法数组索引报告当前分段;语法非法仅报告参数序号。错误只拼入整数,没有插入路径或原值。
- read_context_capture 是未改动但实际验证的消费者:先核对完整捕获摘要,再调用 TypeScript 验证地址,最后从 Python 原始 JSON 取值。这个顺序保持大整数精度,任一选择失败都不会输出部分内容。
独立执行结果:52 个 Python 案例通过;Node runner 报告的1个文件级测试通过;control-plane TypeScript typecheck、改动 Python Ruff 和 whitespace 检查通过。另用同一脚本在不可变 base/head 各跑六组实际 CLI:成功内容与 selection SHA 完全一致,包含转义键、null、UTF8 与 9007199254740993。第三参数缺失、非法数组索引和 scalar 遍历分别得到 arg3/token3、arg3/token2、arg3/token4;语法错误得到 arg2。基线没有这些定位,说明反例能识别本次改动。
对主干的风险 / Risks
最容易出错的是排序后把位置当成输入序号,或用诊断回显私有地址。Map 在排序前固定首次原始位置,重复输入仍使用首次序号;实跑错误全文只有位置,合法内容和摘要保持一致。所有失败均 exit1、无部分内容;坏摘要仍返回原有“恢复原件,不重做准入”的指导。捕获字节未改,也没有创建 registry 或 runtime 状态。
语义与 CI 对齐
这是有意的诊断增强,复用现有错误和选择合同,没有新权限、状态枚举或模型读取义务。恢复文档的父级导航是建议,原准入和结算仍不重做。当前远端快照29项成功、5项跳过、6项等待,没有失败;未等待或轮询,也未把未完成检查当成通过。没有运行完整安装、真实模型或整仓资格,这些不是本次局部改动的实测结论。
我的整体评价 / Verdict
APPROVE,审查固定在 7cf2ec0。改动在现有 owner 中解决已复现的定位问题,成功读取、隐私和后续恢复边界保持,生产代码体量相称。真实模型是否因此减少重试尚未测量,不能把更清楚的诊断直接换算成长程收益。
本次检查的 context_selection.ts 与 quota_capture.py 的实际 CLI 消费路径 不改变已渲染的产品页面;无需用截图证明内部行为。 未进行产品页面视觉检查,因为本次没有页面改动。
English verdict: APPROVE — 7cf2ec0; original argument/token locations are correct on real base/head CLI comparisons, successful selected bytes and digests are unchanged, and failures remain atomic and private. Remote merge readiness remains separate.
Batched
quota context-read --selectfailures previously reported only that a pointer was missing or invalid. With several requested fields, callers could not identify which argument to repair and had to rediscover or retry individual reads.The existing TypeScript selector now reports the original 1-based
--selectargument and failed token position. Sorting and deduplication preserve that original position. Diagnostics do not echo pointer strings or task values; rejected batches still return no partial content, and successful selection, pagination, capture digests and retention semantics are unchanged. The existing bilingual reader guide explains recovery from the resolved prefix of the same capture. No new setting, state owner or admission path is added.Validation: a new TypeScript counterexample fails on the immutable base and passes after the fix; all 6 selector cases and 52 Python capture/read/registry-isolation cases pass, including actual CLI errors, duplicate inputs, escaped values and unchanged source bytes. TypeScript checking, changed Python Ruff and whitespace checks pass. Standard premerge passed with no failed checks or manual holds; public-boundary checks are included. This is a diagnostic/recovery improvement, not a measured task-effectiveness or end-to-end latency claim. No UI changes.