Run the dsh-archive-agent-notes audit over every active Agent Note on current master, judging each record by whether its rationale still guides work rather than by size or age. - Archive 453 implemented bilingual triplets (417,882 English words): completed UI chrome, narrow adapters, closed bug fixes, implementation walkthroughs whose package READMEs, docs pages, generators, or successor notes now carry the useful behavior, and 51 records fully superseded by a later active note. Keep 201 implemented notes whose ownership rules, negative guarantees, durable or wire semantics, security rules, reintroduction conditions, or still-tempting rejected alternatives remain useful. - Reject 7 proposals whose premise is gone or whose work shipped in amended form under other records; delete 2 rejected notes that no longer prevent a plausible mistake. - Retarget every remaining inbound link to the archived path, and repair active prose that named an archived record as the owner of a live fact: parenthetical citations drop, ownership sentences redirect to the README, docs page, or active note that states the fact, and history citations say so. Chinese files link the English archived path because the pairing gate treats the frozen tree as outside the bilingual corpus. - Seal 1,359 new frozen artifacts; existing seals are unchanged and outbound links from archived notes are neither inspected nor repaired. - Regenerate docs/config-catalog.md after the hook-bridge comment edits shifted two source line numbers.
2.4 KiB
2.4 KiB
Agent Note: 模型边界处的运行时参数校验
Status: implemented Archived: 2026-09-04
English | 中文
问题
defineTool(统一 schema DSL)为工具作者的 execute(args) 提供了经 InferArgs<S> 映射的类型化参数。但该类型只是对运行时值的编译期声明,而这个值实际上是模型生成的 JSON:没有任何机制强制模型遵守 schema,因此畸形调用(缺少必需键、声明为数字的位置传入字符串,或字面量超出声明的集合)会以「仅在名义上类型化」的状态到达 execute。工具函数体随后要么在处理结构错误的数据时崩溃,要么在不报错的情况下行为异常。
决策
validateArgs(spec, args): string[] 编译 ParameterSchemaSpec,并委托共享的 validateJsonSchemaValue() 遍历器,对格式正确的声明返回可读的违规列表。defineTool 在定义时对编译后的参数 schema 创建快照,并在调用类型化函数体之前执行校验;存在违规时会抛出 ToolArgsError(INVALID_ARGS),注册表将其作为模型可据以修正的错误结果返回。
校验器与编译器因此共享完全一致的语义:隐式参数根是开放对象;必需键仅来自 required: true;默认值仍是注解;显式嵌套对象遵循其声明的开放性;数组通过 items 递归校验;标量字面量约束保证类型正确;oneOf 仅在恰好一个分支匹配时才接受。直接注册的工具自行负责输入校验。