* fix(agent-instructions): budget the user-global and project chains separately The user-global and project instruction files shared one maxBytes and the user-global files were the broadest, so a large project chain omitted them first. Each chain now renders under maxBytes on its own and the results share one system-reminder frame: unchanged output when everything fits or one chain is empty, at most twice maxBytes otherwise. The project chain keeps its omit-broadest-first, truncate-last rule; reconciliation batches follow the same split; the maxBytes key and the baseline identity are unchanged. Tests cover the fast paths, both chains fitting only separately, each chain over its own budget, the 2 × maxBytes boundary at exact and tiny limits, multibyte content, reconciliation batches, and a resumed single-budget baseline receiving the user-global file as one transition. The agent-instructions-budget snapshot is refreshed and agent-instructions-budget-chains is added. README, Config.maxBytes JSDoc, the configuration catalog, a new Agent Note, and an upgrade guide state the per-chain bound. * fix(agent-instructions): keep loaded order in merged frames and note the unshared chain budget A merged frame now lists sections, omissions and truncations in the loaded order, so a reconciliation batch renders its items in one order whether or not it fits a single budget. The guard comment states only the invariant and points to the Agent Note; the intro selection states its rule. The README names the unshared budget between chains. --------- Co-authored-by: ZiyaZhang <[email protected]>
3.3 KiB
Agent Note: 用户全局指令链与项目指令链分别使用字节预算
Status: implemented
English | 中文
问题
dsh-agent-instructions 曾把用户全局文件与项目文件作为一条指令链,在一个 maxBytes 内渲染,这是最初的工作区上下文决策定下的规则。渲染会最先省略最宽泛的文件,而用户全局文件最宽泛,因此较大的项目指令链会移除它们:在默认的 65,536 字节预算下,20 KiB 的用户全局文件、30 KiB 的项目根文件与 20 KiB 的嵌套文件一起渲染时,用户全局文件被省略。
决策
渲染器把已加载的文件分成用户全局指令链与项目指令链,各自保持原有顺序,并分别在同一个 maxBytes 内渲染:先省略最宽泛的文件,再截断最后一个文件,然后依次退回到精简引言、带空标题的通知和仅含通知的文本。项目指令链的结果与它单独渲染时相同;用户全局文件只有超出自身预算时才会被省略或截断,下文的回退情形除外。
所有文件合起来能放进 maxBytes,或只有一条链有文件时,输出逐字节不变。其他情况下,一个至多为 maxBytes 两倍的 <system-reminder> 框架包含合并后的通知(仅当有文件被省略或截断时)、一段引言(仅当某条链保留了框架时),以及按加载顺序排列的渲染段落,因此基线中用户全局文件在前。若某条链在没有框架的情况下渲染,且合并后的框架会超过该上限,则所有文件作为一条链在一个 maxBytes 内渲染,这可能省略一个本可放进自身预算的用户全局文件;这只会在预算只有几百字节,或通知接近或超过 maxBytes 时发生。对账批次采用同样的拆分。
maxBytes 配置键与基线标识都不变,因此恢复的会话保留其可见基线;该基线曾省略的用户全局文件会以一次附加指令变更的形式加入。
备选方案
一个预算,并优先保留用户全局文件。 较大的用户全局文件会截断或省略项目根文件,而且临界值附近的字节差异就决定哪条链丢失内容。
一个预算,并为用户全局文件划出份额。 项目指令链仍会缩小,而且没有测量数据支撑份额的大小。
为第二条链增加配置字段。 没有部署需要为两条链设定不同大小,而且该字段会进入基线标识,使恢复的会话重新发送基线。
采用 Codex 的布局:不设上限的用户全局文件,加上从根目录开始保留的项目指令链。 输出没有上限,项目指令链会保留最宽泛的文件,而不是最具体的文件。
影响
- 同时包含两条链的基线或批次最多可达
maxBytes的两倍;把maxBytes当作总预算设定的部署应将其减半,见升级指南。 - 用户全局指令不会因项目指令链较大而被移除。
agent-instructions-budgetsnapshot 显示被截断的用户全局文件与完整的项目文件;agent-instructions-budget-chains显示两条只能各自放下的链。- 包 README、
Config.maxBytes的 JSDoc 与配置目录说明了按链计算的上限。