diff --git a/.agents/notes/implemented/architecture/2026-11-03-hoc-slot-kind.i18n.yaml b/.agents/notes/implemented/architecture/2026-11-03-hoc-slot-kind.i18n.yaml
index 4834371d87..585a30591e 100644
--- a/.agents/notes/implemented/architecture/2026-11-03-hoc-slot-kind.i18n.yaml
+++ b/.agents/notes/implemented/architecture/2026-11-03-hoc-slot-kind.i18n.yaml
@@ -12,8 +12,8 @@
en: d23bc3c8c3b20ac9
zh: 874c7a4dda283e89
/agent-note-add-the-hoc-slot-kind-so-plugins-can-wrap-owner-content-in-layers/decision/implementation:
- en: 02ec3c2bfad692af
- zh: 229a3ae12eac49a6
+ en: 14492f95b195917b
+ zh: e9ee4c438dccd225
/agent-note-add-the-hoc-slot-kind-so-plugins-can-wrap-owner-content-in-layers/decision/first-consumer:
en: 1afdf4ceeef7a3b3
zh: be01cf39850db0ca
@@ -21,5 +21,5 @@
en: b4824619c502b422
zh: 610364f2dc8cb2b7
/agent-note-add-the-hoc-slot-kind-so-plugins-can-wrap-owner-content-in-layers/consequences:
- en: 6d350e8f9df1d33a
- zh: 5411b39fc4cc14ce
+ en: 7576007507f393dc
+ zh: d964cc1419bb6917
diff --git a/.agents/notes/implemented/architecture/2026-11-03-hoc-slot-kind.md b/.agents/notes/implemented/architecture/2026-11-03-hoc-slot-kind.md
index a79d28ceda..4fa4900d7a 100644
--- a/.agents/notes/implemented/architecture/2026-11-03-hoc-slot-kind.md
+++ b/.agents/notes/implemented/architecture/2026-11-03-hoc-slot-kind.md
@@ -42,7 +42,7 @@ Add a fifth kind: `hoc`.
| Package | Realization |
|---|---|
| `ui-slots` | `SlotKind` includes `'hoc'`; `HocRenderOpts` (optional `children` and `entryKey`), `HocKeysOf`, `HocShare`; `RenderSlotFn` has a hoc-key overload taking optional `{ children, entryKey }`; `KindOptions` has a hoc branch with optional `key`; `SlotCore.register` / `entriesOfSlot` key hoc cells by `(key or wildcard, id)` |
-| `ui-renderer` | `HocOutlet` takes its render function from `hocChainFor`, a cache per host, live declaration, and dispatch key that every outlet dispatching the same key shares. Once per ledger version it reselects the key's layers with `hocLayersFor` (wildcard winners plus exact-key winners, an exact-key layer replacing the wildcard layer with its id, sorted by `order`) and calls `composeHocLayers` to nest them into one render function only when that ordered list changes by entry identity. Each layer is one Component that fixes its scope-specific Entry (`StrictSessionEntry` / `SessionMaybeEntry` / `RootEntry`), entry, slot inject, and crash reporting at composition, and receives only `owner` and the next inner layer when rendering. With no layer the outlet returns the owner content directly. `HocContentBoundary` wraps each layer's inner content and rethrows its errors as `HocContentError`, which layer boundaries pass through and `HocOutletBoundary` unwraps to the original error. The Entry chain passes `children` to the registered Component as JSX children; non-hoc entries receive `undefined`. `SlotErrorBoundary` takes a `crashed` replacement node, which a layer's boundary keeps rendering for the rest of its mount; layer crash reports pass `abdicate: false` |
+| `ui-renderer` | `HocOutlet` takes its render function from `hocChainFor`, which caches one chain per host, spec object, slot name, and `entryKey` across outlet instances. Once per ledger version it reselects the key's layers with `hocLayersFor` (wildcard winners plus exact-key winners, an exact-key layer replacing the wildcard layer with its id, sorted by `order`) and calls `composeHocLayers` to nest them into one render function only when that ordered list changes by entry identity. Each layer is one Component that fixes its scope-specific Entry (`StrictSessionEntry` / `SessionMaybeEntry` / `RootEntry`), entry, slot inject, and crash reporting at composition, and receives only `owner` and the next inner layer when rendering. With no layer the outlet returns the owner content directly. `HocContentBoundary` wraps each layer's inner content and rethrows its errors as `HocContentError`, which layer boundaries pass through and `HocOutletBoundary` unwraps to the original error. The Entry chain passes `children` to the registered Component as JSX children; non-hoc entries receive `undefined`. `SlotErrorBoundary` takes a `crashed` replacement node, which a layer's boundary keeps rendering for the rest of its mount; layer crash reports pass `abdicate: false` |
| `scripts/gen-client-catalog.ts` | Register options, a `children`-rendering example, and the `wraps-owner-content` replace risk for hoc slots |
### First consumer
@@ -66,9 +66,9 @@ Add a fifth kind: `hoc`.
- Adding or removing a layer remounts everything inside it, including the composer on the home.
- Every non-hoc registered Component receives `children: undefined`, which overrides any owner prop of that name.
- Each layer adds one Component and two error boundaries to the tree; each hoc slot with layers adds one outlet boundary.
-- The outlet's `[data-slot]` element sits between the owner and its content, so owner selectors cannot assume the content is a direct child.
+- The renderer marks the slot and [where each layer renders `children`](../../../../docs/subsystems/slots.md#hoc-layers), not the layer's own markup. Plugins need no wrapper of their own, but structural selectors must account for those DOM elements.
- React 18 recollects the component stack where an error is rethrown, so a content error reaching boundaries above a hoc slot with layers carries a component stack that starts at `HocOutletBoundary`.
- A layer that wraps its `children` in its own error boundary catches the internal `HocContentError` rather than the original content error.
- The frame contract holds only on the home: other phases leave the Conversation root out of the stacking order, so unportaled Conversation popovers still rise above AppFrame chrome that floats over the column, while on the home they stack only within the root.
-- `HocOutlet` keeps its layer Components in a compile cache shared per host, live declaration, and dispatch key, not in outlet-instance state, so they do not depend on React retaining memoized values; these Components are the remount boundary of the content inside them, and a redeclared slot starts with an empty cache.
+- `HocOutlet` keeps its layer Components in a shared compile cache, not in outlet-instance state, so they do not depend on React retaining memoized values; these Components are the remount boundary of the content inside them. Different slot names use separate chains even when they share a spec object.
- [The slot system standard](2026-07-22-slot-type-chain-implementation.md) remains authoritative for the other kinds; this note adds the fifth.
diff --git a/.agents/notes/implemented/architecture/2026-11-03-hoc-slot-kind.zh.md b/.agents/notes/implemented/architecture/2026-11-03-hoc-slot-kind.zh.md
index 0f3ff1dc88..d9412b5126 100644
--- a/.agents/notes/implemented/architecture/2026-11-03-hoc-slot-kind.zh.md
+++ b/.agents/notes/implemented/architecture/2026-11-03-hoc-slot-kind.zh.md
@@ -42,7 +42,7 @@ Status: implemented
| 包 | 实现 |
|---|---|
| `ui-slots` | `SlotKind` 包含 `'hoc'`;`HocRenderOpts`(可选 `children` 与 `entryKey`)、`HocKeysOf`、`HocShare`;`RenderSlotFn` 为 hoc key 提供接受可选 `{ children, entryKey }` 的重载;`KindOptions` 的 hoc 分支含可选 `key`;`SlotCore.register` / `entriesOfSlot` 按 `(key 或通配, id)` 划分 hoc cell |
-| `ui-renderer` | `HocOutlet` 从 `hocChainFor` 取渲染函数,该缓存按 host、存活声明与分派 key 划分,分派同一 key 的所有 outlet 共享。每个 ledger 版本它只用 `hocLayersFor` 重新选出一次该 key 的层(通配胜者加精确 key 胜者,精确 key 的层替换同 id 的通配层,按 `order` 排序),仅当这一有序列表按 entry 身份比较发生变化时才调用 `composeHocLayers` 把各层组合成一个嵌套渲染函数。每层是一个组件,在组合时固定按 scope 选定的 Entry(`StrictSessionEntry` / `SessionMaybeEntry` / `RootEntry`)、entry、slot inject 与崩溃上报,渲染时只接收 `owner` 与内一层。没有层时 outlet 直接返回宿主内容。`HocContentBoundary` 包住每层的内层内容,把其中的错误包装为 `HocContentError` 重新抛出;层的边界放行这种错误,`HocOutletBoundary` 再解开为原始错误。Entry 链以 JSX children 把 `children` 交给注册组件;非 hoc entry 收到 `undefined`。`SlotErrorBoundary` 接受 `crashed` 替换节点,层的边界在本次挂载内一直渲染该节点;层的崩溃上报传 `abdicate: false` |
+| `ui-renderer` | `HocOutlet` 从 `hocChainFor` 取渲染函数,后者按 host、spec 对象、slot 名和 `entryKey` 缓存层链,同一组合的 outlet 实例共享一条层链。每个 ledger 版本它只用 `hocLayersFor` 重新选出一次该 key 的层(通配胜者加精确 key 胜者,精确 key 的层替换同 id 的通配层,按 `order` 排序),仅当这一有序列表按 entry 身份比较发生变化时才调用 `composeHocLayers` 把各层组合成一个嵌套渲染函数。每层是一个组件,在组合时固定按 scope 选定的 Entry(`StrictSessionEntry` / `SessionMaybeEntry` / `RootEntry`)、entry、slot inject 与崩溃上报,渲染时只接收 `owner` 与内一层。没有层时 outlet 直接返回宿主内容。`HocContentBoundary` 包住每层的内层内容,把其中的错误包装为 `HocContentError` 重新抛出;层的边界放行这种错误,`HocOutletBoundary` 再解开为原始错误。Entry 链以 JSX children 把 `children` 交给注册组件;非 hoc entry 收到 `undefined`。`SlotErrorBoundary` 接受 `crashed` 替换节点,层的边界在本次挂载内一直渲染该节点;层的崩溃上报传 `abdicate: false` |
| `scripts/gen-client-catalog.ts` | hoc 插槽的注册选项、渲染 `children` 的示例,以及 `wraps-owner-content` 替换风险 |
### 首个使用者
@@ -66,9 +66,9 @@ Status: implemented
- 增减一层会让其内部所有内容重新挂载,包括首页的输入框。
- 所有非 hoc 的注册组件都会收到 `children: undefined`,会覆盖同名的 owner prop。
- 每层在组件树中多一个组件和两个 error boundary;有层的 hoc 插槽另多一个 outlet 边界。
-- outlet 的 `[data-slot]` 元素位于 owner 与内容之间,owner 侧选择器不能假定内容是直接子元素。
+- 渲染器标记的是 slot 和[各层渲染 `children` 的位置](../../../../docs/subsystems/slots.zh.md#hoc-layers),而不是层组件自己的元素。插件不必添加自己的包装元素,但结构选择器必须考虑这些 DOM 元素。
- React 18 会在错误被重新抛出的位置重新采集组件栈,因此有层的 hoc 插槽之上的边界收到的内容错误,组件栈从 `HocOutletBoundary` 开始。
- 层如果自己在 `children` 外包错误边界,捕获到的是内部的 `HocContentError`,而不是原始的内容错误。
- frame 契约只在首页阶段成立:其他阶段根元素不参与层叠隔离,未经 portal 的 Conversation 浮层仍能盖住悬浮在中栏上方的 AppFrame 元素;首页阶段它们只在根元素内部比较层级。
-- `HocOutlet` 把层组件保存在按 host、存活声明与分派 key 共享的编译缓存中,而不是 outlet 实例状态里,因此不依赖 React 保留 memo 缓存;这些组件是其内部内容的重新挂载边界,重新声明的插槽从空缓存开始。
+- `HocOutlet` 把层组件保存在共享的编译缓存中,而不是 outlet 实例状态里,因此不依赖 React 保留 memo 缓存;这些组件是其内部内容的重新挂载边界。不同名称的 slot 即使复用同一个 spec 对象,也不共享层链。
- 其他 kind 仍以 [slot 体系标准](2026-07-22-slot-type-chain-implementation.zh.md) 为准;本 Note 新增第五种。
diff --git a/.agents/notes/implemented/architecture/2026-11-05-markdown-fence-hoc-slot.i18n.yaml b/.agents/notes/implemented/architecture/2026-11-05-markdown-fence-hoc-slot.i18n.yaml
index 468e7726f7..c428483cda 100644
--- a/.agents/notes/implemented/architecture/2026-11-05-markdown-fence-hoc-slot.i18n.yaml
+++ b/.agents/notes/implemented/architecture/2026-11-05-markdown-fence-hoc-slot.i18n.yaml
@@ -15,8 +15,8 @@
en: 03db9adf39724644
zh: 59350008e49737c3
/agent-note-dispatch-markdown-fences-by-language-through-a-keyed-hoc-slot/decision/hoc-slots-with-dispatch-keys:
- en: efd632de6cd9612b
- zh: 996ebdce579fa62a
+ en: 6bb63738320431b9
+ zh: 036b8506defc6e8b
/agent-note-dispatch-markdown-fences-by-language-through-a-keyed-hoc-slot/decision/code-blocks:
en: 8ca893405e949ced
zh: d08790568180ec36
diff --git a/.agents/notes/implemented/architecture/2026-11-05-markdown-fence-hoc-slot.md b/.agents/notes/implemented/architecture/2026-11-05-markdown-fence-hoc-slot.md
index 559fd5d9d1..3d6633de97 100644
--- a/.agents/notes/implemented/architecture/2026-11-05-markdown-fence-hoc-slot.md
+++ b/.agents/notes/implemented/architecture/2026-11-05-markdown-fence-hoc-slot.md
@@ -52,7 +52,7 @@ The API guarantees:
| Nesting | Ascending `order`, then `priority`, then registration order; lowest `order` outermost |
| children | Rendered at most once; omitting it replaces everything inside the layer |
| Crash | The failed occurrence renders `children` for the rest of its mount and the error is reported; the layer stays registered (`abdicate: false`) and other occurrences keep it; the occurrence retries when it remounts |
-| Compilation | One chain per `(host, slot declaration, entryKey)`, shared by every outlet; each ledger version reselects that key's layers and recompiles only when they change, so a registration for another key leaves mounted content in place, while switching an outlet's `entryKey` switches chains |
+| Compilation | Outlets with the same host, spec object, slot name, and `entryKey` [share one compiled chain](../../../../docs/subsystems/slots.md#hoc-layers); each ledger version reselects that key's layers and recompiles only when they change, so a registration for another key leaves mounted content in place, while switching an outlet's `entryKey` switches chains |
These hoc semantics apply to every hoc slot, including `conversation.hero.frame`, whose layers are all wildcards. This note partially supersedes four decisions of [hoc slot kind](2026-11-03-hoc-slot-kind.md): rendering `children` exactly once, rejecting `entryKey`, per-outlet `useMemo` composition, and abdicating a crashed layer.
diff --git a/.agents/notes/implemented/architecture/2026-11-05-markdown-fence-hoc-slot.zh.md b/.agents/notes/implemented/architecture/2026-11-05-markdown-fence-hoc-slot.zh.md
index 32daa0c05a..0eb7b085f1 100644
--- a/.agents/notes/implemented/architecture/2026-11-05-markdown-fence-hoc-slot.zh.md
+++ b/.agents/notes/implemented/architecture/2026-11-05-markdown-fence-hoc-slot.zh.md
@@ -52,7 +52,7 @@ API 保证:
| 嵌套 | 依次按 `order`、`priority`、注册顺序升序,`order` 最小的在最外层 |
| children | 至多渲染一次;不渲染即替换该层内部的全部内容 |
| 崩溃 | 出错的那一处在本次挂载内渲染 `children`,错误照常上报;层保持注册(`abdicate: false`),其他出现处保留该层;该处重新挂载时重试 |
-| 编译 | 每个 `(host, slot 声明, entryKey)` 一条层链,所有 outlet 共享;每个 ledger 版本重新选取该 key 的层,只有层变化时才重编,因此为其他 key 注册的层不会让已挂载内容重新挂载,outlet 切换 `entryKey` 则换到另一条层链 |
+| 编译 | host、spec 对象、slot 名和 `entryKey` 都相同的 outlet [共享一条编译好的层链](../../../../docs/subsystems/slots.zh.md#hoc-layers);每个 ledger 版本重新选取该 key 的层,只有层变化时才重编,因此为其他 key 注册的层不会让已挂载内容重新挂载,outlet 切换 `entryKey` 则换到另一条层链 |
这些 hoc 语义适用于所有 hoc slot,包括层全部为通配层的 `conversation.hero.frame`。本 note 部分取代 [hoc slot kind](2026-11-03-hoc-slot-kind.zh.md) 的四处决定:恰好渲染一次 `children`、不接受 `entryKey`、按 outlet `useMemo` 组合层、崩溃层 abdicate。
diff --git a/.agents/notes/implemented/feature/2026-09-28-apply-patch-file-editing.i18n.yaml b/.agents/notes/implemented/feature/2026-09-28-apply-patch-file-editing.i18n.yaml
index 4cb149615f..b229e67c3c 100644
--- a/.agents/notes/implemented/feature/2026-09-28-apply-patch-file-editing.i18n.yaml
+++ b/.agents/notes/implemented/feature/2026-09-28-apply-patch-file-editing.i18n.yaml
@@ -9,11 +9,11 @@
en: de9b76d89795ccec
zh: 588d45b7d9ca9582
/agent-note-apply-patch-file-editing/decision:
- en: e3e174513948d0dd
- zh: 80b13d7e40d38dee
+ en: 269382982f64bfd3
+ zh: bf2936903af27a19
/agent-note-apply-patch-file-editing/alternatives-considered:
- en: fb743c9558cf24ed
- zh: e74bdfff00dea417
+ en: 566894a4c70759cc
+ zh: 176467422789c5e8
/agent-note-apply-patch-file-editing/consequences:
en: b58b7324663c3c90
zh: 649c18a83e33e71d
diff --git a/.agents/notes/implemented/feature/2026-09-28-apply-patch-file-editing.md b/.agents/notes/implemented/feature/2026-09-28-apply-patch-file-editing.md
index 1b911eba1c..ea17259242 100644
--- a/.agents/notes/implemented/feature/2026-09-28-apply-patch-file-editing.md
+++ b/.agents/notes/implemented/feature/2026-09-28-apply-patch-file-editing.md
@@ -20,7 +20,7 @@ Commit reports return `isError: false` so completed diff metadata survives a sto
[Review capture](../../../../packages/deliverables/workspace-changes/README.md) uses filesystem intent listeners, not argument parsing. `tools/pre-execute` associates the execution with its turn recorder; prepended write, edit, and delete listeners first await the policy decision, then await capture before provider mutation. Moves capture both endpoints. Each turn retains its first baseline and compares actual final bytes, so repeated edits yield one net diff and reverted changes disappear. Existing size, count, time, location, and Session-lifetime limits remain.
-`tool-fs.applyPatch` defaults to `false`; each shipped `tool-fs` row that enables `edit` states its own value, so turning the tool on or off is one line per composition, or a profile patch on the `tool-fs` id where no preset owns the row. The tool consults the `fs/*` intent waterfalls like `write` and `edit`, so a mounted observation policy requires a prior read and rejects stale versions for every patch operation. The shipped values of those rows and of the `fs-observation-policy` row are decided by [Shipped filesystem mutation defaults](2026-10-29-shipped-fs-mutation-defaults.md), which supersedes this note's opt-in baseline. The schema names its argument `input` as the Codex tool does: across 2,226 recorded DS-Bench and DeepSWE rollouts, 14% of `apply_patch` calls arrived with that key and were rejected while the argument was named `patch`. The tool registers its schema, guidance, native/PTC execution, and tool presentation through plugin effects; the agent loop is unchanged.
+`tool-fs.applyPatch` defaults to `false`; each shipped `tool-fs` row that enables `edit` states its own value, so turning the tool on or off is one line per composition, or a profile patch on the `tool-fs` id where no preset owns the row. The tool consults the `fs/*` intent waterfalls like `write` and `edit`, so a mounted observation policy requires a prior read and rejects stale versions for every patch operation. The shipped values of those rows and of the `fs-observation-policy` row are decided by [Shipped filesystem mutation defaults](2026-10-29-shipped-fs-mutation-defaults.md), which supersedes this note's opt-in baseline, and [Apply patch follows edit](2026-11-23-apply-patch-follows-edit.md) replaces the `false` default: an unset `applyPatch` follows `edit`. The schema names its argument `input` as the Codex tool does: across 2,226 recorded DS-Bench and DeepSWE rollouts, 14% of `apply_patch` calls arrived with that key and were rejected while the argument was named `patch`. The tool registers its schema, guidance, native/PTC execution, and tool presentation through plugin effects; the agent loop is unchanged.
## Alternatives considered
@@ -32,7 +32,7 @@ Commit reports return `isError: false` so completed diff metadata survives a sto
**Expand Review while adding the tool.** Rename presentation, persistent storage, SSH capture, and capture-failure policy are independent product decisions; existing whole-file capture and rendering cover this integration.
-**Register the tool by default wherever `write` and `edit` are both enabled.** This would add a schema and a guidance section to every default model request and change every recorded request expectation before the tool's effect on ordinary sessions is measured; the explicit switch keeps the baseline composition unchanged and lets comparison runs opt in. The shipped defaults were decided afterwards in [Shipped filesystem mutation defaults](2026-10-29-shipped-fs-mutation-defaults.md).
+**Register the tool by default wherever `write` and `edit` are both enabled.** This would add a schema and a guidance section to every default model request and change every recorded request expectation before the tool's effect on ordinary sessions is measured; the explicit switch keeps the baseline composition unchanged and lets comparison runs opt in. The shipped defaults were decided afterwards in [Shipped filesystem mutation defaults](2026-10-29-shipped-fs-mutation-defaults.md), and [Apply patch follows edit](2026-11-23-apply-patch-follows-edit.md) later adopted this default.
## Consequences
diff --git a/.agents/notes/implemented/feature/2026-09-28-apply-patch-file-editing.zh.md b/.agents/notes/implemented/feature/2026-09-28-apply-patch-file-editing.zh.md
index 6948abe0ea..81046b99d5 100644
--- a/.agents/notes/implemented/feature/2026-09-28-apply-patch-file-editing.zh.md
+++ b/.agents/notes/implemented/feature/2026-09-28-apply-patch-file-editing.zh.md
@@ -20,7 +20,7 @@ Status: implemented
[Review 采集](../../../../packages/deliverables/workspace-changes/README.zh.md)使用文件系统 intent 监听器,不解析参数。`tools/pre-execute` 将执行关联到轮次记录器;前置的 write、edit 和 delete 监听器先等待策略决策,再等待捕获完成,然后提供方才修改文件。移动捕获两端。每轮保留首次基线,比较实际最终字节,因此重复编辑形成一份净 diff,还原的变化不再显示。现有大小、数量、时间、位置和 Session 生命周期限制保持适用。
-`tool-fs.applyPatch` 默认为 `false`;每个启用 `edit` 的随发行版交付的 `tool-fs` 行都显式写出自己的值,因此开关该工具是每个组合一行改动,没有 preset 拥有该行时可通过针对 `tool-fs` id 的 profile patch 开启。该工具像 `write` 和 `edit` 一样咨询 `fs/*` intent waterfall,因此已挂载的观察策略对每个补丁操作要求先读并拒绝过期版本。这些行以及 `fs-observation-policy` 行随发行版交付的值由[随发行版交付的文件系统修改默认值](2026-10-29-shipped-fs-mutation-defaults.zh.md)决定,该 Note 取代本 Note 的 opt-in 基线。schema 沿用 Codex 的参数名 `input`:在 2,226 条 DS-Bench 与 DeepSWE 录制轨迹中,14% 的 `apply_patch` 调用带着这个键发出,而参数名为 `patch` 时它们都被拒绝。工具通过插件 effect 注册 schema、指导文本、native/PTC 执行与调用展示;不修改 agent loop(智能体循环)。
+`tool-fs.applyPatch` 默认为 `false`;每个启用 `edit` 的随发行版交付的 `tool-fs` 行都显式写出自己的值,因此开关该工具是每个组合一行改动,没有 preset 拥有该行时可通过针对 `tool-fs` id 的 profile patch 开启。该工具像 `write` 和 `edit` 一样咨询 `fs/*` intent waterfall,因此已挂载的观察策略对每个补丁操作要求先读并拒绝过期版本。这些行以及 `fs-observation-policy` 行随发行版交付的值由[随发行版交付的文件系统修改默认值](2026-10-29-shipped-fs-mutation-defaults.zh.md)决定,该 Note 取代本 Note 的 opt-in 基线;[Apply patch 跟随 edit](2026-11-23-apply-patch-follows-edit.zh.md) 取代 `false` 默认值:未设置的 `applyPatch` 跟随 `edit`。schema 沿用 Codex 的参数名 `input`:在 2,226 条 DS-Bench 与 DeepSWE 录制轨迹中,14% 的 `apply_patch` 调用带着这个键发出,而参数名为 `patch` 时它们都被拒绝。工具通过插件 effect 注册 schema、指导文本、native/PTC 执行与调用展示;不修改 agent loop(智能体循环)。
## 考虑过的替代方案
@@ -32,7 +32,7 @@ Status: implemented
**加入工具时同时扩展 Review。** 重命名展示、持久存储、SSH 采集和捕获失败策略是独立产品决策;既有整文件采集和展示覆盖本次接入。
-**在同时启用 `write` 与 `edit` 的地方默认注册该工具。** 这会在尚未衡量该工具对普通会话的影响之前,给每个默认模型请求增加一个 schema 和一段指导文本,并改变所有录制请求的预期;显式开关保持基线组合不变,让对比评测自行选择开启。随发行版交付的默认值随后在[随发行版交付的文件系统修改默认值](2026-10-29-shipped-fs-mutation-defaults.zh.md)中决定。
+**在同时启用 `write` 与 `edit` 的地方默认注册该工具。** 这会在尚未衡量该工具对普通会话的影响之前,给每个默认模型请求增加一个 schema 和一段指导文本,并改变所有录制请求的预期;显式开关保持基线组合不变,让对比评测自行选择开启。随发行版交付的默认值随后在[随发行版交付的文件系统修改默认值](2026-10-29-shipped-fs-mutation-defaults.zh.md)中决定,[Apply patch 跟随 edit](2026-11-23-apply-patch-follows-edit.zh.md) 后来采用了这一默认行为。
## 后果
diff --git a/.agents/notes/implemented/feature/2026-10-29-shipped-fs-mutation-defaults.i18n.yaml b/.agents/notes/implemented/feature/2026-10-29-shipped-fs-mutation-defaults.i18n.yaml
index edbaa9db2f..1171d04e70 100644
--- a/.agents/notes/implemented/feature/2026-10-29-shipped-fs-mutation-defaults.i18n.yaml
+++ b/.agents/notes/implemented/feature/2026-10-29-shipped-fs-mutation-defaults.i18n.yaml
@@ -9,11 +9,11 @@
en: 57dcac3bdbcf1c21
zh: f5bf64888e6dd973
/agent-note-shipped-filesystem-mutation-defaults/decision:
- en: bb3f24080fd35466
- zh: 9e150eca994cccd0
+ en: 73697cb1201df898
+ zh: 52c57f98f95b7470
/agent-note-shipped-filesystem-mutation-defaults/alternatives-considered:
- en: 1249a7868ff2a069
- zh: 739f191121bf5293
+ en: 1cd4dcb6033aaf70
+ zh: 2b9472dbebe47b2a
/agent-note-shipped-filesystem-mutation-defaults/consequences:
en: 3def7f0443b41d34
zh: 70df709d1fcbe8fa
diff --git a/.agents/notes/implemented/feature/2026-10-29-shipped-fs-mutation-defaults.md b/.agents/notes/implemented/feature/2026-10-29-shipped-fs-mutation-defaults.md
index 3ce6819ef6..30f43303f4 100644
--- a/.agents/notes/implemented/feature/2026-10-29-shipped-fs-mutation-defaults.md
+++ b/.agents/notes/implemented/feature/2026-10-29-shipped-fs-mutation-defaults.md
@@ -10,7 +10,7 @@ English | [中文](2026-10-29-shipped-fs-mutation-defaults.zh.md)
## Decision
-- The `dsh-base` `tool-fs` row (headless, SDK, and ACP) and the Web `standard` preset state `applyPatch: true`. The Web `ptc` and `cordis` presets state `applyPatch: false`, and the shipped [PTC overlay](../../../../apps/cli/config/examples/ptc.yml) sets the same on the base row, so both keep the tool set the PTC compositions were evaluated with.
+- The `dsh-base` `tool-fs` row (headless, SDK, and ACP) and the Web `standard` preset state `applyPatch: true`. The Web `ptc` and `cordis` presets state `applyPatch: false`, and the shipped [PTC overlay](../../../../apps/cli/config/examples/ptc.yml) sets the same on the base row, so both keep the tool set the PTC compositions were evaluated with. [Apply patch follows edit](2026-11-23-apply-patch-follows-edit.md) supersedes this bullet: shipped rows state no `applyPatch`, which then follows `edit`, and the PTC compositions offer the tool.
- The `dsh-base` `fs-observation-policy` row ships `disabled: true`. Every mutating tool in a base-backed profile runs against the bare provider: `write` overwrites, `edit` replaces the unique literal match, and `apply_patch` applies hunks on context match alone. A deployment restores the guard for all three with `disabled: false` on that row. `sdk-minimal` stacks no `dsh-base` and is unaffected.
- The `write` and `edit` guidance keeps asking for a prior read without naming the policy; the `apply_patch` guidance asks for enough hunk context to match one place instead of a prior read.
- The policy package is classified as an optional product package, since no default composition mounts it. The two recordings that capture a policy refusal, `fs-policy-reject` and `apply-patch-rejected`, re-enable the row through a per-scenario `runtime.cordis.yml`; the fixed-budget compaction scenarios pin `applyPatch: false` in both their live and replay patches because their thresholds were tuned to the recorded tool set.
@@ -21,7 +21,7 @@ English | [中文](2026-10-29-shipped-fs-mutation-defaults.zh.md)
**Disable the policy for `apply_patch` only.** A `tool-fs` switch that skipped the intent waterfalls for patches alone was built and evaluated, but it left `write` and `edit` under a guard the shipped compositions no longer wanted and added a second configuration axis beside the policy row; disabling the row decides all three tools in one place and keeps the policy package intact for deployments that want it.
-**Enable `apply_patch` in the PTC presets too.** Under PTC the tool is a `run_code` binding rather than a JSON schema, so the cost is small, but the PTC compositions were evaluated without it; the overlay and the Web preset keep the evaluated tool set.
+**Enable `apply_patch` in the PTC presets too.** Under PTC the tool is a `run_code` binding rather than a JSON schema, so the cost is small, but the PTC compositions were evaluated without it; the overlay and the Web preset keep the evaluated tool set. [Apply patch follows edit](2026-11-23-apply-patch-follows-edit.md) later adopted this alternative.
## Consequences
diff --git a/.agents/notes/implemented/feature/2026-10-29-shipped-fs-mutation-defaults.zh.md b/.agents/notes/implemented/feature/2026-10-29-shipped-fs-mutation-defaults.zh.md
index 2478c45cdb..de0adb7e49 100644
--- a/.agents/notes/implemented/feature/2026-10-29-shipped-fs-mutation-defaults.zh.md
+++ b/.agents/notes/implemented/feature/2026-10-29-shipped-fs-mutation-defaults.zh.md
@@ -10,7 +10,7 @@
## 决策
-- `dsh-base` 的 `tool-fs` 行(headless、SDK、ACP)与 Web 的 `standard` preset 写出 `applyPatch: true`。Web 的 `ptc`、`cordis` preset 写出 `applyPatch: false`,随发行版交付的 [PTC overlay](../../../../apps/cli/config/examples/ptc.yml) 在 base 行上也设为 `false`,两者都保持 PTC 组合评测时的工具集。
+- `dsh-base` 的 `tool-fs` 行(headless、SDK、ACP)与 Web 的 `standard` preset 写出 `applyPatch: true`。Web 的 `ptc`、`cordis` preset 写出 `applyPatch: false`,随发行版交付的 [PTC overlay](../../../../apps/cli/config/examples/ptc.yml) 在 base 行上也设为 `false`,两者都保持 PTC 组合评测时的工具集。[Apply patch 跟随 edit](2026-11-23-apply-patch-follows-edit.zh.md) 取代本条:内置行不写 `applyPatch`,它随之跟随 `edit`,PTC 组合也提供该工具。
- `dsh-base` 的 `fs-observation-policy` 行以 `disabled: true` 交付。叠加 base 的 profile 中每个修改工具都直接作用于裸提供方:`write` 覆盖,`edit` 替换唯一的字面匹配,`apply_patch` 只凭上下文匹配应用 hunk。部署在该行上写 `disabled: false` 即可为三者恢复防护。`sdk-minimal` 不叠加 `dsh-base`,不受影响。
- `write` 与 `edit` 的提示语仍要求先读,但不再点名该策略;`apply_patch` 的提示语要求给每个 hunk 足够的上下文以匹配唯一位置,而非先读。
- 由于没有默认组合挂载策略包,它被归类为可选产品包。录的是策略拒绝的两个场景 `fs-policy-reject` 与 `apply-patch-rejected` 通过各自的 `runtime.cordis.yml` 把该行开回来;固定 token 预算的压缩场景在 live 与 replay patch 中都钉住 `applyPatch: false`,因为它们的阈值是按录制时的工具集调的。
@@ -21,7 +21,7 @@
**只对 `apply_patch` 关闭策略。** 曾实现并评测过一个让补丁跳过 intent waterfall 的 `tool-fs` 开关,但它让 `write` 与 `edit` 继续受随发行版交付的组合已不需要的防护,并在策略行之外增加了第二个配置维度;禁用该行在一处决定三个工具,并为需要防护的部署完整保留策略包。
-**在 PTC preset 中也开启 `apply_patch`。** PTC 下该工具是 `run_code` 内的绑定而非 JSON schema,代价很小,但 PTC 组合是在没有它的情况下评测的;overlay 与 Web preset 保持评测时的工具集。
+**在 PTC preset 中也开启 `apply_patch`。** PTC 下该工具是 `run_code` 内的绑定而非 JSON schema,代价很小,但 PTC 组合是在没有它的情况下评测的;overlay 与 Web preset 保持评测时的工具集。[Apply patch 跟随 edit](2026-11-23-apply-patch-follows-edit.zh.md) 后来采用了这一方案。
## 后果
diff --git a/.agents/notes/implemented/feature/2026-11-23-apply-patch-follows-edit.i18n.yaml b/.agents/notes/implemented/feature/2026-11-23-apply-patch-follows-edit.i18n.yaml
new file mode 100644
index 0000000000..25cf68a4d7
--- /dev/null
+++ b/.agents/notes/implemented/feature/2026-11-23-apply-patch-follows-edit.i18n.yaml
@@ -0,0 +1,22 @@
+# Bilingual-pair consistency record for 2026-11-23-apply-patch-follows-edit.md (docs/i18n/README.md): per heading
+# section, a hash of its English and Chinese blocks outside code blocks and generated regions.
+# After editing either side, bring the other along and re-record with:
+# pnpm run verify-translation-pairing --write .agents/notes/implemented/feature/2026-11-23-apply-patch-follows-edit.md
+/agent-note-apply-patch-follows-edit:
+ en: 308f457df1043b22
+ zh: a2b7e5704bd75bfc
+/agent-note-apply-patch-follows-edit/problem:
+ en: 76703e4d5526f79a
+ zh: e1902a2cee4ec8ae
+/agent-note-apply-patch-follows-edit/decision:
+ en: 81d0f093dc8d3484
+ zh: febca7ada6c6494d
+/agent-note-apply-patch-follows-edit/alternatives-considered:
+ en: ad9a06d31a34428c
+ zh: b01ca4cdb81049ea
+/agent-note-apply-patch-follows-edit/consequences:
+ en: fa0ae7968dc0f327
+ zh: acfe649e0b829ffa
+/agent-note-apply-patch-follows-edit/testing:
+ en: 05ec244f1a0ab3dc
+ zh: 36c137bf58aef7e0
diff --git a/.agents/notes/implemented/feature/2026-11-23-apply-patch-follows-edit.md b/.agents/notes/implemented/feature/2026-11-23-apply-patch-follows-edit.md
new file mode 100644
index 0000000000..8f75beb857
--- /dev/null
+++ b/.agents/notes/implemented/feature/2026-11-23-apply-patch-follows-edit.md
@@ -0,0 +1,29 @@
+# Agent Note: Apply patch follows edit
+
+Status: implemented
+
+English | [中文](2026-11-23-apply-patch-follows-edit.zh.md)
+
+## Problem
+
+[Shipped filesystem mutation defaults](2026-10-29-shipped-fs-mutation-defaults.md) enabled `apply_patch` by stating `applyPatch: true` on the `dsh-base` `tool-fs` row and the Web `standard` preset, while the `ptc` and `cordis` presets and the PTC overlay stated `false` and the `tool-fs` schema defaulted to `false`. Agent presets list complete plugin declarations with no shared parent, so every shipped default had to be repeated on each row, and the shipped coding presets offered different file-editing tools for the same workspace.
+
+## Decision
+
+- `tool-fs` resolves an unset `applyPatch` to the resolved `edit` value in an explicit `resolveConfig` step ([`src/index.ts`](../../../../packages/fs/tool-fs/src/index.ts)); an explicit `true` or `false` wins, and the schema carries no `applyPatch` default.
+- The `dsh-base` `tool-fs` row (headless, SDK, and ACP), the Web and Desktop `standard`, `ptc`, and `cordis` presets, and the shipped [PTC overlay](../../../../apps/cli/config/examples/ptc.yml) state no `applyPatch`, so each offers `apply_patch` beside `edit`: a JSON tool under native execution and a `run_code` binding under PTC. The Web `minimal` preset and `sdk-minimal` set `edit: false` and omit it. The SDK and Desktop `standard` and `ptc` tool sets stay equal.
+- The fixed-budget compaction scenarios keep pinning `applyPatch: false`, because their thresholds were tuned to the recorded tool set.
+
+## Alternatives considered
+
+**State `applyPatch: true` on each shipped row.** Every preset and the base row would repeat the value, and a new composition that enables `edit` would have to remember it; deriving the default inside `tool-fs` decides it in one place.
+
+**Keep `apply_patch` off in the PTC and `cordis` presets.** The PTC compositions were evaluated without the tool, but keeping it off leaves the shipped coding presets with different file-editing tools for the same workspace. Under PTC the tool is a `run_code` binding rather than a JSON schema, so it adds little to each request. Unlike the base and `standard` defaults, enabling it in these presets rests on that consistency, not on a separate benchmark run.
+
+## Consequences
+
+Every `tool-fs` row that keeps `edit` and states no `applyPatch` registers `apply_patch`, including rows in third-party profiles, presets, and plugins; the [upgrade guide](../../../../docs/upgrade-guide/v0.2.3-alpha.2/apply-patch-default-on/guide.md) names the one-key opt-out. `dsh --dump-config` renders only stated keys, so the derived value is visible in model requests, not in the dump. Recorded expectations whose `tool-fs` rows enable `edit` without `applyPatch` carry the tool's guidance and schema.
+
+## Testing
+
+`tool-fs` registration tests cover the derived default and both explicit overrides. `web-agent-presets.e2e.ts` asserts `apply_patch` in the `cordis` tool set and in the `ptc` `run_code` bindings; the keyless SDK smoke checks the native tool and the PTC overlay binding; `desktop-tools.expected.e2e.ts` compares the SDK and Desktop `standard` and `ptc` tool sets.
diff --git a/.agents/notes/implemented/feature/2026-11-23-apply-patch-follows-edit.zh.md b/.agents/notes/implemented/feature/2026-11-23-apply-patch-follows-edit.zh.md
new file mode 100644
index 0000000000..534522f78d
--- /dev/null
+++ b/.agents/notes/implemented/feature/2026-11-23-apply-patch-follows-edit.zh.md
@@ -0,0 +1,29 @@
+# Agent Note: Apply patch 跟随 edit
+
+状态:implemented
+
+[English](2026-11-23-apply-patch-follows-edit.md) | 中文
+
+## 问题
+
+[随发行版交付的文件系统修改默认值](2026-10-29-shipped-fs-mutation-defaults.zh.md)通过在 `dsh-base` 的 `tool-fs` 行与 Web 的 `standard` preset 上写出 `applyPatch: true` 来开启 `apply_patch`,而 `ptc`、`cordis` preset 与 PTC overlay 写出 `false`,`tool-fs` schema 的默认值也是 `false`。Agent preset 列出完整的插件声明,没有共同的父级,因此每个内置默认值都要在每一行上重复,随发行版交付的各编码 preset 也会对同一工作区提供不同的文件编辑工具。
+
+## 决策
+
+- `tool-fs` 在显式的 `resolveConfig` 步骤([`src/index.ts`](../../../../packages/fs/tool-fs/src/index.ts))中把未设置的 `applyPatch` 解析为解析后的 `edit` 值;显式写出的 `true` 或 `false` 优先,schema 不再为 `applyPatch` 提供默认值。
+- `dsh-base` 的 `tool-fs` 行(headless、SDK、ACP)、Web 与 Desktop 的 `standard`、`ptc`、`cordis` preset,以及随发行版交付的 [PTC overlay](../../../../apps/cli/config/examples/ptc.yml) 都不写 `applyPatch`,因此都在 `edit` 旁提供 `apply_patch`:原生执行下是 JSON 工具,PTC 下是 `run_code` 绑定。Web 的 `minimal` preset 与 `sdk-minimal` 设置 `edit: false`,不提供它。SDK 与 Desktop 的 `standard`、`ptc` 工具集保持一致。
+- 固定 token 预算的压缩场景继续钉住 `applyPatch: false`,因为它们的阈值是按录制时的工具集调的。
+
+## 考虑过的替代方案
+
+**在每个内置行上写出 `applyPatch: true`。** 每个 preset 和 base 行都要重复这个值,新的组合开启 `edit` 时也必须记得写上;在 `tool-fs` 内推导默认值,只需在一处决定。
+
+**在 PTC 与 `cordis` preset 中保持 `apply_patch` 关闭。** PTC 组合是在没有该工具的情况下评测的,但保持关闭会让随发行版交付的各编码 preset 对同一工作区提供不同的文件编辑工具。PTC 下该工具是 `run_code` 内的绑定而非 JSON schema,每个请求增加的内容很少。与 base 和 `standard` 的默认值不同,这两个 preset 开启它依据的是这种一致性,而不是单独的 benchmark。
+
+## 后果
+
+每个保留 `edit` 且未写 `applyPatch` 的 `tool-fs` 行都会注册 `apply_patch`,包括第三方 profile、preset 和插件中的行;[升级指南](../../../../docs/upgrade-guide/v0.2.3-alpha.2/apply-patch-default-on/guide.zh.md)给出关闭它所需的一个键。`dsh --dump-config` 只渲染显式写出的键,因此推导出的值只能在模型请求中看到,在输出中看不到。`tool-fs` 行开启 `edit` 而未写 `applyPatch` 的录制预期带有该工具的提示语与 schema。
+
+## 测试
+
+`tool-fs` 注册测试覆盖推导出的默认值和两种显式覆盖。`web-agent-presets.e2e.ts` 断言 `cordis` 工具集与 `ptc` 的 `run_code` 绑定中都有 `apply_patch`;keyless SDK smoke 检查原生工具和 PTC overlay 下的绑定;`desktop-tools.expected.e2e.ts` 比较 SDK 与 Desktop 的 `standard`、`ptc` 工具集。
diff --git a/apps/cli/config/examples/ptc.yml b/apps/cli/config/examples/ptc.yml
index 65905eacdd..d0c2cc888a 100644
--- a/apps/cli/config/examples/ptc.yml
+++ b/apps/cli/config/examples/ptc.yml
@@ -3,8 +3,3 @@
- id: tool-executor-ptc
disabled: false
-
-# PTC mode exposes the pre-apply_patch tool set, as the Web ptc preset does.
-- id: tool-fs
- config:
- applyPatch: false
diff --git a/apps/cli/tests/profiles/headless/subagent-inheritance-snapshot.patch.yml b/apps/cli/tests/profiles/headless/subagent-inheritance-snapshot.patch.yml
index 83547c6412..7511e92167 100644
--- a/apps/cli/tests/profiles/headless/subagent-inheritance-snapshot.patch.yml
+++ b/apps/cli/tests/profiles/headless/subagent-inheritance-snapshot.patch.yml
@@ -40,8 +40,3 @@
- id: session-log-deepseek
config:
enabled: false
-
-# The recorded tool catalog includes the optional patch tool.
-- id: tool-fs
- config:
- applyPatch: true
diff --git a/apps/cli/tests/profiles/headless/tests/expected/goal-tools/stream-json.expected.jsonl b/apps/cli/tests/profiles/headless/tests/expected/goal-tools/stream-json.expected.jsonl
index 6e66c8149d..ae0be7d698 100644
--- a/apps/cli/tests/profiles/headless/tests/expected/goal-tools/stream-json.expected.jsonl
+++ b/apps/cli/tests/profiles/headless/tests/expected/goal-tools/stream-json.expected.jsonl
@@ -2,7 +2,7 @@
{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"turn/start","seq":4,"time":0,"data":{"turn":1}}}
{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"agent/inbox/spliced","seq":5,"time":0,"data":{"target":"next-turn","start":0,"removedCount":1,"inserted":[]}}}
{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"step/start","seq":6,"time":0,"data":{"turn":1,"step":1}}}
-{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"system/message","seq":7,"time":0,"data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tool:bash","order":1000,"state":"active","contentIndex":2},{"name":"tool:read","order":1100,"state":"active","contentIndex":3},{"name":"tool:write","order":1200,"state":"active","contentIndex":4},{"name":"tool:edit","order":1300,"state":"active","contentIndex":5},{"name":"tool:glob","order":1400,"state":"active","contentIndex":6},{"name":"tool:grep","order":1500,"state":"active","contentIndex":7},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":8},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":9},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":10},{"name":"tool:goal","order":2400,"state":"active","contentIndex":11},{"name":"tool:workflow","order":2600,"state":"active","contentIndex":12},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":13}]},"id":"{{sessionId}}"}},"surfaceOp":"append"}}
+{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"system/message","seq":7,"time":0,"data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tool:bash","order":1000,"state":"active","contentIndex":2},{"name":"tool:read","order":1100,"state":"active","contentIndex":3},{"name":"tool:write","order":1200,"state":"active","contentIndex":4},{"name":"tool:edit","order":1300,"state":"active","contentIndex":5},{"name":"tool:apply_patch","order":1350,"state":"active","contentIndex":6},{"name":"tool:glob","order":1400,"state":"active","contentIndex":7},{"name":"tool:grep","order":1500,"state":"active","contentIndex":8},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":9},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":10},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":11},{"name":"tool:goal","order":2400,"state":"active","contentIndex":12},{"name":"tool:workflow","order":2600,"state":"active","contentIndex":13},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":14}]},"id":"{{sessionId}}"}},"surfaceOp":"append"}}
{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"user/message","seq":8,"time":0,"data":{"content":[{"type":"text","text":"Probe strict-schema fillers against missing-goal revision 1, then create a durable goal to finish the snapshot proof and inspect it."}],"source":{"kind":"user"},"role":"user","id":"{{sessionId}}"},"surfaceOp":"append"}}
{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"user/message","seq":9,"time":0,"data":{"content":[{"type":"text","text":"\nThe following information describes your current session:\n\nCurrent working directory: \"{{cwd}}\".\n\nCurrent DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}\". Some platform temporary areas may also be writable.\n\nApproval prompts are enabled in this session: operations that require approval may ask through the configured answerers; without an available answerer, the request fails closed.\n\nYou are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names.\n"}],"source":{"kind":"runtime-context","form":"snapshot","sections":[{"name":"working-directory:current","text":"Current working directory: \"{{cwd}}\"."},{"name":"sandbox:policy","text":"Current DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}\". Some platform temporary areas may also be writable."},{"name":"approval:policy","text":"Approval prompts are enabled in this session: operations that require approval may ask through the configured answerers; without an available answerer, the request fails closed."},{"name":"subagent:identity","text":"You are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names."}]},"role":"user","id":"{{sessionId}}"},"surfaceOp":"append"}}
{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"request/header","seq":10,"time":0,"data":{"header":{"config":{"provider":"deepseek-official","model":"deepseek-v4-flash"},"tools":"{{tools}}"},"reason":"initial"}}}
diff --git a/apps/cli/tests/profiles/headless/tests/expected/headless-profile/session.expected.jsonl b/apps/cli/tests/profiles/headless/tests/expected/headless-profile/session.expected.jsonl
index 7e1012f53e..9a1d7ba82b 100644
--- a/apps/cli/tests/profiles/headless/tests/expected/headless-profile/session.expected.jsonl
+++ b/apps/cli/tests/profiles/headless/tests/expected/headless-profile/session.expected.jsonl
@@ -6,7 +6,7 @@
{"type":"turn/start","data":{"turn":1}}
{"type":"agent/inbox/spliced","data":{"target":"next-turn","start":0,"removedCount":1,"inserted":[]}}
{"type":"step/start","data":{"turn":1,"step":1}}
-{"type":"system/message","data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tool:bash","order":1000,"state":"active","contentIndex":2},{"name":"tool:read","order":1100,"state":"active","contentIndex":3},{"name":"tool:write","order":1200,"state":"active","contentIndex":4},{"name":"tool:edit","order":1300,"state":"active","contentIndex":5},{"name":"tool:glob","order":1400,"state":"active","contentIndex":6},{"name":"tool:grep","order":1500,"state":"active","contentIndex":7},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":8},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":9},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":10},{"name":"tool:goal","order":2400,"state":"active","contentIndex":11},{"name":"tool:workflow","order":2600,"state":"active","contentIndex":12},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":13}]},"id":"{{sessionId}}"}},"surfaceOp":"append"}
+{"type":"system/message","data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tool:bash","order":1000,"state":"active","contentIndex":2},{"name":"tool:read","order":1100,"state":"active","contentIndex":3},{"name":"tool:write","order":1200,"state":"active","contentIndex":4},{"name":"tool:edit","order":1300,"state":"active","contentIndex":5},{"name":"tool:apply_patch","order":1350,"state":"active","contentIndex":6},{"name":"tool:glob","order":1400,"state":"active","contentIndex":7},{"name":"tool:grep","order":1500,"state":"active","contentIndex":8},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":9},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":10},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":11},{"name":"tool:goal","order":2400,"state":"active","contentIndex":12},{"name":"tool:workflow","order":2600,"state":"active","contentIndex":13},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":14}]},"id":"{{sessionId}}"}},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"Prove the product headless profile path with one real tool round trip."}],"source":{"kind":"user"},"role":"user","id":"{{sessionId}}"},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"\nThe following information describes your current session:\n\nCurrent working directory: \"{{cwd}}\".\n\nCurrent DSH file policy: danger-full-access. The DSH file sandbox does not restrict file modifications by available operations.\n\nApproval prompts are disabled in this session: actions that require approval are rejected automatically — do not request sandbox escalation (do not set `sandbox_permissions`).\n\nYou are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names.\n"}],"source":{"kind":"runtime-context","form":"snapshot","sections":[{"name":"working-directory:current","text":"Current working directory: \"{{cwd}}\"."},{"name":"sandbox:policy","text":"Current DSH file policy: danger-full-access. The DSH file sandbox does not restrict file modifications by available operations."},{"name":"approval:policy","text":"Approval prompts are disabled in this session: actions that require approval are rejected automatically — do not request sandbox escalation (do not set `sandbox_permissions`)."},{"name":"subagent:identity","text":"You are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names."}]},"role":"user","id":"{{sessionId}}"},"surfaceOp":"append"}
{"type":"request/header","data":{"header":{"config":{"provider":"cli-mock","model":"cli-mock","reasoningEffort":"high"},"adapterDefaults":{"reasoningEffort":true},"tools":"{{tools}}"},"reason":"initial"}}
diff --git a/apps/cli/tests/profiles/headless/tests/expected/invalid-credential/stream-json.expected.jsonl b/apps/cli/tests/profiles/headless/tests/expected/invalid-credential/stream-json.expected.jsonl
index fed2009d5a..01d4a40124 100644
--- a/apps/cli/tests/profiles/headless/tests/expected/invalid-credential/stream-json.expected.jsonl
+++ b/apps/cli/tests/profiles/headless/tests/expected/invalid-credential/stream-json.expected.jsonl
@@ -2,7 +2,7 @@
{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"turn/start","seq":4,"time":0,"data":{"turn":1}}}
{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"agent/inbox/spliced","seq":5,"time":0,"data":{"target":"next-turn","start":0,"removedCount":1,"inserted":[]}}}
{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"step/start","seq":6,"time":0,"data":{"turn":1,"step":1}}}
-{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"system/message","seq":7,"time":0,"data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tool:bash","order":1000,"state":"active","contentIndex":2},{"name":"tool:read","order":1100,"state":"active","contentIndex":3},{"name":"tool:write","order":1200,"state":"active","contentIndex":4},{"name":"tool:edit","order":1300,"state":"active","contentIndex":5},{"name":"tool:glob","order":1400,"state":"active","contentIndex":6},{"name":"tool:grep","order":1500,"state":"active","contentIndex":7},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":8},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":9},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":10},{"name":"tool:goal","order":2400,"state":"active","contentIndex":11},{"name":"tool:workflow","order":2600,"state":"active","contentIndex":12},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":13}]},"id":"{{sessionId}}"}},"surfaceOp":"append"}}
+{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"system/message","seq":7,"time":0,"data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tool:bash","order":1000,"state":"active","contentIndex":2},{"name":"tool:read","order":1100,"state":"active","contentIndex":3},{"name":"tool:write","order":1200,"state":"active","contentIndex":4},{"name":"tool:edit","order":1300,"state":"active","contentIndex":5},{"name":"tool:apply_patch","order":1350,"state":"active","contentIndex":6},{"name":"tool:glob","order":1400,"state":"active","contentIndex":7},{"name":"tool:grep","order":1500,"state":"active","contentIndex":8},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":9},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":10},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":11},{"name":"tool:goal","order":2400,"state":"active","contentIndex":12},{"name":"tool:workflow","order":2600,"state":"active","contentIndex":13},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":14}]},"id":"{{sessionId}}"}},"surfaceOp":"append"}}
{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"user/message","seq":8,"time":0,"data":{"content":[{"type":"text","text":"say pong"}],"source":{"kind":"user"},"role":"user","id":"{{sessionId}}"},"surfaceOp":"append"}}
{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"user/message","seq":9,"time":0,"data":{"content":[{"type":"text","text":"\nThe following information describes your current session:\n\nCurrent working directory: \"{{cwd}}\".\n\nCurrent DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}\". Some platform temporary areas may also be writable.\n\nApproval prompts are enabled in this session: operations that require approval may ask through the configured answerers; without an available answerer, the request fails closed.\n\nYou are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names.\n"}],"source":{"kind":"runtime-context","form":"snapshot","sections":[{"name":"working-directory:current","text":"Current working directory: \"{{cwd}}\"."},{"name":"sandbox:policy","text":"Current DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}\". Some platform temporary areas may also be writable."},{"name":"approval:policy","text":"Approval prompts are enabled in this session: operations that require approval may ask through the configured answerers; without an available answerer, the request fails closed."},{"name":"subagent:identity","text":"You are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names."}]},"role":"user","id":"{{sessionId}}"},"surfaceOp":"append"}}
{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"request/header","seq":10,"time":0,"data":{"header":{"config":{"provider":"deepseek-official","model":"deepseek-v4-flash","maxTokens":256000,"reasoningEffort":"high"},"adapterDefaults":{"reasoningEffort":true,"maxTokens":true},"tools":"{{tools}}"},"reason":"initial"}}}
diff --git a/apps/cli/tests/profiles/headless/tests/expected/missing-credential/stream-json.expected.jsonl b/apps/cli/tests/profiles/headless/tests/expected/missing-credential/stream-json.expected.jsonl
index 6f88d55b40..c1f6c94a10 100644
--- a/apps/cli/tests/profiles/headless/tests/expected/missing-credential/stream-json.expected.jsonl
+++ b/apps/cli/tests/profiles/headless/tests/expected/missing-credential/stream-json.expected.jsonl
@@ -2,7 +2,7 @@
{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"turn/start","seq":4,"time":0,"data":{"turn":1}}}
{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"agent/inbox/spliced","seq":5,"time":0,"data":{"target":"next-turn","start":0,"removedCount":1,"inserted":[]}}}
{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"step/start","seq":6,"time":0,"data":{"turn":1,"step":1}}}
-{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"system/message","seq":7,"time":0,"data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tool:bash","order":1000,"state":"active","contentIndex":2},{"name":"tool:read","order":1100,"state":"active","contentIndex":3},{"name":"tool:write","order":1200,"state":"active","contentIndex":4},{"name":"tool:edit","order":1300,"state":"active","contentIndex":5},{"name":"tool:glob","order":1400,"state":"active","contentIndex":6},{"name":"tool:grep","order":1500,"state":"active","contentIndex":7},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":8},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":9},{"name":"tool:goal","order":2400,"state":"active","contentIndex":10},{"name":"tool:workflow","order":2600,"state":"active","contentIndex":11},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":12}]},"id":"{{sessionId}}"}},"surfaceOp":"append"}}
+{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"system/message","seq":7,"time":0,"data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tool:bash","order":1000,"state":"active","contentIndex":2},{"name":"tool:read","order":1100,"state":"active","contentIndex":3},{"name":"tool:write","order":1200,"state":"active","contentIndex":4},{"name":"tool:edit","order":1300,"state":"active","contentIndex":5},{"name":"tool:apply_patch","order":1350,"state":"active","contentIndex":6},{"name":"tool:glob","order":1400,"state":"active","contentIndex":7},{"name":"tool:grep","order":1500,"state":"active","contentIndex":8},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":9},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":10},{"name":"tool:goal","order":2400,"state":"active","contentIndex":11},{"name":"tool:workflow","order":2600,"state":"active","contentIndex":12},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":13}]},"id":"{{sessionId}}"}},"surfaceOp":"append"}}
{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"user/message","seq":8,"time":0,"data":{"content":[{"type":"text","text":"say pong"}],"source":{"kind":"user"},"role":"user","id":"{{sessionId}}"},"surfaceOp":"append"}}
{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"user/message","seq":9,"time":0,"data":{"content":[{"type":"text","text":"\nThe following information describes your current session:\n\nCurrent working directory: \"{{cwd}}\".\n\nCurrent DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}\". Some platform temporary areas may also be writable.\n\nApproval prompts are enabled in this session: operations that require approval may ask through the configured answerers; without an available answerer, the request fails closed.\n\nYou are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names.\n"}],"source":{"kind":"runtime-context","form":"snapshot","sections":[{"name":"working-directory:current","text":"Current working directory: \"{{cwd}}\"."},{"name":"sandbox:policy","text":"Current DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}\". Some platform temporary areas may also be writable."},{"name":"approval:policy","text":"Approval prompts are enabled in this session: operations that require approval may ask through the configured answerers; without an available answerer, the request fails closed."},{"name":"subagent:identity","text":"You are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names."}]},"role":"user","id":"{{sessionId}}"},"surfaceOp":"append"}}
{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"request/header","seq":10,"time":0,"data":{"header":{"config":{"provider":"deepseek-official","model":"deepseek-v4-flash","maxTokens":256000,"reasoningEffort":"high"},"adapterDefaults":{"reasoningEffort":true,"maxTokens":true},"tools":"{{tools}}"},"reason":"initial"}}}
diff --git a/apps/cli/tests/profiles/headless/tests/expected/provider-retry/stream-json.expected.jsonl b/apps/cli/tests/profiles/headless/tests/expected/provider-retry/stream-json.expected.jsonl
index c1036bf21b..3be8ff4b79 100644
--- a/apps/cli/tests/profiles/headless/tests/expected/provider-retry/stream-json.expected.jsonl
+++ b/apps/cli/tests/profiles/headless/tests/expected/provider-retry/stream-json.expected.jsonl
@@ -2,7 +2,7 @@
{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"turn/start","seq":4,"time":0,"data":{"turn":1}}}
{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"agent/inbox/spliced","seq":5,"time":0,"data":{"target":"next-turn","start":0,"removedCount":1,"inserted":[]}}}
{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"step/start","seq":6,"time":0,"data":{"turn":1,"step":1}}}
-{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"system/message","seq":7,"time":0,"data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tool:bash","order":1000,"state":"active","contentIndex":2},{"name":"tool:read","order":1100,"state":"active","contentIndex":3},{"name":"tool:write","order":1200,"state":"active","contentIndex":4},{"name":"tool:edit","order":1300,"state":"active","contentIndex":5},{"name":"tool:glob","order":1400,"state":"active","contentIndex":6},{"name":"tool:grep","order":1500,"state":"active","contentIndex":7},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":8},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":9},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":10},{"name":"tool:goal","order":2400,"state":"active","contentIndex":11},{"name":"tool:workflow","order":2600,"state":"active","contentIndex":12},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":13}]},"id":"{{sessionId}}"}},"surfaceOp":"append"}}
+{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"system/message","seq":7,"time":0,"data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tool:bash","order":1000,"state":"active","contentIndex":2},{"name":"tool:read","order":1100,"state":"active","contentIndex":3},{"name":"tool:write","order":1200,"state":"active","contentIndex":4},{"name":"tool:edit","order":1300,"state":"active","contentIndex":5},{"name":"tool:apply_patch","order":1350,"state":"active","contentIndex":6},{"name":"tool:glob","order":1400,"state":"active","contentIndex":7},{"name":"tool:grep","order":1500,"state":"active","contentIndex":8},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":9},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":10},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":11},{"name":"tool:goal","order":2400,"state":"active","contentIndex":12},{"name":"tool:workflow","order":2600,"state":"active","contentIndex":13},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":14}]},"id":"{{sessionId}}"}},"surfaceOp":"append"}}
{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"user/message","seq":8,"time":0,"data":{"content":[{"type":"text","text":"retry the transient provider failure"}],"source":{"kind":"user"},"role":"user","id":"{{sessionId}}"},"surfaceOp":"append"}}
{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"user/message","seq":9,"time":0,"data":{"content":[{"type":"text","text":"\nThe following information describes your current session:\n\nCurrent working directory: \"{{cwd}}\".\n\nCurrent DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}\". Some platform temporary areas may also be writable.\n\nApproval prompts are enabled in this session: operations that require approval may ask through the configured answerers; without an available answerer, the request fails closed.\n\nYou are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names.\n"}],"source":{"kind":"runtime-context","form":"snapshot","sections":[{"name":"working-directory:current","text":"Current working directory: \"{{cwd}}\"."},{"name":"sandbox:policy","text":"Current DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}\". Some platform temporary areas may also be writable."},{"name":"approval:policy","text":"Approval prompts are enabled in this session: operations that require approval may ask through the configured answerers; without an available answerer, the request fails closed."},{"name":"subagent:identity","text":"You are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names."}]},"role":"user","id":"{{sessionId}}"},"surfaceOp":"append"}}
{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"request/header","seq":10,"time":0,"data":{"header":{"config":{"provider":"deepseek-official","model":"deepseek-v4-flash"},"tools":"{{tools}}"},"reason":"initial"}}}
diff --git a/apps/cli/tests/profiles/headless/tests/expected/semantic-checkpoint/session.expected.jsonl b/apps/cli/tests/profiles/headless/tests/expected/semantic-checkpoint/session.expected.jsonl
index 3bb2761bf5..2a440215c3 100644
--- a/apps/cli/tests/profiles/headless/tests/expected/semantic-checkpoint/session.expected.jsonl
+++ b/apps/cli/tests/profiles/headless/tests/expected/semantic-checkpoint/session.expected.jsonl
@@ -16,7 +16,7 @@
{"type":"turn/start","data":{"turn":2}}
{"type":"agent/inbox/spliced","data":{"target":"next-turn","start":0,"removedCount":1,"inserted":[]}}
{"type":"step/start","data":{"turn":2,"step":1}}
-{"type":"system/message","data":{"turn":2,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tool:bash","order":1000,"state":"active","contentIndex":2},{"name":"tool:read","order":1100,"state":"active","contentIndex":3},{"name":"tool:write","order":1200,"state":"active","contentIndex":4},{"name":"tool:edit","order":1300,"state":"active","contentIndex":5},{"name":"tool:glob","order":1400,"state":"active","contentIndex":6},{"name":"tool:grep","order":1500,"state":"active","contentIndex":7},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":8},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":9},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":10},{"name":"tool:goal","order":2400,"state":"active","contentIndex":11},{"name":"tool:workflow","order":2600,"state":"active","contentIndex":12},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":13}],"reset":true},"id":"{{sessionId}}"}},"sourceEventSeqs":[2],"surfaceOp":{"op":"replace","startSeq":2,"endSeq":2}}
+{"type":"system/message","data":{"turn":2,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tool:bash","order":1000,"state":"active","contentIndex":2},{"name":"tool:read","order":1100,"state":"active","contentIndex":3},{"name":"tool:write","order":1200,"state":"active","contentIndex":4},{"name":"tool:edit","order":1300,"state":"active","contentIndex":5},{"name":"tool:apply_patch","order":1350,"state":"active","contentIndex":6},{"name":"tool:glob","order":1400,"state":"active","contentIndex":7},{"name":"tool:grep","order":1500,"state":"active","contentIndex":8},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":9},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":10},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":11},{"name":"tool:goal","order":2400,"state":"active","contentIndex":12},{"name":"tool:workflow","order":2600,"state":"active","contentIndex":13},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":14}],"reset":true},"id":"{{sessionId}}"}},"sourceEventSeqs":[2],"surfaceOp":{"op":"replace","startSeq":2,"endSeq":2}}
{"type":"user/message","data":{"content":[{"type":"text","text":"Continue safely from the interrupted operation."}],"source":{"kind":"user"},"role":"user","id":"{{sessionId}}"},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"\nThe following information describes your current session:\n\nCurrent working directory: \"{{cwd}}\".\n\nCurrent DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}\". Some platform temporary areas may also be writable.\n\nApproval prompts are enabled in this session: operations that require approval may ask through the configured answerers; without an available answerer, the request fails closed.\n\nYou are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names.\n"}],"source":{"kind":"runtime-context","form":"snapshot","sections":[{"name":"working-directory:current","text":"Current working directory: \"{{cwd}}\"."},{"name":"sandbox:policy","text":"Current DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}\". Some platform temporary areas may also be writable."},{"name":"approval:policy","text":"Approval prompts are enabled in this session: operations that require approval may ask through the configured answerers; without an available answerer, the request fails closed."},{"name":"subagent:identity","text":"You are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names."}]},"role":"user","id":"{{sessionId}}"},"surfaceOp":"append"}
{"type":"request/header","data":{"header":{"config":{"provider":"deepseek-official","model":"deepseek-v4-flash"},"tools":"{{tools}}"},"reason":"initial","startsSeries":true}}
diff --git a/apps/cli/tests/profiles/headless/tests/expected/subagent-diagnostic/parent.expected.jsonl b/apps/cli/tests/profiles/headless/tests/expected/subagent-diagnostic/parent.expected.jsonl
index 17334f9fcc..832b4bc718 100644
--- a/apps/cli/tests/profiles/headless/tests/expected/subagent-diagnostic/parent.expected.jsonl
+++ b/apps/cli/tests/profiles/headless/tests/expected/subagent-diagnostic/parent.expected.jsonl
@@ -14,7 +14,7 @@
{"type":"turn/start","data":{"turn":2}}
{"type":"agent/inbox/spliced","data":{"target":"next-turn","start":0,"removedCount":1,"inserted":[]}}
{"type":"step/start","data":{"turn":2,"step":1}}
-{"type":"system/message","data":{"turn":2,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tool:bash","order":1000,"state":"active","contentIndex":2},{"name":"tool:read","order":1100,"state":"active","contentIndex":3},{"name":"tool:write","order":1200,"state":"active","contentIndex":4},{"name":"tool:edit","order":1300,"state":"active","contentIndex":5},{"name":"tool:glob","order":1400,"state":"active","contentIndex":6},{"name":"tool:grep","order":1500,"state":"active","contentIndex":7},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":8},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":9},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":10},{"name":"tool:goal","order":2400,"state":"active","contentIndex":11},{"name":"tool:workflow","order":2600,"state":"active","contentIndex":12},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":13}],"reset":true},"id":"{{sessionId}}"}},"sourceEventSeqs":[2],"surfaceOp":{"op":"replace","startSeq":2,"endSeq":2}}
+{"type":"system/message","data":{"turn":2,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tool:bash","order":1000,"state":"active","contentIndex":2},{"name":"tool:read","order":1100,"state":"active","contentIndex":3},{"name":"tool:write","order":1200,"state":"active","contentIndex":4},{"name":"tool:edit","order":1300,"state":"active","contentIndex":5},{"name":"tool:apply_patch","order":1350,"state":"active","contentIndex":6},{"name":"tool:glob","order":1400,"state":"active","contentIndex":7},{"name":"tool:grep","order":1500,"state":"active","contentIndex":8},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":9},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":10},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":11},{"name":"tool:goal","order":2400,"state":"active","contentIndex":12},{"name":"tool:workflow","order":2600,"state":"active","contentIndex":13},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":14}],"reset":true},"id":"{{sessionId}}"}},"sourceEventSeqs":[2],"surfaceOp":{"op":"replace","startSeq":2,"endSeq":2}}
{"type":"user/message","data":{"content":[{"type":"text","text":"Call list_agents once and report what it shows."}],"source":{"kind":"user"},"role":"user","id":"{{sessionId}}"},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"\nThe following information describes your current session:\n\nCurrent working directory: \"{{cwd}}\".\n\nCurrent DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}\". Some platform temporary areas may also be writable.\n\nApproval prompts are enabled in this session: operations that require approval may ask through the configured answerers; without an available answerer, the request fails closed.\n\nYou are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names.\n"}],"source":{"kind":"runtime-context","form":"snapshot","sections":[{"name":"working-directory:current","text":"Current working directory: \"{{cwd}}\"."},{"name":"sandbox:policy","text":"Current DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}\". Some platform temporary areas may also be writable."},{"name":"approval:policy","text":"Approval prompts are enabled in this session: operations that require approval may ask through the configured answerers; without an available answerer, the request fails closed."},{"name":"subagent:identity","text":"You are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names."}]},"role":"user","id":"{{sessionId}}"},"surfaceOp":"append"}
{"type":"request/header","data":{"header":{"config":{"provider":"deepseek-official","model":"deepseek-v4-flash"},"tools":"{{tools}}"},"reason":"initial","startsSeries":true}}
diff --git a/apps/cli/tests/profiles/headless/tests/expected/subagent-settlement/child.expected.jsonl b/apps/cli/tests/profiles/headless/tests/expected/subagent-settlement/child.expected.jsonl
index 088fdda2ee..e55f97126e 100644
--- a/apps/cli/tests/profiles/headless/tests/expected/subagent-settlement/child.expected.jsonl
+++ b/apps/cli/tests/profiles/headless/tests/expected/subagent-settlement/child.expected.jsonl
@@ -6,7 +6,7 @@
{"type":"turn/start","data":{"turn":1}}
{"type":"agent/inbox/spliced","data":{"target":"next-turn","start":0,"removedCount":1,"inserted":[]}}
{"type":"step/start","data":{"turn":1,"step":1}}
-{"type":"system/message","data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tool:bash","order":1000,"state":"active","contentIndex":2},{"name":"tool:read","order":1100,"state":"active","contentIndex":3},{"name":"tool:write","order":1200,"state":"active","contentIndex":4},{"name":"tool:edit","order":1300,"state":"active","contentIndex":5},{"name":"tool:glob","order":1400,"state":"active","contentIndex":6},{"name":"tool:grep","order":1500,"state":"active","contentIndex":7},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":8},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":9},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":10},{"name":"tool:goal","order":2400,"state":"active","contentIndex":11},{"name":"tool:workflow","order":2600,"state":"active","contentIndex":12},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":13}]},"id":"{{sessionId}}"}},"surfaceOp":"append"}
+{"type":"system/message","data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tool:bash","order":1000,"state":"active","contentIndex":2},{"name":"tool:read","order":1100,"state":"active","contentIndex":3},{"name":"tool:write","order":1200,"state":"active","contentIndex":4},{"name":"tool:edit","order":1300,"state":"active","contentIndex":5},{"name":"tool:apply_patch","order":1350,"state":"active","contentIndex":6},{"name":"tool:glob","order":1400,"state":"active","contentIndex":7},{"name":"tool:grep","order":1500,"state":"active","contentIndex":8},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":9},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":10},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":11},{"name":"tool:goal","order":2400,"state":"active","contentIndex":12},{"name":"tool:workflow","order":2600,"state":"active","contentIndex":13},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":14}]},"id":"{{sessionId}}"}},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"Agent lead sent a message: "},{"type":"text","text":"Reply with exactly CHILD_RESULT and nothing else. Do not call send_message."},{"type":"text","text":"Your final answer is delivered automatically if your parent is still online. Include the result and relevant evidence in that answer; the parent does not receive your full transcript, tool output, or reasoning. If your last action is a message to your parent, the completion notice omits your final answer; include the result and relevant evidence in that message."}],"source":{"kind":"agent-message","form":"relay","senderSessionId":"{{sessionId}}"},"role":"user","id":"{{sessionId}}"},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"\nThe following information describes your current session:\n\nCurrent working directory: \"{{cwd}}\".\n\nCurrent DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}\". Some platform temporary areas may also be writable.\n\nApproval prompts are disabled in this session: actions that require approval are rejected automatically — do not request sandbox escalation (do not set `sandbox_permissions`).\n\nYou are a subagent delegated by agent \"lead\".\nYour name is \"agent-1\".\nThe root agent of your collaboration tree is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nWhen you finish, use send_message to send a self-contained result to the agent that delegated you. Message any agent as soon as a finding changes what it should do next; sending a message does not end your turn.\nUse list_agents({}) to find your collaborator agents and their names.\n\nDelegation depth for `subagent`: current 1, maximum 1, remaining levels 0. Do not call `subagent` at this depth; carry out the work directly.\n\nDelegation depth for `subagent_fork`: current 1, maximum 1, remaining levels 0. Do not call `subagent_fork` at this depth; carry out the work directly.\n\nYou are a delegated subagent: your permission scope was fixed when you were started and cannot be widened from inside this session — operations that require approval are rejected automatically. When the task needs access beyond that scope, do not retry the denied operation; state the limitation in your reply so the delegating agent can handle it. Messages from other agents begin with \"Agent sent a message:\". Other user messages come from the human user, who reads this conversation directly. You can still message other agents to coordinate, but answer the human user in your reply.\n"}],"source":{"kind":"runtime-context","form":"snapshot","sections":[{"name":"working-directory:current","text":"Current working directory: \"{{cwd}}\"."},{"name":"sandbox:policy","text":"Current DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}\". Some platform temporary areas may also be writable."},{"name":"approval:policy","text":"Approval prompts are disabled in this session: actions that require approval are rejected automatically — do not request sandbox escalation (do not set `sandbox_permissions`)."},{"name":"subagent:identity","text":"You are a subagent delegated by agent \"lead\".\nYour name is \"agent-1\".\nThe root agent of your collaboration tree is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nWhen you finish, use send_message to send a self-contained result to the agent that delegated you. Message any agent as soon as a finding changes what it should do next; sending a message does not end your turn.\nUse list_agents({}) to find your collaborator agents and their names."},{"name":"tool:subagent:depth","text":"Delegation depth for `subagent`: current 1, maximum 1, remaining levels 0. Do not call `subagent` at this depth; carry out the work directly."},{"name":"tool:subagent_fork:depth","text":"Delegation depth for `subagent_fork`: current 1, maximum 1, remaining levels 0. Do not call `subagent_fork` at this depth; carry out the work directly."},{"name":"subagent:delegation","text":"You are a delegated subagent: your permission scope was fixed when you were started and cannot be widened from inside this session — operations that require approval are rejected automatically. When the task needs access beyond that scope, do not retry the denied operation; state the limitation in your reply so the delegating agent can handle it. Messages from other agents begin with \"Agent sent a message:\". Other user messages come from the human user, who reads this conversation directly. You can still message other agents to coordinate, but answer the human user in your reply."}]},"role":"user","id":"{{sessionId}}"},"surfaceOp":"append"}
{"type":"request/header","data":{"header":{"config":{"provider":"deepseek-official","model":"deepseek-v4-flash"},"tools":"{{tools}}"},"reason":"initial"}}
diff --git a/apps/cli/tests/profiles/headless/tests/expected/subagent-settlement/stream-json.expected.jsonl b/apps/cli/tests/profiles/headless/tests/expected/subagent-settlement/stream-json.expected.jsonl
index 0e3f7f6c98..086b7d91a5 100644
--- a/apps/cli/tests/profiles/headless/tests/expected/subagent-settlement/stream-json.expected.jsonl
+++ b/apps/cli/tests/profiles/headless/tests/expected/subagent-settlement/stream-json.expected.jsonl
@@ -2,7 +2,7 @@
{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"turn/start","seq":4,"time":0,"data":{"turn":1}}}
{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"agent/inbox/spliced","seq":5,"time":0,"data":{"target":"next-turn","start":0,"removedCount":1,"inserted":[]}}}
{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"step/start","seq":6,"time":0,"data":{"turn":1,"step":1}}}
-{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"system/message","seq":7,"time":0,"data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tool:bash","order":1000,"state":"active","contentIndex":2},{"name":"tool:read","order":1100,"state":"active","contentIndex":3},{"name":"tool:write","order":1200,"state":"active","contentIndex":4},{"name":"tool:edit","order":1300,"state":"active","contentIndex":5},{"name":"tool:glob","order":1400,"state":"active","contentIndex":6},{"name":"tool:grep","order":1500,"state":"active","contentIndex":7},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":8},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":9},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":10},{"name":"tool:goal","order":2400,"state":"active","contentIndex":11},{"name":"tool:workflow","order":2600,"state":"active","contentIndex":12},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":13}]},"id":"{{sessionId}}"}},"surfaceOp":"append"}}
+{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"system/message","seq":7,"time":0,"data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tool:bash","order":1000,"state":"active","contentIndex":2},{"name":"tool:read","order":1100,"state":"active","contentIndex":3},{"name":"tool:write","order":1200,"state":"active","contentIndex":4},{"name":"tool:edit","order":1300,"state":"active","contentIndex":5},{"name":"tool:apply_patch","order":1350,"state":"active","contentIndex":6},{"name":"tool:glob","order":1400,"state":"active","contentIndex":7},{"name":"tool:grep","order":1500,"state":"active","contentIndex":8},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":9},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":10},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":11},{"name":"tool:goal","order":2400,"state":"active","contentIndex":12},{"name":"tool:workflow","order":2600,"state":"active","contentIndex":13},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":14}]},"id":"{{sessionId}}"}},"surfaceOp":"append"}}
{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"user/message","seq":8,"time":0,"data":{"content":[{"type":"text","text":"Start one continuable subagent and acknowledge its completion notice. Do not call list_agents or send_message."}],"source":{"kind":"user"},"role":"user","id":"{{sessionId}}"},"surfaceOp":"append"}}
{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"user/message","seq":9,"time":0,"data":{"content":[{"type":"text","text":"\nThe following information describes your current session:\n\nCurrent working directory: \"{{cwd}}\".\n\nCurrent DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}\". Some platform temporary areas may also be writable.\n\nApproval prompts are enabled in this session: operations that require approval may ask through the configured answerers; without an available answerer, the request fails closed.\n\nYou are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names.\n"}],"source":{"kind":"runtime-context","form":"snapshot","sections":[{"name":"working-directory:current","text":"Current working directory: \"{{cwd}}\"."},{"name":"sandbox:policy","text":"Current DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}\". Some platform temporary areas may also be writable."},{"name":"approval:policy","text":"Approval prompts are enabled in this session: operations that require approval may ask through the configured answerers; without an available answerer, the request fails closed."},{"name":"subagent:identity","text":"You are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names."}]},"role":"user","id":"{{sessionId}}"},"surfaceOp":"append"}}
{"type":"session_event","sessionId":"{{sessionId}}","event":{"type":"request/header","seq":10,"time":0,"data":{"header":{"config":{"provider":"deepseek-official","model":"deepseek-v4-flash"},"tools":"{{tools}}"},"reason":"initial"}}}
diff --git a/apps/cli/tests/profiles/headless/tests/expected/workspace-context-resume/offline-edit/session.expected.jsonl b/apps/cli/tests/profiles/headless/tests/expected/workspace-context-resume/offline-edit/session.expected.jsonl
index e0dc2020f1..52e8e44d96 100644
--- a/apps/cli/tests/profiles/headless/tests/expected/workspace-context-resume/offline-edit/session.expected.jsonl
+++ b/apps/cli/tests/profiles/headless/tests/expected/workspace-context-resume/offline-edit/session.expected.jsonl
@@ -14,7 +14,7 @@
{"type":"turn/start","data":{"turn":2}}
{"type":"agent/inbox/spliced","data":{"target":"next-turn","start":0,"removedCount":1,"inserted":[]}}
{"type":"step/start","data":{"turn":2,"step":1}}
-{"type":"system/message","data":{"turn":2,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tool:bash","order":1000,"state":"active","contentIndex":2},{"name":"tool:read","order":1100,"state":"active","contentIndex":3},{"name":"tool:write","order":1200,"state":"active","contentIndex":4},{"name":"tool:edit","order":1300,"state":"active","contentIndex":5},{"name":"tool:glob","order":1400,"state":"active","contentIndex":6},{"name":"tool:grep","order":1500,"state":"active","contentIndex":7},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":8},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":9},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":10},{"name":"tool:goal","order":2400,"state":"active","contentIndex":11},{"name":"tool:workflow","order":2600,"state":"active","contentIndex":12},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":13}],"reset":true},"id":"{{sessionId}}"}},"sourceEventSeqs":[2],"surfaceOp":{"op":"replace","startSeq":2,"endSeq":2}}
+{"type":"system/message","data":{"turn":2,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tool:bash","order":1000,"state":"active","contentIndex":2},{"name":"tool:read","order":1100,"state":"active","contentIndex":3},{"name":"tool:write","order":1200,"state":"active","contentIndex":4},{"name":"tool:edit","order":1300,"state":"active","contentIndex":5},{"name":"tool:apply_patch","order":1350,"state":"active","contentIndex":6},{"name":"tool:glob","order":1400,"state":"active","contentIndex":7},{"name":"tool:grep","order":1500,"state":"active","contentIndex":8},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":9},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":10},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":11},{"name":"tool:goal","order":2400,"state":"active","contentIndex":12},{"name":"tool:workflow","order":2600,"state":"active","contentIndex":13},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":14}],"reset":true},"id":"{{sessionId}}"}},"sourceEventSeqs":[2],"surfaceOp":{"op":"replace","startSeq":2,"endSeq":2}}
{"type":"user/message","data":{"content":[{"type":"text","text":"Acknowledge the current workspace instruction."}],"source":{"kind":"user"},"role":"user","id":"{{sessionId}}"},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"\nUpdated instructions from: AGENTS.md\n\nThis file changed after it was loaded. Use the following content instead of the previously loaded instructions from this file.\n\nNew workspace instruction after offline edit.\n\n"}],"source":{"kind":"agent-instructions","form":"instructions","changes":[{"action":"replace","scope":".\u0000AGENTS.md","path":"AGENTS.md","digest":"d8375b516f158718bd3463bc8eb7ed42c011b29f"}]},"role":"user","id":"{{sessionId}}"},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"\nThe following information describes your current session:\n\nCurrent working directory: \"{{cwd}}\".\n\nCurrent DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}\". Some platform temporary areas may also be writable.\n\nApproval prompts are enabled in this session: operations that require approval may ask through the configured answerers; without an available answerer, the request fails closed.\n\nYou are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names.\n"}],"source":{"kind":"runtime-context","form":"snapshot","sections":[{"name":"working-directory:current","text":"Current working directory: \"{{cwd}}\"."},{"name":"sandbox:policy","text":"Current DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}\". Some platform temporary areas may also be writable."},{"name":"approval:policy","text":"Approval prompts are enabled in this session: operations that require approval may ask through the configured answerers; without an available answerer, the request fails closed."},{"name":"subagent:identity","text":"You are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names."}]},"role":"user","id":"{{sessionId}}"},"surfaceOp":"append"}
diff --git a/apps/cli/tests/profiles/headless/tests/expected/workspace-context-resume/precedence-change/session.expected.jsonl b/apps/cli/tests/profiles/headless/tests/expected/workspace-context-resume/precedence-change/session.expected.jsonl
index 4e6bbdf69b..52bf412d0b 100644
--- a/apps/cli/tests/profiles/headless/tests/expected/workspace-context-resume/precedence-change/session.expected.jsonl
+++ b/apps/cli/tests/profiles/headless/tests/expected/workspace-context-resume/precedence-change/session.expected.jsonl
@@ -14,7 +14,7 @@
{"type":"turn/start","data":{"turn":2}}
{"type":"agent/inbox/spliced","data":{"target":"next-turn","start":0,"removedCount":1,"inserted":[]}}
{"type":"step/start","data":{"turn":2,"step":1}}
-{"type":"system/message","data":{"turn":2,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tool:bash","order":1000,"state":"active","contentIndex":2},{"name":"tool:read","order":1100,"state":"active","contentIndex":3},{"name":"tool:write","order":1200,"state":"active","contentIndex":4},{"name":"tool:edit","order":1300,"state":"active","contentIndex":5},{"name":"tool:glob","order":1400,"state":"active","contentIndex":6},{"name":"tool:grep","order":1500,"state":"active","contentIndex":7},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":8},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":9},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":10},{"name":"tool:goal","order":2400,"state":"active","contentIndex":11},{"name":"tool:workflow","order":2600,"state":"active","contentIndex":12},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":13}],"reset":true},"id":"{{sessionId}}"}},"sourceEventSeqs":[2],"surfaceOp":{"op":"replace","startSeq":2,"endSeq":2}}
+{"type":"system/message","data":{"turn":2,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tool:bash","order":1000,"state":"active","contentIndex":2},{"name":"tool:read","order":1100,"state":"active","contentIndex":3},{"name":"tool:write","order":1200,"state":"active","contentIndex":4},{"name":"tool:edit","order":1300,"state":"active","contentIndex":5},{"name":"tool:apply_patch","order":1350,"state":"active","contentIndex":6},{"name":"tool:glob","order":1400,"state":"active","contentIndex":7},{"name":"tool:grep","order":1500,"state":"active","contentIndex":8},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":9},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":10},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":11},{"name":"tool:goal","order":2400,"state":"active","contentIndex":12},{"name":"tool:workflow","order":2600,"state":"active","contentIndex":13},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":14}],"reset":true},"id":"{{sessionId}}"}},"sourceEventSeqs":[2],"surfaceOp":{"op":"replace","startSeq":2,"endSeq":2}}
{"type":"user/message","data":{"content":[{"type":"text","text":"Acknowledge the current workspace instruction."}],"source":{"kind":"user"},"role":"user","id":"{{sessionId}}"},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"\nThis complete workspace instruction baseline replaces all earlier workspace instruction baselines. The following workspace instructions may be relevant to your work. Use them as guidance when applicable. More specific instructions take precedence over broader ones. They do not override system, developer, or direct user instructions.\n\nInstructions from: AGENTS.md\n\nCurrent AGENTS rule.\n\n\nInstructions from: CLAUDE.md\n\nCurrent CLAUDE rule.\n\n"}],"source":{"kind":"agent-instructions","form":"instructions","baseline":true,"baselineIdentity":"{\"projectRoot\":\"\",\"projectRootMarkers\":[\".git\"],\"maxBytes\":65536,\"maxSourceBytes\":1048576,\"instructionFileCandidates\":[\"AGENTS.md\",\"CLAUDE.md\"],\"localInstructionFileCandidates\":[\"AGENTS.local.md\",\"CLAUDE.local.md\"]}","changes":[{"action":"set","scope":".\u0000AGENTS.md","path":"AGENTS.md","digest":"7f53d2327837129750aef117f9754a001c46cf68"},{"action":"set","scope":".\u0000CLAUDE.md","path":"CLAUDE.md","digest":"5b1e9e3fd759eee6b43ceff899e47fb10c64701a"}]},"role":"user","id":"{{sessionId}}"},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"\nThe following information describes your current session:\n\nCurrent working directory: \"{{cwd}}\".\n\nCurrent DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}\". Some platform temporary areas may also be writable.\n\nApproval prompts are enabled in this session: operations that require approval may ask through the configured answerers; without an available answerer, the request fails closed.\n\nYou are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names.\n"}],"source":{"kind":"runtime-context","form":"snapshot","sections":[{"name":"working-directory:current","text":"Current working directory: \"{{cwd}}\"."},{"name":"sandbox:policy","text":"Current DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}\". Some platform temporary areas may also be writable."},{"name":"approval:policy","text":"Approval prompts are enabled in this session: operations that require approval may ask through the configured answerers; without an available answerer, the request fails closed."},{"name":"subagent:identity","text":"You are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names."}]},"role":"user","id":"{{sessionId}}"},"surfaceOp":"append"}
diff --git a/apps/cli/tests/profiles/sdk/keyless-smoke.e2e.ts b/apps/cli/tests/profiles/sdk/keyless-smoke.e2e.ts
index 518e223dc3..b5bdcc1cd0 100644
--- a/apps/cli/tests/profiles/sdk/keyless-smoke.e2e.ts
+++ b/apps/cli/tests/profiles/sdk/keyless-smoke.e2e.ts
@@ -57,7 +57,6 @@ describe('Python SDK dsh profile keyless smoke', () => {
{ label: 'reports max-token turns with mapping enabled through env', envValue: 'true', editorEnabled: false },
{ label: 'reports max-token turns with mapping disabled through env', envValue: 'false', editorEnabled: false },
{ label: 'allows an explicit patch to enable str_replace_editor', envValue: undefined, editorEnabled: true },
- { label: 'allows an explicit patch to enable apply_patch', envValue: undefined, editorEnabled: false, patchEnabled: true },
{ label: 'uses the PTC executor overlay despite the retired environment selector', envValue: undefined, editorEnabled: false, ptc: true },
// The shipped sdk profile mounts no observation policy: an edit of a file the model never read lands on disk.
{ label: 'edits a file the model never read through the shipped profile', envValue: undefined, editorEnabled: false, unreadEdit: true },
@@ -65,14 +64,11 @@ describe('Python SDK dsh profile keyless smoke', () => {
const { envValue, editorEnabled } = scenario
const ptc = 'ptc' in scenario && scenario.ptc
const unreadEdit = 'unreadEdit' in scenario && scenario.unreadEdit
- const patchEnabled = 'patchEnabled' in scenario && scenario.patchEnabled
const root = await mkdtemp(join(tmpdir(), 'dsh-python-sdk-runtime-smoke-'))
const unreadFile = join(root, 'notes.txt')
if (unreadEdit) await writeFile(unreadFile, 'alpha\n')
const editorPatch = join(root, 'editor.patch.yml')
- const fsPatch = join(root, 'fs.patch.yml')
- if (patchEnabled) await writeFile(fsPatch, '- {id: tool-fs, config: {applyPatch: true}}\n')
if (editorEnabled) await writeFile(editorPatch, [
'- insert:',
' - id: tool-str-replace-editor',
@@ -107,7 +103,6 @@ describe('Python SDK dsh profile keyless smoke', () => {
'--profile',
'sdk',
...(editorEnabled ? ['--patch', editorPatch] : []),
- ...(patchEnabled ? ['--patch', fsPatch] : []),
...(ptc ? ['--patch', join(repoRoot, 'apps/cli/config/examples/ptc.yml')] : []),
], {
cwd: repoRoot,
@@ -194,16 +189,14 @@ describe('Python SDK dsh profile keyless smoke', () => {
const toolNames = tools.map(tool => tool.name)
expect(modelRequests[0]?.output_config).toEqual({ effort: 'max' })
expect(modelRequests[0]?.max_tokens).toBe(1234)
- const expectedTools = ['read', 'write', 'edit', 'web_fetch', 'web_search', 'subagent', 'subagent_fork',
+ const expectedTools = ['read', 'write', 'edit', 'apply_patch', 'web_fetch', 'web_search', 'subagent', 'subagent_fork',
'present', 'ask_user_question', 'schedule_create', 'schedule_edit', 'schedule_list', 'schedule_view', 'plugin_manager']
const requestText = JSON.stringify(modelRequests[0])
if (ptc) {
expect(toolNames).toEqual(['run_code'])
for (const tool of expectedTools) expect(requestText.includes(`${tool}:`), tool).toBe(true)
- expect(requestText.includes('apply_patch:')).toBe(false)
} else {
expect(toolNames).toEqual(expect.arrayContaining(expectedTools))
- expect(toolNames.includes('apply_patch')).toBe(patchEnabled)
expect(toolNames.includes('str_replace_editor')).toBe(editorEnabled)
expect(toolNames).not.toContain('list_subagent_models')
}
diff --git a/apps/cli/tests/web-agent-presets.e2e.ts b/apps/cli/tests/web-agent-presets.e2e.ts
index 0c451b4d85..473a89be4a 100644
--- a/apps/cli/tests/web-agent-presets.e2e.ts
+++ b/apps/cli/tests/web-agent-presets.e2e.ts
@@ -351,7 +351,7 @@ describe('the shipped Web composition', () => {
// excluded for the reason the TUI composition e2e excludes them — they
// depend on ripgrep being present on the machine.
expect(toolNames(ctx, handle.agent).filter(name => name !== 'glob' && name !== 'grep')).toEqual([
- 'ask_user_question', 'bash', 'cordis_inspect', 'create_goal', 'edit', 'exit_plan_mode',
+ 'apply_patch', 'ask_user_question', 'bash', 'cordis_inspect', 'create_goal', 'edit', 'exit_plan_mode',
'get_goal', 'job_kill', 'job_list', 'job_output', 'list_agents', 'list_subagent_models', 'office_convert', 'office_recalculate', 'office_render', 'plugin_manager', 'present', 'read', 'read_image',
'schedule_create', 'schedule_edit', 'schedule_list', 'schedule_view',
'send_message', 'skill',
@@ -707,6 +707,7 @@ describe('the shipped Web composition', () => {
expect(cordisPersona).toEqual(standardPersona.map(section => section.name === 'deployment:persona-prefix'
? { ...section, text: `${section.text} You help the user customize DeepSeek Harness itself.` }
: section))
+ expect(toolNames(ctx, handle.agent)).toContain('apply_patch')
const definition = composeEntries([webPatches('Creator persona')])
.find(row => row.id === 'preset-cordis')!.config as import('@deepseek-ai/dsh-agent-preset-registry').PresetDefinition
const unregister = await ctx.agentPresets.register({
@@ -753,6 +754,8 @@ describe('the shipped Web composition', () => {
const sdk = assembly.sections.find(section => section.name === 'tools:sdk')?.text ?? ''
expect(sdk).not.toContain('str_replace_editor')
expect(sdk).toContain('web_search')
+ expect(toolNames(ctx, coded.agent)).toContain('apply_patch')
+ expect(sdk).toContain('apply_patch')
// Like `standard`, PTC manages plugins when the Host provides an editable profile.
expect(toolNames(ctx, coded.agent)).toContain('plugin_manager')
expect(sdk).toContain('plugin_manager')
diff --git a/apps/web/tests/home-whale.e2e.ts b/apps/web/tests/home-whale.e2e.ts
index 6e0154acdd..6787910a81 100644
--- a/apps/web/tests/home-whale.e2e.ts
+++ b/apps/web/tests/home-whale.e2e.ts
@@ -153,6 +153,9 @@ describe('official home whale in the default web profile', () => {
hiddenFromAssistiveTech: node.getAttribute('aria-hidden'),
pointerEvents: getComputedStyle(node).pointerEvents,
nativeComposer: document.querySelectorAll('[data-composer-seat]').length,
+ scrollInChildrenOutlet: node.parentElement?.querySelector(
+ ':scope > [data-slot-children="conversation.hero.frame"] > [data-conversation-scroll]',
+ ) != null,
}))
expect(facts).toMatchInlineSnapshot(`
{
@@ -160,6 +163,7 @@ describe('official home whale in the default web profile', () => {
"hiddenFromAssistiveTech": "true",
"nativeComposer": 1,
"pointerEvents": "none",
+ "scrollInChildrenOutlet": true,
}
`)
expect(consoleState.pageErrors).toEqual([])
diff --git a/apps/web/tests/scaffold.ts b/apps/web/tests/scaffold.ts
index a2c5c61517..0626600cec 100644
--- a/apps/web/tests/scaffold.ts
+++ b/apps/web/tests/scaffold.ts
@@ -58,7 +58,6 @@ import {
type NormalizeContext,
} from '@deepseek-ai/dsh-session-snapshot'
import type { Profile, ProfileContext } from '@deepseek-ai/dsh-app-boot'
-import type { PresetDefinition } from '@deepseek-ai/dsh-agent-preset-registry'
import { dshHomePath } from '@deepseek-ai/dsh-home-paths'
import { LlmAdapter } from '@deepseek-ai/dsh-llm'
import type {
@@ -720,20 +719,6 @@ export async function launchWebScaffold(options: LaunchOptions = {}): Promise row.id === 'preset-standard')!.config as PresetDefinition
- overlayPatches.push({
- id: 'preset-standard',
- config: {
- ...config,
- plugins: config.plugins.map(plugin => plugin.id === 'tool-fs'
- ? { ...plugin, config: { ...plugin.config, applyPatch: true } }
- : plugin),
- },
- })
- }
-
// Live fields use a shared deployment layer; process-specific ports and roots stay in CLI overlays.
const formEntries = new Set(['agent-default-model', 'agent-preset-registry', 'llm-deepseek', 'llm-pi-ai',
'web', 'web-search-deepseek', 'web-deepseek-api', 'agent-loop', 'subagent', 'bash-sandbox', 'pwsh-sandbox',
diff --git a/apps/web/tests/shipped-composition.e2e.ts b/apps/web/tests/shipped-composition.e2e.ts
index 58c98ee574..23d350bef3 100644
--- a/apps/web/tests/shipped-composition.e2e.ts
+++ b/apps/web/tests/shipped-composition.e2e.ts
@@ -469,6 +469,7 @@ function assertLeanChildRecord(agent: Agent): void {
* MCP servers, and ralph are not enabled in this preset.
*/
const EXPECTED_TOOLS = [
+ 'apply_patch',
'ask_user_question',
'bash',
'cordis_inspect',
diff --git a/docs/config-catalog.md b/docs/config-catalog.md
index ac9c00f793..8aeb293881 100644
--- a/docs/config-catalog.md
+++ b/docs/config-catalog.md
@@ -4772,7 +4772,7 @@ export interface Config {
write?: boolean
/** Register `edit` and its guidance. Defaults to true. */
edit?: boolean
- /** Register `apply_patch` and its guidance beside `edit`. Defaults to false; shipped compositions set it on their `tool-fs` rows. */
+ /** Register `apply_patch` and its guidance. Defaults to the resolved `edit` value. */
applyPatch?: boolean
/** Default and maximum number of lines returned by one `read` call. */
readLimit?: number
diff --git a/docs/config-catalog.zh.md b/docs/config-catalog.zh.md
index d99ba15687..0d270f76dd 100644
--- a/docs/config-catalog.zh.md
+++ b/docs/config-catalog.zh.md
@@ -4774,7 +4774,7 @@ export interface Config {
write?: boolean
/** Register `edit` and its guidance. Defaults to true. */
edit?: boolean
- /** Register `apply_patch` and its guidance beside `edit`. Defaults to false; shipped compositions set it on their `tool-fs` rows. */
+ /** Register `apply_patch` and its guidance. Defaults to the resolved `edit` value. */
applyPatch?: boolean
/** Default and maximum number of lines returned by one `read` call. */
readLimit?: number
diff --git a/docs/subsystems/slots.i18n.yaml b/docs/subsystems/slots.i18n.yaml
index 632ae5542c..04c55b877a 100644
--- a/docs/subsystems/slots.i18n.yaml
+++ b/docs/subsystems/slots.i18n.yaml
@@ -12,8 +12,8 @@
en: 8ffb43e3e0d863d5
zh: 96f32d0047f784cb
/web-client-slots/cardinality-and-scope/hoc-layers:
- en: fa392c3a5c556751
- zh: f148ce2c56af3779
+ en: 8f817cccbbefb9fb
+ zh: a880d4a542a7ef82
/web-client-slots/component-inputs:
en: 278b2eee160be413
zh: d6e0fd1e9f4a4b27
diff --git a/docs/subsystems/slots.md b/docs/subsystems/slots.md
index 05710ee316..239430c71e 100644
--- a/docs/subsystems/slots.md
+++ b/docs/subsystems/slots.md
@@ -76,11 +76,28 @@ The slot declaration fixes two independent axes.
A hoc entry is a layer addressed by its required `id` and optional `key`. A layer without `key` is a wildcard that applies to every dispatch; a layer with `key` applies only when the owner passes the same `entryKey` to `renderSlot`, and an owner that omits `entryKey` gets only wildcard layers. Each `(key, id)` pair, with the wildcard as its own key, is one shadowing cell; within one `id`, an exact-key layer replaces the wildcard layer for that key.
-Layers nest by ascending `order`, then `priority`, then registration order, lowest outermost. Each layer receives the same owner props plus the next inner layer as `children`, the owner's content at the innermost, and renders it at most once; a layer that omits it replaces everything inside it. Owner props must not use the name `children`. Omitted `children` renders the layers around nothing, and with no applicable layer the content renders unchanged.
+Layers nest by ascending `order`, then `priority`, then registration order, lowest outermost. Every layer receives the same owner props. The renderer supplies the next inner layer as React `children`, or the owner's content at the innermost layer. The owner may omit its content without skipping the layers. Each layer may render `children` at most once. Owner props must not use the name `children`.
-- Remounting: adding or removing a layer that applies to a dispatch remounts the content inside it; a `session` or `session-maybe` layer also remounts it when its Session binding changes. Outlets that dispatch the same key share one compiled layer chain, so a registration for another key does not remount their content; an outlet that switches its `entryKey` switches chains and remounts its content even when the same layers apply.
-- Errors: a crashed layer reports its error and renders its `children` at the occurrence that failed, for the rest of that occurrence's mount even when its owner props change. The layer stays registered, so other occurrences, including those dispatching the same key, keep it, and a remounted occurrence renders it again. An error thrown by the wrapped content passes every layer and is reported against none; a layer that wraps its `children` in its own error boundary catches it as an internal wrapper error rather than the original.
-- Layout: the outlet inserts a `display: contents` `[data-slot]` element between the owner and its content, so owner selectors cannot rely on the content being a direct child. A layer that wraps its `children` must not create a box of its own unless its slot documents otherwise — for example, use `display: contents` — or the content leaves its parent's layout.
+The outer `[data-slot="key"]` marks the named slot's render position. With no applicable layer, the owner's content renders unchanged inside it, without a children outlet. Where a layer renders `children`, the renderer inserts one `[data-slot-children="key"]` outlet around the inner content, even when it is empty. Forwarding layers nest these outlets. A layer that omits `children` replaces everything inside it: neither its children outlet nor its inner content mounts.
+
+`data-slot-children` names the slot that supplied those `children` to the layer. Passing them through another slot preserves that name. All layers and all render occurrences of the same slot share the value; it does not identify a layer, plugin module, or dispatch `entryKey`.
+
+Suppose the owner passes a button to `outer.frame`. Its layer passes a React fragment containing its `children` followed by a second button to its declared hoc slot `inner.frame`. If the `inner.frame` layer returns its own `children` unchanged, the DOM is:
+
+```text
+[data-slot="outer.frame"]
+ [data-slot="inner.frame"]
+ [data-slot-children="inner.frame"]
+ [data-slot-children="outer.frame"]
+ button
+ button
+```
+
+Both buttons have `inner.frame` as their nearest `[data-slot]`, and `[data-slot-children] > button` matches both. Within the intended `outer.frame` instance, `[data-slot-children="outer.frame"] > button` matches only the owner's button; `[data-slot-children="inner.frame"] > button` matches only the button added by the `outer.frame` layer.
+
+- Remounting: adding or removing a layer that applies to a dispatch remounts the content inside it; a `session` or `session-maybe` layer also remounts it when its Session binding changes. Outlets of the same named slot that dispatch the same key share one compiled layer chain, so a registration for another key does not remount their content; an outlet that switches its `entryKey` switches chains and remounts its content even when the same layers apply.
+- Errors: a crashed layer reports its error and falls back to the same `children`, including its outlet, for the rest of that occurrence's mount even when its owner props change. The layer stays registered, so other occurrences, including those dispatching the same key, keep it, and a remounted occurrence renders it again. An error thrown by the wrapped content passes every layer and is reported against none; a layer that wraps its `children` in its own error boundary catches it as an internal wrapper error rather than the original.
+- Layout: both outlet elements are `div`s (`span`s for `inline: true`) with `display: contents`. They create no layout boxes, but child and sibling selectors still see them. Identify the outlets by their attributes, not by depth. A layer that wraps `children` must not create a box of its own unless its slot documents otherwise.
The [context-menu plugin](../../packages/client/ui-context-menu/README.md) contributes `useContextMenu` through `provideRoot`; every scope receives the same plugin-owned trigger factory. Its prop and retained handlers retire when the provider unloads. Its root-scoped keyed `contextMenu.icon` Slot renders business-owned icons from action metadata.
diff --git a/docs/subsystems/slots.zh.md b/docs/subsystems/slots.zh.md
index 8e1bf17ad5..44725db631 100644
--- a/docs/subsystems/slots.zh.md
+++ b/docs/subsystems/slots.zh.md
@@ -76,11 +76,28 @@ Slot 声明固定两个相互独立的维度。
hoc entry 是以必填 `id` 和可选 `key` 寻址的一层。不带 `key` 的层是通配层,作用于每次分派;带 `key` 的层只在 owner 向 `renderSlot` 传入相同 `entryKey` 时生效,省略 `entryKey` 的 owner 只得到通配层。每个 `(key, id)` 组合(通配视为单独的 key)是一个遮蔽 cell;同一 `id` 下,精确 key 的层替换该 key 的通配层。
-各层依次按 `order`、`priority`、注册顺序升序嵌套,最小者在最外层。每层收到同一份 owner props,并以 `children` 收到内一层(最内层是 owner 的内容),且至多渲染一次;不渲染 `children` 的层替换其内部的全部内容。owner props 不得使用 `children` 这个名字。省略 `children` 时各层包裹空内容;没有适用的层时原样渲染内容。
+各层依次按 `order`、`priority`、注册顺序升序嵌套,最小者在最外层。每层收到同一份 owner props。渲染器通过 React 的 `children` 传入下一层;最内层收到的是 owner 的内容。owner 可以省略内容,适用层仍会渲染。每层至多渲染一次 `children`。owner props 不得使用 `children` 这个名字。
-- 重新挂载:增减一个适用于本次分派的层会让其内部内容重新挂载;`session` 或 `session-maybe` 作用域的层在 Session binding 变化时也会让内部内容重新挂载。分派同一 key 的 outlet 共享一条编译好的层链,因此为其他 key 注册的层不会让它们的内容重新挂载;outlet 切换 `entryKey` 时会换到另一条层链,即使生效的层相同,内容也会重新挂载。
-- 错误:崩溃的层照常上报错误,并在出错的那一处渲染它的 `children`,直到该处本次挂载结束,owner props 变化也不恢复。该层保持注册,因此其他出现处(包括分派同一 key 的出现处)仍保留它,重新挂载的出现处会再次渲染它。被包裹内容抛出的错误穿过所有层,不记到任何层名下;层如果自己在 `children` 外包错误边界,捕获到的是内部包装错误而不是原始错误。
-- 布局:outlet 会在 owner 与内容之间插入一个 `display: contents` 的 `[data-slot]` 元素,所以 owner 侧的选择器不能假定内容是直接子元素。包裹 `children` 的层自身不得产生盒子(其 slot 另有说明的除外)——例如应使用 `display: contents`——否则内容会脱离父元素的布局。
+外层 `[data-slot="key"]` 标记 slot `key` 的渲染位置。没有适用层时,owner 的内容在其中原样渲染,不产生 `children` 出口。某层渲染 `children` 时,渲染器就在该位置用一个 `[data-slot-children="key"]` 出口包住内层内容,即使内容为空也会生成该出口。多层转发 `children` 时,这些出口相互嵌套。某层省略 `children` 即替换其内部的全部内容:该层的 `children` 出口和内层内容都不会挂载。
+
+`data-slot-children` 的值是向该层提供这份 `children` 的 slot 名。即使该层把 `children` 交给另一个 slot 渲染,这个值也不变。同一 slot 的各层和各次渲染实例都使用同一个值;它不标识层、插件模块或分派用的 `entryKey`。
+
+假设 owner 向 `outer.frame` 传入一个按钮。`outer.frame` 的层将自己的 `children` 和紧随其后的第二个按钮放在同一个 React Fragment 中,传给它声明的 hoc slot `inner.frame`。若 `inner.frame` 的层原样返回自己收到的 `children`,DOM 如下:
+
+```text
+[data-slot="outer.frame"]
+ [data-slot="inner.frame"]
+ [data-slot-children="inner.frame"]
+ [data-slot-children="outer.frame"]
+ button
+ button
+```
+
+两个按钮最近的 `[data-slot]` 都是 `inner.frame`,`[data-slot-children] > button` 也会同时选中两者。在目标 `outer.frame` 实例内,`[data-slot-children="outer.frame"] > button` 只选中 owner 传入的按钮;`[data-slot-children="inner.frame"] > button` 只选中 `outer.frame` 的层添加的按钮。
+
+- 重新挂载:增减一个适用于本次分派的层会让其内部内容重新挂载;`session` 或 `session-maybe` 作用域的层在 Session binding 变化时也会让内部内容重新挂载。同一具名 slot 中分派同一 key 的 outlet 共享一条编译好的层链,因此为其他 key 注册的层不会让它们的内容重新挂载;outlet 切换 `entryKey` 时会换到另一条层链,即使生效的层相同,内容也会重新挂载。
+- 错误:层自身崩溃时照常上报错误,出错处回退到同一份 `children`(含其出口),直到该处本次挂载结束,owner props 变化也不恢复。该层保持注册,因此其他出现处(包括分派同一 key 的出现处)仍保留它,重新挂载的出现处会再次渲染它。被包裹内容抛出的错误穿过所有层,不记到任何层名下;层如果自己在 `children` 外包错误边界,捕获到的是内部包装错误而不是原始错误。
+- 布局:两种出口都使用 `display: contents` 的 `div`(`inline: true` 时使用 `span`)。它们不产生布局盒,但仍参与子元素和兄弟元素选择器的匹配。应按属性识别出口,而非依赖嵌套深度。包裹 `children` 的层自身不得产生盒子,除非该 slot 另有说明。
diff --git a/docs/tool-catalog.i18n.yaml b/docs/tool-catalog.i18n.yaml
index 3cc55f7b70..c1b5ce735a 100644
--- a/docs/tool-catalog.i18n.yaml
+++ b/docs/tool-catalog.i18n.yaml
@@ -9,8 +9,8 @@
en: 6cc2cd9ced70bb09
zh: 1c0e6cb4ba2ed637
/tool-schema-catalog/tool-package-map:
- en: 8eb7039496b00847
- zh: 7d115fbbd23e2084
+ en: 92fe4be7a61af314
+ zh: 4d94aaab95817ae2
/tool-schema-catalog/deepseek-ai-dsh-tool-session-control:
en: 79ab575ea6da86e2
zh: 79ab575ea6da86e2
@@ -150,8 +150,8 @@
en: f6f7a1140066ce04
zh: d528e01a0939795a
/tool-schema-catalog/deepseek-ai-dsh-tool-fs/write:
- en: 22e7c232e157a1e2
- zh: 176da52cdd4765a9
+ en: 7f2a1de1e6796543
+ zh: c17622849cf3f47b
/tool-schema-catalog/deepseek-ai-dsh-tool-fs-search:
en: 703fea005ce84c50
zh: 703fea005ce84c50
diff --git a/docs/tool-catalog.md b/docs/tool-catalog.md
index b2efdb8375..a03f0f1672 100644
--- a/docs/tool-catalog.md
+++ b/docs/tool-catalog.md
@@ -31,7 +31,7 @@ This table connects model-visible tool names to the plugin package and service s
| `@deepseek-ai/dsh-tool-bash-persistent` | `bash` | `ctx.workingDirectory`, `ctx.tools`, `ctx.terminals`, `an owning Agent at execution time` | `tool/call`, `PTY shell state`, `tool/result` | - | One owner-isolated persistent bash tool; deployment composition supplies the PTY backend and may override the model-facing environment description. |
| `@deepseek-ai/dsh-tool-pwsh-persistent` | `pwsh` | `ctx.workingDirectory`, `ctx.tools`, `ctx.terminals`, `an owning Agent at execution time` | `tool/call`, `PTY shell state`, `tool/result` | - | One owner-isolated persistent pwsh tool, the Windows counterpart of the persistent bash tool; deployment composition supplies a pwsh-dialect PTY backend and may override the model-facing environment description. |
| `@deepseek-ai/dsh-tool-str-replace-editor` | `str_replace_editor` | `ctx.tools`, `ctx.fs` | `tool/call`, `fs/observed after view presence/absence, edit absence, or successful mutation`, `tool/result` | - | Standalone view/create/unique literal replace/line insert tool over the filesystem seam; it composes with any shell or terminal API. |
-| `@deepseek-ai/dsh-tool-fs` | `apply_patch`, `edit`, `read`, `read_image`, `write` | `ctx.workingDirectory`, `ctx.tools`, `ctx.fs`, `ctx.systemPrompt`, `ctx.attachments (image-tool registration)`, `ctx.llm + an image-capable route (image-tool execution)` | `tool/call`, `fs/write-intent, fs/edit-intent, or fs/delete-intent for mutations`, `fs/observed after read presence/absence or successful file operation`, `durable attachment (read_image)`, `tool/result` | - | The read-before-write/edit policy is added by `@deepseek-ai/dsh-fs-observation-policy` (an `fs/*` event-gate plugin, no schema change); the shipped compositions leave its row disabled, so mutations are unconditional unless a deployment enables it. The image tool is not registered without `ctx.attachments`; its schema is route-independent, and execution refuses unless the exact routed model declares image input. `apply_patch` registers only with `applyPatch: true`; the catalog sets it so the schema is documented. `dsh-base` and the Web `standard` preset enable it; the Web `ptc` and `cordis` presets and the PTC overlay state `applyPatch: false`. |
+| `@deepseek-ai/dsh-tool-fs` | `apply_patch`, `edit`, `read`, `read_image`, `write` | `ctx.workingDirectory`, `ctx.tools`, `ctx.fs`, `ctx.systemPrompt`, `ctx.attachments (image-tool registration)`, `ctx.llm + an image-capable route (image-tool execution)` | `tool/call`, `fs/write-intent, fs/edit-intent, or fs/delete-intent for mutations`, `fs/observed after read presence/absence or successful file operation`, `durable attachment (read_image)`, `tool/result` | - | The read-before-write/edit policy is added by `@deepseek-ai/dsh-fs-observation-policy` (an `fs/*` event-gate plugin, no schema change); the shipped compositions leave its row disabled, so mutations are unconditional unless a deployment enables it. The image tool is not registered without `ctx.attachments`; its schema is route-independent, and execution refuses unless the exact routed model declares image input. `apply_patch` registers when `applyPatch` resolves to true; unset, it follows `edit`, so every shipped composition that keeps `edit` offers it, including the Web `standard`, `ptc`, and `cordis` presets. |
| `@deepseek-ai/dsh-tool-fs-search` | `glob`, `grep` | `ctx.workingDirectory`, `ctx.tools`, `ctx.subprocess`, `ctx.systemPrompt` | `tool/call`, `tool/result` | - | glob and grep are unconditional discovery tools that spawn the packaged ripgrep binary (`@vscode/ripgrep`) through ctx.subprocess as ordinary foreground calls (never background jobs) — no host `rg` install and no shell layer. The catalog uses `sampleOverCapGlobResults: true`; deployments must choose that behavior explicitly. Capped results save the complete formatted list through the optional ctx.spillStore backend; returned locators are follow-up-readable/searchable when the backend exposes local paths in co-located deployments. |
| `@deepseek-ai/dsh-tool-terminal` | `terminal_close`, `terminal_list`, `terminal_open`, `terminal_read`, `terminal_send`, `terminal_signal` | `ctx.workingDirectory`, `ctx.tools`, `ctx.terminals`, `ctx.systemPrompt`, `ctx.jobs at call time for run_in_background` | `tool/call`, `tool/result` | - | The six terminal tools are opt-in and complement one-shot shell/filesystem tools. `terminal_send(run_in_background: true)` registers with `ctx.jobs`; TUI, named key sequences, BEL, resize, auto-start, and cross-agent sharing are absent from the schema. |
| `@deepseek-ai/dsh-terminal-panel` | `user_terminal_list`, `user_terminal_read` | `ctx.tools`, `ctx.systemPrompt`, `ctx.terminals`, `ctx.terminalController`, `ctx.sandboxPolicy`, `a calling Agent` | `tool/call`, `tool/result` | - | The package also serves the six `terminal_*` tools from Web sidebar terminals. `user_terminal_list` and `user_terminal_read` only read terminals the user controls; `readUserTerminals: false` removes both. |
@@ -1276,7 +1276,7 @@ Create or fully replace a UTF-8 text file.
Source: [`packages/fs/tool-fs/src/index.ts`](../packages/fs/tool-fs/src/index.ts)
-The read-before-write/edit policy is added by `@deepseek-ai/dsh-fs-observation-policy` (an `fs/*` event-gate plugin, no schema change); the shipped compositions leave its row disabled, so mutations are unconditional unless a deployment enables it. The image tool is not registered without `ctx.attachments`; its schema is route-independent, and execution refuses unless the exact routed model declares image input. `apply_patch` registers only with `applyPatch: true`; the catalog sets it so the schema is documented. `dsh-base` and the Web `standard` preset enable it; the Web `ptc` and `cordis` presets and the PTC overlay state `applyPatch: false`.
+The read-before-write/edit policy is added by `@deepseek-ai/dsh-fs-observation-policy` (an `fs/*` event-gate plugin, no schema change); the shipped compositions leave its row disabled, so mutations are unconditional unless a deployment enables it. The image tool is not registered without `ctx.attachments`; its schema is route-independent, and execution refuses unless the exact routed model declares image input. `apply_patch` registers when `applyPatch` resolves to true; unset, it follows `edit`, so every shipped composition that keeps `edit` offers it, including the Web `standard`, `ptc`, and `cordis` presets.
diff --git a/docs/tool-catalog.zh.md b/docs/tool-catalog.zh.md
index e41b6203b9..c91677b7b6 100644
--- a/docs/tool-catalog.zh.md
+++ b/docs/tool-catalog.zh.md
@@ -35,7 +35,7 @@
| `@deepseek-ai/dsh-tool-bash-persistent` | `bash` | `ctx.workingDirectory`、`ctx.tools`、`ctx.terminals`、`an owning Agent at execution time` | `tool/call`、`PTY shell state`、`tool/result` | - | 一个按所有者隔离的持久 bash 工具;部署组合提供 PTY 后端,并可覆盖面向模型的环境描述。 |
| `@deepseek-ai/dsh-tool-pwsh-persistent` | `pwsh` | `ctx.workingDirectory`、`ctx.tools`、`ctx.terminals`、`an owning Agent at execution time` | `tool/call`、`PTY shell state`、`tool/result` | - | 一个按所有者隔离的持久 pwsh 工具,持久 bash 工具的 Windows 对应物;部署组合提供 pwsh 方言的 PTY 后端,并可覆盖面向模型的环境描述。 |
| `@deepseek-ai/dsh-tool-str-replace-editor` | `str_replace_editor` | `ctx.tools`、`ctx.fs` | `tool/call`、`fs/observed after view presence/absence, edit absence, or successful mutation`、`tool/result` | - | 基于文件系统 seam 的独立查看/创建/唯一字面量替换/按行插入工具;可与任何 shell 或终端接口组合。 |
-| `@deepseek-ai/dsh-tool-fs` | `apply_patch`、`edit`、`read`、`read_image`、`write` | `ctx.workingDirectory`、`ctx.tools`、`ctx.fs`、`ctx.systemPrompt`、`ctx.attachments (image-tool registration)`、`ctx.llm + an image-capable route (image-tool execution)` | `tool/call`、`fs/write-intent, fs/edit-intent, or fs/delete-intent for mutations`、`fs/observed after read presence/absence or successful file operation`、`durable attachment (read_image)`、`tool/result` | - | 先读后写/编辑策略由 `@deepseek-ai/dsh-fs-observation-policy` 添加;它是一个 `fs/*` 事件门禁插件,不会改变 schema。随发行版交付的组合保持该行禁用,因此除非部署启用它,修改都是无条件的。没有 `ctx.attachments` 时图片工具不会注册;其 schema 与路由无关,执行时除非确切路由的模型声明图片输入,否则拒绝。`apply_patch` 仅在 `applyPatch: true` 时注册;目录为了记录其 schema 而开启该开关。`dsh-base` 与 Web 的 `standard` preset 开启它;Web 的 `ptc`、`cordis` preset 以及 PTC overlay 显式写出 `applyPatch: false`。 |
+| `@deepseek-ai/dsh-tool-fs` | `apply_patch`、`edit`、`read`、`read_image`、`write` | `ctx.workingDirectory`、`ctx.tools`、`ctx.fs`、`ctx.systemPrompt`、`ctx.attachments (image-tool registration)`、`ctx.llm + an image-capable route (image-tool execution)` | `tool/call`、`fs/write-intent, fs/edit-intent, or fs/delete-intent for mutations`、`fs/observed after read presence/absence or successful file operation`、`durable attachment (read_image)`、`tool/result` | - | 先读后写/编辑策略由 `@deepseek-ai/dsh-fs-observation-policy` 添加;它是一个 `fs/*` 事件门禁插件,不会改变 schema。随发行版交付的组合保持该行禁用,因此除非部署启用它,修改都是无条件的。没有 `ctx.attachments` 时图片工具不会注册;其 schema 与路由无关,执行时除非确切路由的模型声明图片输入,否则拒绝。`applyPatch` 解析为 true 时注册 `apply_patch`;未设置时它跟随 `edit`,因此每个保留 `edit` 的内置组合都提供它,包括 Web 的 `standard`、`ptc`、`cordis` preset。 |
| `@deepseek-ai/dsh-tool-fs-search` | `glob`、`grep` | `ctx.workingDirectory`、`ctx.tools`、`ctx.subprocess`、`ctx.systemPrompt` | `tool/call`、`tool/result` | - | glob 和 grep 是无条件可用的发现工具,通过 ctx.subprocess spawn 随包提供的 ripgrep 二进制文件(`@vscode/ripgrep`),并作为普通前台调用运行,绝不作为后台任务;无需在宿主机安装 `rg`,也不经过 shell 层。本目录使用 `sampleOverCapGlobResults: true`;部署必须显式选择该行为。结果超过上限时,会通过可选的 ctx.spillStore 后端保存完整的格式化列表;在共置部署中,如果后端公开本地路径,返回的定位信息可供后续读取/搜索。 |
| `@deepseek-ai/dsh-tool-terminal` | `terminal_close`、`terminal_list`、`terminal_open`、`terminal_read`、`terminal_send`、`terminal_signal` | `ctx.workingDirectory`、`ctx.tools`、`ctx.terminals`、`ctx.systemPrompt`、`ctx.jobs at call time for run_in_background` | `tool/call`、`tool/result` | - | 这 6 个终端工具需要选择启用,用于补充一次性 bash/文件系统工具。`terminal_send(run_in_background: true)` 会注册到 `ctx.jobs`;schema 不包含 TUI、具名按键序列、BEL、调整尺寸、自动启动和跨 agent 共享。 |
| `@deepseek-ai/dsh-terminal-panel` | `user_terminal_list`、`user_terminal_read` | `ctx.tools`、`ctx.systemPrompt`、`ctx.terminals`、`ctx.terminalController`、`ctx.sandboxPolicy`、`a calling Agent` | `tool/call`、`tool/result` | - | 本包还用 Web 侧栏终端承载 6 个 `terminal_*` 工具。`user_terminal_list` 和 `user_terminal_read` 只读取用户控制的终端;`readUserTerminals: false` 会移除这两个工具。 |
@@ -1282,7 +1282,7 @@ Desktop 标准模式、创造模式和 SDK profile 提供一个只读运行时
来源:[`packages/fs/tool-fs/src/index.ts`](../packages/fs/tool-fs/src/index.ts)
-先读后写/编辑策略由 `@deepseek-ai/dsh-fs-observation-policy` 添加;它是一个 `fs/*` 事件门禁插件,不会改变 schema。随发行版交付的组合保持该行禁用,因此除非部署启用它,修改都是无条件的。没有 `ctx.attachments` 时图片工具不会注册;其 schema 与路由无关,执行时除非确切路由的模型声明图片输入,否则拒绝。`apply_patch` 仅在 `applyPatch: true` 时注册;目录为了记录其 schema 而开启该开关。`dsh-base` 与 Web 的 `standard` preset 开启它;Web 的 `ptc`、`cordis` preset 以及 PTC overlay 显式写出 `applyPatch: false`。
+先读后写/编辑策略由 `@deepseek-ai/dsh-fs-observation-policy` 添加;它是一个 `fs/*` 事件门禁插件,不会改变 schema。随发行版交付的组合保持该行禁用,因此除非部署启用它,修改都是无条件的。没有 `ctx.attachments` 时图片工具不会注册;其 schema 与路由无关,执行时除非确切路由的模型声明图片输入,否则拒绝。`applyPatch` 解析为 true 时注册 `apply_patch`;未设置时它跟随 `edit`,因此每个保留 `edit` 的内置组合都提供它,包括 Web 的 `standard`、`ptc`、`cordis` preset。
diff --git a/docs/upgrade-guide/v0.2.3-alpha.2/apply-patch-default-on/guide.i18n.yaml b/docs/upgrade-guide/v0.2.3-alpha.2/apply-patch-default-on/guide.i18n.yaml
new file mode 100644
index 0000000000..c56a966a29
--- /dev/null
+++ b/docs/upgrade-guide/v0.2.3-alpha.2/apply-patch-default-on/guide.i18n.yaml
@@ -0,0 +1,16 @@
+# Bilingual-pair consistency record for guide.md (docs/i18n/README.md): per heading
+# section, a hash of its English and Chinese blocks outside code blocks and generated regions.
+# After editing either side, bring the other along and re-record with:
+# pnpm run verify-translation-pairing --write docs/upgrade-guide/v0.2.3-alpha.2/apply-patch-default-on/guide.md
+/:
+ en: 936ce660cce8d405
+ zh: 1e153f3cdc6bcc41
+/apply-patch-follows-edit-by-default:
+ en: fcec5f478a467dd8
+ zh: 40fdd006860a2282
+/apply-patch-follows-edit-by-default/change:
+ en: c797d1c635b604e8
+ zh: ae07ad16df8a8736
+/apply-patch-follows-edit-by-default/migration:
+ en: fc15427fc3d78fec
+ zh: 10af6b316e9a52f6
diff --git a/docs/upgrade-guide/v0.2.3-alpha.2/apply-patch-default-on/guide.md b/docs/upgrade-guide/v0.2.3-alpha.2/apply-patch-default-on/guide.md
new file mode 100644
index 0000000000..bdb3095845
--- /dev/null
+++ b/docs/upgrade-guide/v0.2.3-alpha.2/apply-patch-default-on/guide.md
@@ -0,0 +1,20 @@
+---
+kind: upgrade-guide
+description: "tool-fs.applyPatch now defaults to the edit value, so every tool-fs row that keeps edit and states no applyPatch offers apply_patch."
+---
+
+# `apply_patch` follows `edit` by default
+
+English | [中文](guide.zh.md)
+
+## Change
+
+In 0.2.3-alpha.2, `tool-fs.applyPatch` defaulted to `false`, the shipped `tool-fs` rows that set it stated `applyPatch: false`, and the [PTC overlay](../../../../apps/cli/config/examples/ptc.yml) set the same, so no default composition offered `apply_patch`. An unset `applyPatch` now takes the resolved `edit` value, and the shipped rows state no `applyPatch`: the model sees `apply_patch` and its guidance beside `edit`, as a JSON tool under native execution and as a `run_code` binding under PTC.
+
+Affected: the `headless`, `sdk`, and `acp` profiles with or without the PTC overlay, Web and Desktop sessions under the `standard`, `ptc`, or `cordis` preset, any profile patch, preset, or plugin that mounts `tool-fs` with `edit` enabled and no `applyPatch`, and recorded expectations that capture those tool sets. The Web `minimal` preset and `sdk-minimal` set `edit: false` and keep the tool off.
+
+## Migration
+
+1. To run without `apply_patch`, set `applyPatch: false` on the `tool-fs` row: add `- {id: tool-fs, config: {applyPatch: false}}` to the profile's `cordis.patch.yml` (`$DSH_HOME/profiles//cordis.patch.yml`) for `headless`, `sdk`, and `acp`; for a Web or Desktop preset, edit its `tool-fs` row from the Agent presets settings page; for a custom preset or plugin, add the key to its `tool-fs` declaration.
+2. A row that disables `edit` but needs `apply_patch` sets `applyPatch: true`.
+3. Confirm with `dsh --profile --dump-config` that each `tool-fs` row shows the intended `edit` value and any `applyPatch` you wrote; the dump omits the derived value, so check that the model request lists `apply_patch` only where expected.
diff --git a/docs/upgrade-guide/v0.2.3-alpha.2/apply-patch-default-on/guide.zh.md b/docs/upgrade-guide/v0.2.3-alpha.2/apply-patch-default-on/guide.zh.md
new file mode 100644
index 0000000000..b2a0a7c96c
--- /dev/null
+++ b/docs/upgrade-guide/v0.2.3-alpha.2/apply-patch-default-on/guide.zh.md
@@ -0,0 +1,20 @@
+---
+kind: upgrade-guide
+description: "tool-fs.applyPatch 现在默认取 edit 的值,因此每个保留 edit 且未写 applyPatch 的 tool-fs 行都会提供 apply_patch。"
+---
+
+# `apply_patch` 默认跟随 `edit`
+
+[English](guide.md) | 中文
+
+## 变更
+
+在 0.2.3-alpha.2 中,`tool-fs.applyPatch` 默认为 `false`,写了该键的内置 `tool-fs` 行都设置 `applyPatch: false`,[PTC overlay](../../../../apps/cli/config/examples/ptc.yml) 也设为同样的值,默认组合不提供 `apply_patch`。现在未设置的 `applyPatch` 取解析后的 `edit` 值,内置行也不再写 `applyPatch`:模型会在 `edit` 旁看到 `apply_patch` 及其指引,原生执行下是 JSON 工具,PTC 下是 `run_code` 绑定。
+
+受影响的有:叠加或未叠加 PTC overlay 的 `headless`、`sdk`、`acp` profile,使用 `standard`、`ptc` 或 `cordis` 预设的 Web 和 Desktop 会话,任何挂载 `tool-fs`、开启 `edit` 且未写 `applyPatch` 的 profile patch、预设或插件,以及记录这些工具集的录制预期。Web 的 `minimal` 预设和 `sdk-minimal` 设置了 `edit: false`,仍不提供该工具。
+
+## 迁移
+
+1. 如需不使用 `apply_patch`,在 `tool-fs` 行上设置 `applyPatch: false`:`headless`、`sdk`、`acp` 在 profile 的 `cordis.patch.yml`(`$DSH_HOME/profiles//cordis.patch.yml`)中加入 `- {id: tool-fs, config: {applyPatch: false}}`;Web 或 Desktop 预设在 Agent 预设设置页编辑它的 `tool-fs` 行;自定义预设或插件在其 `tool-fs` 声明中加入该键。
+2. 关闭 `edit` 但需要 `apply_patch` 的行,设置 `applyPatch: true`。
+3. 用 `dsh --profile --dump-config` 确认每个 `tool-fs` 行显示预期的 `edit` 值和你写出的 `applyPatch`;输出中不含推导出的值,因此再检查模型请求只在预期位置列出 `apply_patch`。
diff --git a/docs/upgrade-guide/v0.2.3-alpha.2/hoc-slot-children-outlet/guide.i18n.yaml b/docs/upgrade-guide/v0.2.3-alpha.2/hoc-slot-children-outlet/guide.i18n.yaml
new file mode 100644
index 0000000000..ee6455164e
--- /dev/null
+++ b/docs/upgrade-guide/v0.2.3-alpha.2/hoc-slot-children-outlet/guide.i18n.yaml
@@ -0,0 +1,16 @@
+# Bilingual-pair consistency record for guide.md (docs/i18n/README.md): per heading
+# section, a hash of its English and Chinese blocks outside code blocks and generated regions.
+# After editing either side, bring the other along and re-record with:
+# pnpm run verify-translation-pairing --write docs/upgrade-guide/v0.2.3-alpha.2/hoc-slot-children-outlet/guide.md
+/:
+ en: 269da5e847d9788e
+ zh: 9b554ae959a12bde
+/dom-selectors-for-hoc-slot-children:
+ en: 1d320414061c1ef6
+ zh: 407b8a1eda948d00
+/dom-selectors-for-hoc-slot-children/change:
+ en: 1e019f372693ff7c
+ zh: a0393e140a2b11a7
+/dom-selectors-for-hoc-slot-children/migration:
+ en: bde2d90bd9745036
+ zh: 47e8a1447506c72f
diff --git a/docs/upgrade-guide/v0.2.3-alpha.2/hoc-slot-children-outlet/guide.md b/docs/upgrade-guide/v0.2.3-alpha.2/hoc-slot-children-outlet/guide.md
new file mode 100644
index 0000000000..09f87088ab
--- /dev/null
+++ b/docs/upgrade-guide/v0.2.3-alpha.2/hoc-slot-children-outlet/guide.md
@@ -0,0 +1,19 @@
+---
+kind: upgrade-guide
+description: "A Web Client hoc layer's forwarded children now sit inside a DOM element, which changes direct-child and sibling selectors."
+---
+
+# DOM selectors for hoc slot children
+
+English | [中文](guide.zh.md)
+
+## Change
+
+In 0.2.3-alpha.2, the renderer inserted no DOM element where a `hoc` layer rendered `children`. After upgrading, it inserts one `[data-slot-children="key"]` element there, around the inner content. The value names the slot that supplied those `children` to the layer, even when another slot renders them. The element uses `display: contents`: it has no layout box but still participates in DOM queries and CSS selectors. The outer `[data-slot="key"]` stays in place. With no applicable layer, it still renders the owner's content without a children outlet. See [hoc layers](../../../subsystems/slots.md#hoc-layers).
+
+## Migration
+
+1. Check your plugin's stylesheets, DOM queries, and tests for direct-child (`>`) or sibling (`+`, `~`) selectors and traversal such as `firstElementChild` across a hoc layer. Slot registrations and React components that only render or replace `children` need no changes.
+2. Suppose an `outer.frame` layer forwards the owner's button and an extra button in one fragment through `inner.frame`. If the `inner.frame` layer returns `children` unchanged, both buttons match `[data-slot-children] > button`, and `closest('[data-slot]')` on either button finds `inner.frame`.
+3. Query within the `[data-slot="outer.frame"]` element for the intended instance. Use `[data-slot-children="outer.frame"] > button` for the owner's button and `[data-slot-children="inner.frame"] > button` for the extra button. To match the extra button as a sibling, use `[data-slot-children="outer.frame"] + button`: it follows the outlet, not the owner's button.
+4. Render two `outer.frame` instances and confirm each name-based selector matches only the intended button within the chosen instance. With no applicable `outer.frame` layer, the owner's button is a direct child of `[data-slot="outer.frame"]`; if a layer replaces `children`, expect the original button to be absent.
diff --git a/docs/upgrade-guide/v0.2.3-alpha.2/hoc-slot-children-outlet/guide.zh.md b/docs/upgrade-guide/v0.2.3-alpha.2/hoc-slot-children-outlet/guide.zh.md
new file mode 100644
index 0000000000..87944deabb
--- /dev/null
+++ b/docs/upgrade-guide/v0.2.3-alpha.2/hoc-slot-children-outlet/guide.zh.md
@@ -0,0 +1,19 @@
+---
+kind: upgrade-guide
+description: "Web Client 的 hoc 层转发的 children 现在位于一个 DOM 元素内,影响直接子元素与兄弟元素选择器。"
+---
+
+# hoc slot 的 children 与 DOM 选择器
+
+[English](guide.md) | 中文
+
+## 变更
+
+在 0.2.3-alpha.2 中,`hoc` 层渲染 `children` 时,渲染器不会在该位置添加 DOM 元素。升级后,渲染器会在该处用一个 `[data-slot-children="key"]` 元素包住内层内容。属性值是向该层提供这份 `children` 的 slot 名,即使最终由另一个 slot 渲染也不变。该元素使用 `display: contents`,没有布局盒,但仍参与 DOM 查询与 CSS 选择器的匹配。外层 `[data-slot="key"]` 的位置不变;没有适用层时,它仍原样渲染 owner 的内容,没有 `children` 出口。详见 [hoc 层](../../../subsystems/slots.zh.md#hoc-layers)。
+
+## 迁移
+
+1. 检查插件的样式表、DOM 查询与测试,找出跨越 hoc 层的直接子元素(`>`)、兄弟元素(`+`、`~`)选择器及 `firstElementChild` 等遍历操作。slot 注册、只渲染或替换 `children` 的 React 组件都无需改动。
+2. 假设 `outer.frame` 的一层把 owner 传入的按钮和额外添加的按钮放在同一个 Fragment 中,交给 `inner.frame` 转发。若 `inner.frame` 的层原样返回 `children`,`[data-slot-children] > button` 会选中两个按钮,在任一按钮上调用 `closest('[data-slot]')` 找到的也都是 `inner.frame`。
+3. 在目标实例的 `[data-slot="outer.frame"]` 元素内查询。用 `[data-slot-children="outer.frame"] > button` 选中 owner 传入的按钮,用 `[data-slot-children="inner.frame"] > button` 选中额外添加的按钮。若要用兄弟选择器匹配后者,应使用 `[data-slot-children="outer.frame"] + button`:它紧跟的是出口,而不是 owner 的按钮。
+4. 渲染两个 `outer.frame` 实例,确认按 slot 名筛选的选择器在目标实例内都只选中预期的按钮。`outer.frame` 没有适用层时,owner 的按钮是 `[data-slot="outer.frame"]` 的直接子元素;若某层替换 `children`,原始按钮应不存在。
diff --git a/packages/bundle/base/cordis.patch.yml b/packages/bundle/base/cordis.patch.yml
index 91e8a4f2b2..a06c99873a 100644
--- a/packages/bundle/base/cordis.patch.yml
+++ b/packages/bundle/base/cordis.patch.yml
@@ -305,9 +305,6 @@
- id: tool-fs
name: '@deepseek-ai/dsh-tool-fs'
- config:
- # Set false to drop the apply_patch tool beside edit.
- applyPatch: false
- id: tool-fs-search
name: '@deepseek-ai/dsh-tool-fs-search'
diff --git a/packages/bundle/web-app/presets/cordis.patch.yml b/packages/bundle/web-app/presets/cordis.patch.yml
index 53ea2c0722..2b2cf0aae1 100644
--- a/packages/bundle/web-app/presets/cordis.patch.yml
+++ b/packages/bundle/web-app/presets/cordis.patch.yml
@@ -29,9 +29,6 @@
disabled: !!js process.platform !== 'win32'
- id: tool-fs
name: '@deepseek-ai/dsh-tool-fs'
- config:
- # Set true to add the apply_patch tool beside edit.
- applyPatch: false
- id: tool-fs-search
name: '@deepseek-ai/dsh-tool-fs-search'
config:
diff --git a/packages/bundle/web-app/presets/ptc.patch.yml b/packages/bundle/web-app/presets/ptc.patch.yml
index 8de9ed6727..03a42a825f 100644
--- a/packages/bundle/web-app/presets/ptc.patch.yml
+++ b/packages/bundle/web-app/presets/ptc.patch.yml
@@ -26,9 +26,6 @@
disabled: !!js process.platform !== 'win32'
- id: tool-fs
name: '@deepseek-ai/dsh-tool-fs'
- config:
- # Set true to add the apply_patch tool beside edit.
- applyPatch: false
- id: tool-fs-search
name: '@deepseek-ai/dsh-tool-fs-search'
config:
diff --git a/packages/bundle/web-app/presets/standard.patch.yml b/packages/bundle/web-app/presets/standard.patch.yml
index b47e613917..25bfb3639c 100644
--- a/packages/bundle/web-app/presets/standard.patch.yml
+++ b/packages/bundle/web-app/presets/standard.patch.yml
@@ -26,9 +26,6 @@
disabled: !!js process.platform !== 'win32'
- id: tool-fs
name: '@deepseek-ai/dsh-tool-fs'
- config:
- # Set false to drop the apply_patch tool beside edit.
- applyPatch: false
- id: tool-fs-search
name: '@deepseek-ai/dsh-tool-fs-search'
config:
diff --git a/packages/client/ui-renderer/README.i18n.yaml b/packages/client/ui-renderer/README.i18n.yaml
index 70a83f68d2..2b643967b9 100644
--- a/packages/client/ui-renderer/README.i18n.yaml
+++ b/packages/client/ui-renderer/README.i18n.yaml
@@ -21,8 +21,8 @@
en: d6f0d5c795be936a
zh: dfbc8b6e1b7c646c
/deepseek-ai-dsh-client-ui-renderer/use-this-package/for-business-plugins:
- en: 15a2bfee2c0bd051
- zh: 0c5b336fc5afbbc6
+ en: d00b390265792c66
+ zh: c8fe2fe69ed5c88e
/deepseek-ai-dsh-client-ui-renderer/understand-the-implementation:
en: 0de0a8ad857b93f6
zh: 98a0fae2d6606a7d
diff --git a/packages/client/ui-renderer/README.md b/packages/client/ui-renderer/README.md
index dec8cc85ee..47c7701505 100644
--- a/packages/client/ui-renderer/README.md
+++ b/packages/client/ui-renderer/README.md
@@ -35,6 +35,8 @@ This package is infrastructure: the web shell and the boot kernel are its only d
A business plugin registers an ordinary Slot entry or a reusable Component Factory; the renderer binds the runtime's session and workspace observable sources into selector hooks at the render position. The plugin receives standard scope props through its derived Component props — it never imports the renderer or touches React internals. Every renderer-created Component can render a Factory occurrence, and a Factory can expose caller-selected local Components without sharing implementation values between packages.
+When a [hoc layer](../../../docs/subsystems/slots.md#hoc-layers) renders its React `children`, the renderer marks that position with `data-slot-children`. The plugin does not need to add its own wrapper or forward DOM attributes.
+
-----
diff --git a/packages/client/ui-renderer/README.zh.md b/packages/client/ui-renderer/README.zh.md
index 2a87fd1db2..12a40a4a18 100644
--- a/packages/client/ui-renderer/README.zh.md
+++ b/packages/client/ui-renderer/README.zh.md
@@ -35,6 +35,8 @@ kind: "package-reference"
业务插件注册普通 Slot entry 或可复用 Component Factory;渲染器在渲染位置把运行时的会话与 Workspace observable source 绑定为 selector 钩子。插件通过推导出的 Component props 收到标准 scope props——它绝不导入渲染器,也不触碰 React 内部机制。每个由 renderer 创建的 Component 都能渲染 Factory occurrence,Factory 也能暴露由调用方选择的局部 Component,而无需在包之间共享实现值。
+当 [hoc 层](../../../docs/subsystems/slots.zh.md#hoc-layers)渲染 React 的 `children` 时,渲染器会用 `data-slot-children` 标记该位置。插件不需要自己添加包装元素或转发 DOM 属性。
+
-----
diff --git a/packages/client/ui-renderer/src/client/scoped-slots.tsx b/packages/client/ui-renderer/src/client/scoped-slots.tsx
index 99d59ad9c7..e37c9c6d55 100644
--- a/packages/client/ui-renderer/src/client/scoped-slots.tsx
+++ b/packages/client/ui-renderer/src/client/scoped-slots.tsx
@@ -1133,8 +1133,14 @@ function hocLayer(
entry: StoredEntry,
renderInner: RenderHocInner,
): FC {
- const anchor: SlotAnchorTag = spec.inline === true ? 'span' : 'div'
+ const Anchor: SlotAnchorTag = spec.inline === true ? 'span' : 'div'
const slotInjected = cachedSlotInject(spec.inject)
+ // This slot supplies these children even if the layer forwards them through another slot.
+ const forwardChildren: RenderHocInner = (owner, children) => (
+
+ {renderInner(owner, children)}
+
+ )
// A layer's failure belongs to the occurrence it rendered; retiring it would strip every other occurrence too.
const onEntryError = (error: unknown): void => {
host.reportEntryError(slotKey, entry, error, { abdicate: false })
@@ -1143,10 +1149,10 @@ function hocLayer(
switch (spec.scope) {
case 'session':
Layer = ({ owner, children }) => {
- const inner = {renderInner(owner, children)}
+ const inner = forwardChildren(owner, children)
return (
{inner}
@@ -1156,9 +1162,9 @@ function hocLayer(
break
case 'session-maybe':
Layer = ({ owner, children }) => {
- const inner = {renderInner(owner, children)}
+ const inner = forwardChildren(owner, children)
return (
-
+
@@ -1170,9 +1176,9 @@ function hocLayer(
break
case 'root':
Layer = ({ owner, children }) => {
- const inner = {renderInner(owner, children)}
+ const inner = forwardChildren(owner, children)
return (
-
+
@@ -1237,13 +1243,11 @@ interface CompiledHoc {
readonly render: RenderHocInner
}
-/**
- * Compiled hoc chains per host, live declaration, and dispatch key. Every
- * outlet dispatching the same key shares one chain, so its layer Components,
- * the remount boundary of the content inside them, are created once; a
- * redeclared slot gets a new spec object and therefore an empty cache.
- */
-const hocChains = new WeakMap, Map>>()
+/** Dispatch chains by slot name; distinct slots can share the same spec object but have independent ledger versions. */
+type HocChainsBySlot = Map>
+
+/** Outlets of one named slot and dispatch key share layer Component identities without retaining replaced specs. */
+const hocChains = new WeakMap, HocChainsBySlot>>()
/**
* Whether two layer lists hold the same entries in the same order.
@@ -1276,15 +1280,18 @@ function hocChainFor(
bySpec = new WeakMap()
hocChains.set(host, bySpec)
}
- let chains = bySpec.get(spec)
+ let bySlot = bySpec.get(spec)
+ if (bySlot === undefined) {
+ bySlot = new Map()
+ bySpec.set(spec, bySlot)
+ }
+ let chains = bySlot.get(slotKey)
if (chains === undefined) {
chains = new Map()
- bySpec.set(spec, chains)
+ bySlot.set(slotKey, chains)
}
- // Key dispatches carry a prefix so none shares the wildcard dispatch's entry.
- const cacheKey = entryKey === undefined ? '' : `=${entryKey}`
const version = host.getVersion(slotKey)
- const cached = chains.get(cacheKey)
+ const cached = chains.get(entryKey)
if (cached !== undefined && cached.version === version) return cached.render
const layers = hocLayersFor(host.entriesOfSlot(slotKey), entryKey)
if (cached !== undefined && sameLayers(cached.layers, layers)) {
@@ -1292,7 +1299,7 @@ function hocChainFor(
return cached.render
}
const render = layers.length === 0 ? renderHocContent : composeHocLayers(host, slotKey, spec, layers)
- chains.set(cacheKey, { version, layers, render })
+ chains.set(entryKey, { version, layers, render })
return render
}
diff --git a/packages/client/ui-renderer/tests/hoc-slots.client.spec.tsx b/packages/client/ui-renderer/tests/hoc-slots.client.spec.tsx
index b8fa704e24..be29eaec83 100644
--- a/packages/client/ui-renderer/tests/hoc-slots.client.spec.tsx
+++ b/packages/client/ui-renderer/tests/hoc-slots.client.spec.tsx
@@ -19,10 +19,12 @@ declare module '@deepseek-ai/dsh-client-ui-slots' {
'spec.hoc.maybe': { kind: 'hoc'; scope: 'session-maybe' }
'spec.hoc.session': { kind: 'hoc'; scope: 'session' }
'spec.hoc.keyed': { kind: 'hoc'; scope: 'root'; owner: { tone: string } }
+ 'spec.hoc.inline': { kind: 'hoc'; scope: 'root'; inline: true }
+ 'spec.hoc.receiver': { kind: 'hoc'; scope: 'root' }
}
}
-type Frame = PropsRenderSlots<'spec.hoc' | 'spec.hoc.maybe' | 'spec.hoc.session' | 'spec.hoc.keyed'>
+type Frame = PropsRenderSlots<'spec.hoc' | 'spec.hoc.maybe' | 'spec.hoc.session' | 'spec.hoc.keyed' | 'spec.hoc.inline'>
afterEach(() => {
cleanup()
@@ -78,6 +80,11 @@ function layer(id: string) {
)
}
+/** A direct path through the children outlets of the given wrapping layers, outermost first. */
+function layerContent(...ids: string[]): string {
+ return ids.map(id => `section[data-layer="${id}"] > [data-slot-children]`).join(' > ')
+}
+
let setTone: (tone: string) => void = () => {}
/** Register the root declaring the hoc slots, render the root-scope hoc around Content, and mount. */
@@ -89,6 +96,7 @@ function mount(core: SlotCore, body?: (renderSlot: Frame['renderSlot']) => React
'spec.hoc.maybe': { kind: 'hoc', scope: 'session-maybe' },
'spec.hoc.session': { kind: 'hoc', scope: 'session' },
'spec.hoc.keyed': { kind: 'hoc', scope: 'root' },
+ 'spec.hoc.inline': { kind: 'hoc', scope: 'root', inline: true },
},
}, function Root(props: Frame) {
const [tone, set] = useState('calm')
@@ -102,19 +110,82 @@ describe('hoc slots', () => {
it('renders the content unchanged without layers, then nests layers lowest order outermost', async () => {
const core = new SlotCore()
const view = mount(core)
- expect(view.getByTestId('content')).toBeTruthy()
- expect(view.container.querySelector('section')).toBeNull()
+ const anchor = view.container.querySelector('[data-slot="spec.hoc"]')!
+ expect(anchor.firstElementChild).toBe(view.getByTestId('content'))
+ expect(anchor.querySelector('[data-slot-children]')).toBeNull()
core.register({ name: 'spec.hoc', id: 'inner', order: 10 }, layer('inner') as never)
core.register({ name: 'spec.hoc', id: 'outer' }, layer('outer') as never)
await flush()
- const outer = view.container.querySelector('section[data-layer="outer"]')
- const inner = outer?.querySelector(':scope > section[data-layer="inner"]')
- expect(inner?.querySelector(':scope > p')?.textContent).toBe('content')
+ const outer = anchor.querySelector(':scope > section[data-layer="outer"]')
+ const inner = outer?.querySelector(':scope > [data-slot-children="spec.hoc"] > section[data-layer="inner"]')
+ expect(inner?.querySelector(':scope > [data-slot-children="spec.hoc"] > p')).toBe(view.getByTestId('content'))
+ const outlets = Array.from(anchor.querySelectorAll('[data-slot-children]'))
+ expect(outlets.map(node => [node.tagName, node.style.display])).toEqual([['DIV', 'contents'], ['DIV', 'contents']])
expect(outer?.getAttribute('data-tone')).toBe('calm')
expect(inner?.getAttribute('data-tone')).toBe('calm')
})
+ it('keeps each supplying slot name when a layer forwards its children through another hoc slot', async () => {
+ const core = new SlotCore()
+ const view = mount(core)
+ core.register({
+ name: 'spec.hoc', id: 'bridge',
+ children: { 'spec.hoc.receiver': { kind: 'hoc', scope: 'root' } },
+ }, ({ renderSlot, children }) => renderSlot('spec.hoc.receiver', {}, {
+ children: <>{children}
Added for the receiver
>,
+ }))
+ core.register({ name: 'spec.hoc', id: 'pass', order: 1 }, ({ children }) => children)
+ core.register({ name: 'spec.hoc.receiver', id: 'pass' }, ({ children }) => children)
+ await flush()
+
+ const content = view.getByTestId('content')
+ const extra = view.getByText('Added for the receiver')
+ const receiver = view.container.querySelector('[data-slot="spec.hoc"] > [data-slot="spec.hoc.receiver"]')!
+ expect(content.closest('[data-slot]')).toBe(receiver)
+ expect(extra.closest('[data-slot]')).toBe(receiver)
+ expect(receiver.querySelector([
+ ':scope', '[data-slot-children="spec.hoc.receiver"]',
+ '[data-slot-children="spec.hoc"]', '[data-slot-children="spec.hoc"]', 'p',
+ ].join(' > '))).toBe(content)
+ expect([...receiver.querySelectorAll('[data-slot-children] > p')]).toEqual([content, extra])
+ expect([...receiver.querySelectorAll('[data-slot-children="spec.hoc"] > p')]).toEqual([content])
+ expect([...receiver.querySelectorAll('[data-slot-children="spec.hoc.receiver"] > p')]).toEqual([extra])
+ })
+
+ it('keeps the selected layers and their slot names separate when two slots share one declaration object', () => {
+ const core = new SlotCore()
+ const shared = { kind: 'hoc', scope: 'root' } as const
+ core.register({ name: 'root', children: { 'spec.hoc': shared, 'spec.hoc.keyed': shared } }, ({ renderSlot }) => <>
+ {renderSlot('spec.hoc', { tone: 'first' }, { entryKey: 'same', children: 'First' })}
+ {renderSlot('spec.hoc.keyed', { tone: 'second' }, { entryKey: 'same', children: 'Second' })}
+ >)
+ core.register({ name: 'spec.hoc', key: 'same', id: 'wrap' }, layer('first'))
+ core.register({ name: 'spec.hoc.keyed', key: 'same', id: 'wrap' }, layer('second'))
+ const view = render(<>{createSlotRenderer().renderRoot(hostOver(core), {})}>)
+
+ for (const [slot, id, text] of [['spec.hoc', 'first', 'First'], ['spec.hoc.keyed', 'second', 'Second']]) {
+ const outlet = view.container.querySelector(`[data-slot="${slot}"] > section[data-layer="${id}"] > [data-slot-children="${slot}"]`)
+ expect(outlet?.textContent).toBe(text)
+ }
+ })
+
+ it('groups inline owner content without enclosing the extra control returned by the layer', async () => {
+ const core = new SlotCore()
+ const view = mount(core, renderSlot => renderSlot('spec.hoc.inline', {}, {
+ children: <>FirstSecond>,
+ }))
+ core.register({ name: 'spec.hoc.inline', id: 'action' }, ({ children }) => <>{children}>)
+ await flush()
+ const anchor = view.container.querySelector('[data-slot="spec.hoc.inline"]')!
+ const outlet = anchor.querySelector(':scope > [data-slot-children="spec.hoc.inline"]')
+ expect(outlet?.tagName).toBe('SPAN')
+ expect(outlet?.style.display).toBe('contents')
+ expect(outlet?.firstChild).toBe(view.getByText('First'))
+ expect(outlet?.lastChild?.textContent).toBe('Second')
+ expect([...anchor.children]).toEqual([outlet, view.getByRole('button', { name: 'Action' })])
+ })
+
it('updates owner props without remounting the content, and remounts it when the layer set changes', async () => {
const core = new SlotCore()
mounts.mockClear()
@@ -157,10 +228,10 @@ describe('hoc slots', () => {
await flush()
await flush()
const loud = view.getByTestId('loud-outlet')
- expect(loud.querySelector('section[data-layer="outer"] > p')?.textContent).toBe('loud-content')
+ expect(loud.querySelector(`${layerContent('outer')} > [data-slot-children="spec.hoc"] > p`)?.textContent).toBe('loud-content')
expect(loud.querySelector('section[data-layer="fragile"]')).toBeNull()
const calm = view.getByTestId('calm-outlet')
- expect(calm.querySelector('section[data-layer="outer"] > section[data-layer="fragile"] > p')?.textContent).toBe('calm-content')
+ expect(calm.querySelector(`${layerContent('outer', 'fragile')} > p`)?.textContent).toBe('calm-content')
expect(view.container.querySelector('[data-slot-error]')).toBeNull()
expect(core.entriesOfSlot('spec.hoc').map(entry => entry.options.id)).toEqual(['outer', 'fragile'])
expect(reported).toHaveBeenCalledWith('spec.hoc', expect.anything(), expect.objectContaining({ message: 'layer failed' }), { abdicated: false })
@@ -200,7 +271,7 @@ describe('hoc slots', () => {
shown = true
act(() => { setTone('remounted') })
expect(calls).toHaveBeenCalledWith('calm')
- expect(view.container.querySelector('section[data-layer="fragile"] > p')?.textContent).toBe('retry-content')
+ expect(view.container.querySelector(`${layerContent('fragile')} > p`)?.textContent).toBe('retry-content')
})
it('passes content errors upward without blaming or removing any layer', async () => {
@@ -233,12 +304,14 @@ describe('hoc slots', () => {
expect(core.entriesOfSlot('spec.hoc').map(entry => entry.options.id)).toEqual(['outer', 'inner'])
})
- it('renders its layers around nothing when the owner omits children', async () => {
+ it('keeps a forwarded children outlet empty when the owner supplies no content', async () => {
const core = new SlotCore()
const view = mount(core, renderSlot => renderSlot('spec.hoc', { tone: 'calm' }))
core.register({ name: 'spec.hoc', id: 'outer' }, layer('outer') as never)
await flush()
- expect(view.container.querySelector('section[data-layer="outer"]')?.childNodes).toHaveLength(0)
+ const outer = view.container.querySelector('section[data-layer="outer"]')!
+ expect(outer.childNodes).toHaveLength(1)
+ expect(outer.firstElementChild?.matches('div[data-slot-children="spec.hoc"]:empty')).toBe(true)
})
it('wraps content in session-maybe and strict session layers', async () => {
@@ -252,8 +325,8 @@ describe('hoc slots', () => {
core.register({ name: 'spec.hoc.maybe', id: 'maybe' }, layer('maybe') as never)
core.register({ name: 'spec.hoc.session', id: 'session' }, layer('session') as never)
await flush()
- expect(view.container.querySelector('section[data-layer="maybe"] p')?.textContent).toBe('maybe-content')
- expect(view.container.querySelector('section[data-layer="session"] p')?.textContent).toBe('session-content')
+ expect(view.getByTestId('maybe-content').parentElement?.getAttribute('data-slot-children')).toBe('spec.hoc.maybe')
+ expect(view.getByTestId('session-content').parentElement?.getAttribute('data-slot-children')).toBe('spec.hoc.session')
})
})
@@ -278,9 +351,9 @@ describe('keyed hoc slots', () => {
core.register({ name: 'spec.hoc.keyed', id: 'ts', key: 'ts', order: 1 }, layer('ts') as never)
await flush()
const ts = view.getByTestId('ts-content-outlet')
- expect(ts.querySelector('section[data-layer="w"] > section[data-layer="ts"] > p')?.textContent).toBe('ts-content')
+ expect(ts.querySelector(`${layerContent('w', 'ts')} > p`)?.textContent).toBe('ts-content')
const md = view.getByTestId('md-content-outlet')
- expect(md.querySelector('section[data-layer="w"] > p')?.textContent).toBe('md-content')
+ expect(md.querySelector(`${layerContent('w')} > p`)?.textContent).toBe('md-content')
expect(md.querySelector('section[data-layer="ts"]')).toBeNull()
})
@@ -290,7 +363,7 @@ describe('keyed hoc slots', () => {
core.register({ name: 'spec.hoc.keyed', id: 'w' }, layer('w') as never)
core.register({ name: 'spec.hoc.keyed', id: 'ts', key: 'ts', order: 1 }, layer('ts') as never)
await flush()
- expect(view.container.querySelector('section[data-layer="w"] > p')?.textContent).toBe('wild-content')
+ expect(view.container.querySelector(`${layerContent('w')} > p`)?.textContent).toBe('wild-content')
expect(view.container.querySelector('section[data-layer="ts"]')).toBeNull()
})
@@ -306,10 +379,10 @@ describe('keyed hoc slots', () => {
core.register({ name: 'spec.hoc.keyed', id: 'x', key: 'ts' }, layer('exact') as never)
await flush()
const ts = view.getByTestId('ts-content-outlet')
- expect(ts.querySelector('section[data-layer="exact"] > p')?.textContent).toBe('ts-content')
+ expect(ts.querySelector(`${layerContent('exact')} > p`)?.textContent).toBe('ts-content')
expect(ts.querySelector('section[data-layer="wild"]')).toBeNull()
const md = view.getByTestId('md-content-outlet')
- expect(md.querySelector('section[data-layer="wild"] > p')?.textContent).toBe('md-content')
+ expect(md.querySelector(`${layerContent('wild')} > p`)?.textContent).toBe('md-content')
expect(md.querySelector('section[data-layer="exact"]')).toBeNull()
})
@@ -322,7 +395,8 @@ describe('keyed hoc slots', () => {
outletShown = true
act(() => { setTone('loud') })
await flush()
- expect(view.getByTestId('replaced')).toBeTruthy()
+ expect(view.getByTestId('replaced').parentElement?.getAttribute('data-slot')).toBe('spec.hoc.keyed')
+ expect(view.container.querySelector('[data-slot-children]')).toBeNull()
expect(view.queryByTestId('skipped-content')).toBeNull()
expect(mounts).not.toHaveBeenCalledWith('skipped-content')
})
@@ -346,7 +420,7 @@ describe('keyed hoc slots', () => {
await flush()
expect(view.getByTestId('ts-content').textContent).toBe('ts-content')
expect(view.getByTestId('ts-content-outlet').querySelector('section[data-layer="fragile"]')).toBeNull()
- expect(view.getByTestId('calm-outlet').querySelector('section[data-layer="fragile"] > p')?.textContent).toBe('calm-content')
+ expect(view.getByTestId('calm-outlet').querySelector(`${layerContent('fragile')} > p`)?.textContent).toBe('calm-content')
expect(core.entriesOfSlot('spec.hoc.keyed').map(entry => [entry.options.key, entry.options.id])).toEqual([['ts', 'fragile']])
})
@@ -363,10 +437,10 @@ describe('keyed hoc slots', () => {
core.register({ name: 'spec.hoc.keyed', id: 'w0', order: 0 }, layer('w0') as never)
await flush()
const ts = view.getByTestId('ts-content-outlet')
- expect(ts.querySelector('section[data-layer="w0"] > section[data-layer="e1"] > section[data-layer="w2"] > p')?.textContent)
+ expect(ts.querySelector(`${layerContent('w0', 'e1', 'w2')} > p`)?.textContent)
.toBe('ts-content')
const md = view.getByTestId('md-content-outlet')
- expect(md.querySelector('section[data-layer="w0"] > section[data-layer="w2"] > p')?.textContent).toBe('md-content')
+ expect(md.querySelector(`${layerContent('w0', 'w2')} > p`)?.textContent).toBe('md-content')
expect(md.querySelector('section[data-layer="e1"]')).toBeNull()
})
@@ -379,11 +453,11 @@ describe('keyed hoc slots', () => {
const dispose = core.register({ name: 'spec.hoc.keyed', id: 'e1', key: 'ts', order: 1, priority: -1 }, layer('shadow') as never)
await flush()
const ts = view.getByTestId('ts-content-outlet')
- expect(ts.querySelector('section[data-layer="w0"] > section[data-layer="shadow"] > p')?.textContent).toBe('ts-content')
+ expect(ts.querySelector(`${layerContent('w0', 'shadow')} > p`)?.textContent).toBe('ts-content')
expect(ts.querySelector('section[data-layer="e1"]')).toBeNull()
dispose()
await flush()
- expect(ts.querySelector('section[data-layer="w0"] > section[data-layer="e1"] > p')?.textContent).toBe('ts-content')
+ expect(ts.querySelector(`${layerContent('w0', 'e1')} > p`)?.textContent).toBe('ts-content')
expect(ts.querySelector('section[data-layer="shadow"]')).toBeNull()
})
@@ -396,7 +470,7 @@ describe('keyed hoc slots', () => {
core.register({ name: 'spec.hoc.keyed', id: 'w2', order: 2 }, layer('w2') as never)
await flush()
const ts = view.getByTestId('ts-content-outlet')
- expect(ts.querySelector('section[data-layer="w0"] > i[data-testid="replaced"]')).not.toBeNull()
+ expect(ts.querySelector(`${layerContent('w0')} > i[data-testid="replaced"]`)).not.toBeNull()
expect(ts.querySelector('section[data-layer="w2"]')).toBeNull()
expect(view.queryByTestId('ts-content')).toBeNull()
expect(mounts).not.toHaveBeenCalledWith('ts-content')
@@ -415,7 +489,7 @@ describe('keyed hoc slots', () => {
act(() => { core.register({ name: 'spec.hoc.keyed', id: 'ts2', key: 'ts' }, layer('ts2') as never) })
await flush()
expect(mounts).toHaveBeenCalledTimes(before + 1)
- expect(view.container.querySelector('section[data-layer="ts2"] > p')?.textContent).toBe('ts-content')
+ expect(view.container.querySelector(`${layerContent('ts2')} > p`)?.textContent).toBe('ts-content')
})
it('keeps every outlet of a key mounted when another key registers', async () => {
@@ -433,8 +507,8 @@ describe('keyed hoc slots', () => {
act(() => { core.register({ name: 'spec.hoc.keyed', id: 'md', key: 'md' }, layer('md') as never) })
await flush()
expect(mounts).toHaveBeenCalledTimes(before)
- expect(view.getByTestId('first-content-outlet').querySelector('section[data-layer="w"] > p')?.textContent).toBe('first-content')
- expect(view.getByTestId('second-content-outlet').querySelector('section[data-layer="w"] > p')?.textContent).toBe('second-content')
+ expect(view.getByTestId('first-content-outlet').querySelector(`${layerContent('w')} > p`)?.textContent).toBe('first-content')
+ expect(view.getByTestId('second-content-outlet').querySelector(`${layerContent('w')} > p`)?.textContent).toBe('second-content')
})
it('recompiles a key\'s chain for a redeclared slot', async () => {
@@ -449,14 +523,14 @@ describe('keyed hoc slots', () => {
const view = render(<>{createSlotRenderer().renderRoot(hostOver(core), {})}>)
core.register({ name: 'spec.hoc.keyed', id: 'first', key: 'ts' }, layer('first') as never)
await flush()
- expect(view.container.querySelector('section[data-layer="first"] > p')?.textContent).toBe('ts-content')
+ expect(view.container.querySelector(`${layerContent('first')} > p`)?.textContent).toBe('ts-content')
act(() => {
undeclare()
declare()
core.register({ name: 'spec.hoc.keyed', id: 'second', key: 'ts' }, layer('second') as never)
})
await flush()
- expect(view.container.querySelector('section[data-layer="second"] > p')?.textContent).toBe('ts-content')
+ expect(view.container.querySelector(`${layerContent('second')} > p`)?.textContent).toBe('ts-content')
expect(view.container.querySelector('section[data-layer="first"]')).toBeNull()
})
})
diff --git a/packages/client/ui-sidebar/README.i18n.yaml b/packages/client/ui-sidebar/README.i18n.yaml
index 7d7a31ef1a..18bc0d6806 100644
--- a/packages/client/ui-sidebar/README.i18n.yaml
+++ b/packages/client/ui-sidebar/README.i18n.yaml
@@ -24,8 +24,8 @@
en: c0434112ae12b04a
zh: 20da5afa27de5177
/deepseek-ai-dsh-client-ui-sidebar/use-this-package/collapse-behavior:
- en: 61d563b0f82ff658
- zh: f27504350dd14d4c
+ en: d6c134d7cfd8d301
+ zh: 25a31e2d5d740387
/deepseek-ai-dsh-client-ui-sidebar/use-this-package/macos-desktop:
en: 28e3639ed58492e0
zh: 4896acd767287c8a
diff --git a/packages/client/ui-sidebar/README.md b/packages/client/ui-sidebar/README.md
index 76cfeb907c..3014f45783 100644
--- a/packages/client/ui-sidebar/README.md
+++ b/packages/client/ui-sidebar/README.md
@@ -51,7 +51,7 @@ The sidebar and conversation-header toggles show the effective shortcut from the
The top expand button hosts the optional, non-interactive `sidebar.toggle.badge` slot while collapsed. Its occupant supplies status and tooltip content without adding another action or changing the button's navigation behavior.
-The root-scoped `sidebar.session.action` HOC layer wraps the New Session row's content: an occupant receives the row's Tooltip and button as `children` and returns them, possibly wrapped, together with its own controls, so it decorates the row without adding a wrapper element. It receives only `wide`, and an occupant that adds nothing must return `children`. Expanded, the controls share the New Session row and the button takes the remaining width; in the rail they stack below its icon. The row renders only while New Session renders, and each occupant still checks its own access.
+The root-scoped `sidebar.session.action` HOC slot wraps the New Session button and its Tooltip. Each layer receives `wide` as its only owner prop and renders `children`, optionally wrapped, alongside its own controls. A layer that adds nothing must return `children`. Expanded, the controls share the New Session row and the button takes the remaining width; in the rail they stack below its icon. The row renders only while New Session renders, and each occupant still checks its own access.
Expanded content follows the frame's column width, including its transitions. During a live collapse, the content fades out at its frozen expanded width, the upper controls share one fade and leftward translation into the 56px rail, and the layout's column slide ends the motion. A page that starts collapsed renders the rail statically, and reduced-motion mode disables both transitions. The bottom-pinned `sidebar.settings` control shares the fade timing but has no horizontal translation.
diff --git a/packages/client/ui-sidebar/README.zh.md b/packages/client/ui-sidebar/README.zh.md
index 0d76837aca..efd644c57a 100644
--- a/packages/client/ui-sidebar/README.zh.md
+++ b/packages/client/ui-sidebar/README.zh.md
@@ -51,7 +51,7 @@ root 作用域的 `sidebar.panellist.actions` list 有注册项时,导航区
侧栏收起时,顶部展开按钮承载可选、不可交互的 `sidebar.toggle.badge` slot。占用方提供状态和提示内容,不增加操作,也不改变按钮的导航行为。
-root 作用域的 `sidebar.session.action` 是包裹新建会话行内容的 HOC 层:占用方以 `children` 收到该行的 Tooltip 与按钮,再把它们(可再包裹)连同自己的控件一起返回,因此无需新增包裹元素即可装饰该行。占用方只收到 `wide`;不添加任何内容时必须原样返回 `children`。展开态下这些控件与新建会话按钮同处一行,按钮占据剩余宽度;收起态下它们纵向排在新建会话图标下方。该行只在新建会话按钮渲染时渲染,各占用方仍自行检查访问权限。
+root 作用域的 `sidebar.session.action` HOC slot 包裹新建会话按钮及其 Tooltip。每层收到的 owner prop 只有 `wide`,并将 `children`(可再包裹)与自己的控件一起渲染。不添加任何内容的层必须返回 `children`。展开态下这些控件与新建会话按钮同处一行,按钮占据剩余宽度;收起态下它们纵向排在新建会话图标下方。该行只在新建会话按钮渲染时渲染,各占用方仍自行检查访问权限。
展开内容跟随框架的列宽及其过渡。实时收起时,内容固定在展开宽度淡出,上方控件共用同一段透明度渐变,并向左平移进入 56px 轨道,由布局的栏滑动结束整段动画。页面初始即为收起状态时会静态渲染轨道;减少动态效果模式会禁用两段过渡。固定在底部的 `sidebar.settings` 控件共用相同的透明度渐变时序,但不发生横向位移。
diff --git a/packages/client/ui-sidebar/src/client/SidebarRoot.module.css b/packages/client/ui-sidebar/src/client/SidebarRoot.module.css
index 61ffc2b547..b675ee0b43 100644
--- a/packages/client/ui-sidebar/src/client/SidebarRoot.module.css
+++ b/packages/client/ui-sidebar/src/client/SidebarRoot.module.css
@@ -165,19 +165,23 @@
rail right edge over the remaining 150ms of the AppFrame track transition.
The bottom-pinned settings seat shares their opacity timeline but stays
horizontally fixed. Only a live collapse gets .railIn; a cold collapsed
- render stays static.
- The New Session row renders its content through the `sidebar.session.action`
- HOC slot, whose `display: contents` outlet anchor sits between the row and
- its content. The shell's New-session button and the occupant's own controls
- are that anchor's children, so the fade targets them through the anchor; the
- boxless anchor itself cannot carry an animation. */
+ render stays static. The New Session row animates each direct output of its
+ slot. Only the slot's children outlets are transparent: a layer's own wrapper
+ moves as one item, not together with a second animation on its descendants. */
.railIn .iconButton,
.railIn .newSessionRow > :global([data-slot='sidebar.session.action']) > *,
+.railIn .newSessionRow [data-slot-children='sidebar.session.action']:not(:where(
+ [data-slot='sidebar.session.action'] :not([data-slot-children='sidebar.session.action']) *
+)) > *,
.railIn .panelList,
.railIn .regionArea {
animation: rail-in 150ms var(--ds-ease-in-out) backwards;
}
+.railIn .newSessionRow [data-slot-children='sidebar.session.action'] {
+ animation: none;
+}
+
.railIn .footArea {
animation: rail-fade-in 150ms var(--ds-ease-in-out) backwards;
}
@@ -876,6 +880,9 @@
.fading > *,
.railIn .iconButton,
.railIn .newSessionRow > :global([data-slot='sidebar.session.action']) > *,
+ .railIn .newSessionRow [data-slot-children='sidebar.session.action']:not(:where(
+ [data-slot='sidebar.session.action'] :not([data-slot-children='sidebar.session.action']) *
+ )) > *,
.railIn .panelList,
.railIn .footArea,
.railIn .regionArea {
diff --git a/packages/client/ui-sidebar/src/client/contract/slots.ts b/packages/client/ui-sidebar/src/client/contract/slots.ts
index 73c1a7b082..c5e25a0969 100644
--- a/packages/client/ui-sidebar/src/client/contract/slots.ts
+++ b/packages/client/ui-sidebar/src/client/contract/slots.ts
@@ -90,11 +90,10 @@ declare module '@deepseek-ai/dsh-client-ui-slots' {
/**
* HOC layer around the inner content of the New-session row — the Tooltip
* and button the shell passes as `children`, rendered only while the Peer
- * may create Sessions. An occupant receives that content and returns it,
- * possibly wrapped, together with its own controls, so it decorates the
- * row without adding a wrapper element. Occupants nest around the content
- * instead of rendering beside it: one that adds nothing must return
- * `children`, and with no occupant the content renders unchanged.
+ * may create Sessions. Each occupant can render `children` with its own
+ * controls. Forwarded content sits in `[data-slot-children="sidebar.session.action"]`.
+ * An occupant that adds nothing must return `children`; with no occupant
+ * the content renders directly in the slot anchor.
* Declared by this package's 'sidebar' entry.
*/
'sidebar.session.action': { kind: 'hoc'; scope: 'root'; owner: SidebarSessionActionOwnerProps }
diff --git a/packages/client/ui-sidebar/tests/sidebar-styles.client.spec.ts b/packages/client/ui-sidebar/tests/sidebar-styles.client.spec.ts
index 51cc466da6..ce3a6dad64 100644
--- a/packages/client/ui-sidebar/tests/sidebar-styles.client.spec.ts
+++ b/packages/client/ui-sidebar/tests/sidebar-styles.client.spec.ts
@@ -2,6 +2,7 @@
import { readFileSync } from 'node:fs'
import { fileURLToPath } from 'node:url'
import { JSDOM } from 'jsdom'
+import { transform } from 'lightningcss'
import { describe, expect, it } from 'vitest'
const css = readFileSync(fileURLToPath(new URL('../src/client/SidebarRoot.module.css', import.meta.url)), 'utf8')
@@ -26,28 +27,6 @@ function declarations(selector: string): Map | undefined {
return undefined
}
-/**
- * Every declared selector, including those inside at-rule blocks.
- * @returns the selector text of each comma-separated part.
- */
-function declaredSelectors(): string[] {
- const withoutComments = css.replace(/\/\*[\s\S]*?\*\//g, ' ')
- return [...withoutComments.matchAll(/([^{}]+)\{([^{}]*)\}/g)]
- .flatMap(([, selectorList = '']) => selectorList.split(',').map(value => value.trim()))
-}
-
-/** Declarations of the reduced-motion block, which disables every rail animation. */
-function reducedMotion(): string {
- return css.match(/@media \(prefers-reduced-motion: reduce\) \{([\s\S]*)\n\}/u)?.[1] ?? ''
-}
-
-/** The renderer's `display: contents` anchor for the sidebar session action HOC slot. */
-const SLOT_ANCHOR = ":global([data-slot='sidebar.session.action'])"
-/** The shell's New-session button and the occupant's controls: the anchor's children, each matched once. */
-const ROW_CONTENT = `.railIn .newSessionRow > ${SLOT_ANCHOR} > *`
-/** The rail rule as a plain selector a DOM can match, with the CSS-module escape removed. */
-const ROW_CONTENT_SELECTOR = ROW_CONTENT.replace(SLOT_ANCHOR, "[data-slot='sidebar.session.action']")
-
describe('SidebarRoot.module.css', () => {
it('uses a compact expanded navigation gap without shrinking the collapsed rail spacing', () => {
expect(declarations('.panelList')?.get('gap')).toBe('2px')
@@ -124,11 +103,7 @@ describe('SidebarRoot.module.css', () => {
it('moves the upper controls while the settings seat only fades', () => {
const animation = 'rail-in 150ms var(--ds-ease-in-out) backwards'
- for (const selector of [
- '.railIn .iconButton',
- ROW_CONTENT,
- '.railIn .regionArea',
- ]) {
+ for (const selector of ['.railIn .iconButton', '.railIn .regionArea']) {
expect(declarations(selector)?.get('animation')).toBe(animation)
}
expect(declarations('.railIn .footArea')?.get('animation')).toBe(
@@ -140,43 +115,32 @@ describe('SidebarRoot.module.css', () => {
expect(css).toMatch(/@keyframes rail-fade-in\s*\{\s*from\s*\{\s*opacity: 0;\s*}\s*}/)
})
- it('fades the New Session row through its slot anchor without reaching into either button', () => {
- // The row renders its content through the HOC slot, so the renderer's
- // display:contents anchor is the row's only child; the shell's New-session
- // button and the occupant's own controls are the anchor's children.
- expect(declarations(ROW_CONTENT)?.get('animation')).toBe('rail-in 150ms var(--ds-ease-in-out) backwards')
- expect(reducedMotion()).toContain(ROW_CONTENT)
- for (const selector of declaredSelectors()) {
- if (!selector.includes('.newSessionRow')) continue
- // A bare star under the row matches the boxless anchor, so nothing animates.
- expect(selector).not.toMatch(/\.newSessionRow\s*>\s*\*/u)
- // A second bare star step also matches .newSessionLabelMask and
- // .newSessionShortcut inside the button, which would run rail-in twice on it.
- expect(selector).not.toMatch(/>\s*\*\s*>\s*\*/u)
- expect(selector).not.toContain('.newSessionLabelMask')
- expect(selector).not.toContain('.newSessionShortcut')
- }
- })
+ it('animates the session action outputs through HOC outlets but not their contents, except where motion is disabled', () => {
+ const sheet = transform({ filename: 'SidebarRoot.module.css', code: Buffer.from(css), cssModules: { pattern: '[local]' } }).code.toString()
+ const slot = 'sidebar.session.action'
+ const row = (content: string) => `
`).window
+ const animated = () => [...document.querySelectorAll('.newSessionRow')].map(el => [el, ...el.querySelectorAll('*')]
+ .filter(child => getComputedStyle(child).animation.includes('rail-in')).map(child => child.getAttribute('class')))
- it('matches exactly the two buttons the slot anchor holds', () => {
- // The renderer's outlet anchor is a display:contents div; the shell's
- // New-session button and the occupant's control are its element children.
- const { document } = new JSDOM(`
-
-
-
-
-
-
-
-
`).window
- const matched = [...document.querySelectorAll(ROW_CONTENT_SELECTOR)]
- expect(matched.map(element => element.className)).toEqual(['newSession', 'trigger'])
- // A bare child step matches only the boxless anchor, so nothing would animate.
- expect(document.querySelectorAll('.railIn .newSessionRow > *')).toHaveLength(1)
+ expect(animated()).toEqual([
+ ['newSession'], ['newSession'], ['newSession', 'import', 'tooltip'], ['newSession', 'import', 'tooltip', 'link'], ['customControl'],
+ ])
+ document.documentElement.setAttribute('data-windows-titlebar', '')
+ const [plain, ...layered] = animated()
+ expect(layered).toEqual([plain, [...plain!, 'import', 'tooltip'], [...plain!, 'import', 'tooltip', 'link'], ['customControl']])
+ document.documentElement.removeAttribute('data-windows-titlebar')
+ // jsdom has no reduced-motion preference; enable that media block in the same stylesheet cascade.
+ document.querySelector('style')!.textContent = sheet.replace('@media (prefers-reduced-motion: reduce)', '@media all')
+ expect(animated()).toEqual([[], [], [], [], []])
})
it('gives shell rail controls the same base anchor for their shared translation', () => {
diff --git a/packages/extensions/cordis-client-runner/src/client/slot-catalog.ts b/packages/extensions/cordis-client-runner/src/client/slot-catalog.ts
index 7ca69c567e..f3960c2c49 100644
--- a/packages/extensions/cordis-client-runner/src/client/slot-catalog.ts
+++ b/packages/extensions/cordis-client-runner/src/client/slot-catalog.ts
@@ -5919,7 +5919,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
kind: 'hoc',
scope: 'root',
summary: 'HOC layer around the inner content of the New-session row — the Tooltip and button the shell passes as `children`, rendered only while the Peer may create Sessions.',
- doc: 'HOC layer around the inner content of the New-session row — the Tooltip\nand button the shell passes as `children`, rendered only while the Peer\nmay create Sessions. An occupant receives that content and returns it,\npossibly wrapped, together with its own controls, so it decorates the\nrow without adding a wrapper element. Occupants nest around the content\ninstead of rendering beside it: one that adds nothing must return\n`children`, and with no occupant the content renders unchanged.\nDeclared by this package\'s \'sidebar\' entry.',
+ doc: 'HOC layer around the inner content of the New-session row — the Tooltip\nand button the shell passes as `children`, rendered only while the Peer\nmay create Sessions. Each occupant can render `children` with its own\ncontrols. Forwarded content sits in `[data-slot-children="sidebar.session.action"]`.\nAn occupant that adds nothing must return `children`; with no occupant\nthe content renders directly in the slot anchor.\nDeclared by this package\'s \'sidebar\' entry.',
registerOptions: [
{
name: 'id',
@@ -5965,7 +5965,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
],
replaceRisk: 'wraps-owner-content',
example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'sidebar.session.action\', () => ctx.slots.register(\n { name: \'sidebar.session.action\', id: \'my-layer\', order: 100 },\n ({ children }) => React.createElement(\'div\', null, children),\n ))\n },\n}',
- source: 'packages/client/ui-sidebar/src/client/contract/slots.ts:100',
+ source: 'packages/client/ui-sidebar/src/client/contract/slots.ts:99',
},
{
key: 'sidebar.session.row.hover',
diff --git a/packages/fs/tool-fs/README.i18n.yaml b/packages/fs/tool-fs/README.i18n.yaml
index 69acb22a04..c798e7dfc7 100644
--- a/packages/fs/tool-fs/README.i18n.yaml
+++ b/packages/fs/tool-fs/README.i18n.yaml
@@ -24,8 +24,8 @@
en: 6e12ea9c79039360
zh: 7230ad3bda4515d5
/deepseek-ai-dsh-tool-fs/use-this-package/configuration:
- en: 92b0a816b47159e9
- zh: 1b6ce7b0c7216886
+ en: b5d18581b190e246
+ zh: 4ebbb8927f7745fb
/deepseek-ai-dsh-tool-fs/use-this-package/policy-and-sandbox-behavior:
en: 9bddebaf4aff0a8d
zh: fea0196162e3fcd1
diff --git a/packages/fs/tool-fs/README.md b/packages/fs/tool-fs/README.md
index d77f4e791b..b7045ba821 100644
--- a/packages/fs/tool-fs/README.md
+++ b/packages/fs/tool-fs/README.md
@@ -55,7 +55,7 @@ Field names are snake_case to match Claude Code and existing harness tool schema
### Configuration
-All keys are optional. The `read`, `readImage`, `write`, and `edit` switches default to `true`; set a switch to `false` to omit that tool and its guidance. `applyPatch` defaults to `false`; [`dsh-base`](../../bundle/base/cordis.patch.yml) and the Web `standard` preset enable it on their `tool-fs` rows, while the Web `ptc` and `cordis` presets state `applyPatch: false`, and changing that one line adds or drops the tool beside `edit`. All five tools may be disabled. Enabling `readImage` still requires an attachment store and an image-capable model. Read caps remain validated when `read` is disabled.
+All keys are optional. The `read`, `readImage`, `write`, and `edit` switches default to `true`; set a switch to `false` to omit that tool and its guidance. `applyPatch` defaults to the resolved `edit` value, so a row that keeps `edit` also offers `apply_patch`; set `applyPatch: false` to drop it beside `edit`, or `applyPatch: true` to keep it without `edit`. All five tools may be disabled. Enabling `readImage` still requires an attachment store and an image-capable model. Read caps remain validated when `read` is disabled.
| Key | Default | Meaning |
|---|---|---|
@@ -63,7 +63,7 @@ All keys are optional. The `read`, `readImage`, `write`, and `edit` switches def
| `readImage` | `true` | Register `read_image` while an attachment store is mounted |
| `write` | `true` | Register `write` and its guidance |
| `edit` | `true` | Register `edit` and its guidance |
-| `applyPatch` | `false` | Register `apply_patch` and its guidance |
+| `applyPatch` | value of `edit` | Register `apply_patch` and its guidance |
| `readLimit` | `2000` | Default and maximum lines returned by one `read` call |
| `readMaxLineLength` | `2000` | Characters kept per line before truncation |
| `readMaxBytes` | `51200` | Byte cap on one `read` call's selected lines; overflow ends the window with a capped footer |
diff --git a/packages/fs/tool-fs/README.zh.md b/packages/fs/tool-fs/README.zh.md
index eb74e5837c..164a5e72ac 100644
--- a/packages/fs/tool-fs/README.zh.md
+++ b/packages/fs/tool-fs/README.zh.md
@@ -55,7 +55,7 @@ kind: "package-reference"
### 配置
-所有键均为可选。`read`、`readImage`、`write` 和 `edit` 开关默认为 `true`;将开关设为 `false` 可省略对应工具及其指导文本。`applyPatch` 默认为 `false`;[`dsh-base`](../../bundle/base/cordis.patch.yml) 与 Web 的 `standard` preset 在各自的 `tool-fs` 行上开启它,而 Web 的 `ptc`、`cordis` preset 显式写出 `applyPatch: false`,改这一行即可在 `edit` 旁加入或去掉该工具。允许关闭全部五个工具。启用 `readImage` 仍需要附件存储和支持图片输入的模型。关闭 `read` 时仍会校验读取上限。
+所有键均为可选。`read`、`readImage`、`write` 和 `edit` 开关默认为 `true`;将开关设为 `false` 可省略对应工具及其指导文本。`applyPatch` 默认取解析后的 `edit` 值,因此保留 `edit` 的行也会提供 `apply_patch`;设为 `false` 可在 `edit` 旁去掉它,设为 `true` 可在没有 `edit` 时保留它。允许关闭全部五个工具。启用 `readImage` 仍需要附件存储和支持图片输入的模型。关闭 `read` 时仍会校验读取上限。
| 键 | 默认值 | 含义 |
|---|---|---|
@@ -63,7 +63,7 @@ kind: "package-reference"
| `readImage` | `true` | 附件存储挂载时注册 `read_image` |
| `write` | `true` | 注册 `write` 及其指导文本 |
| `edit` | `true` | 注册 `edit` 及其指导文本 |
-| `applyPatch` | `false` | 注册 `apply_patch` 及其提示 |
+| `applyPatch` | `edit` 的值 | 注册 `apply_patch` 及其提示 |
| `readLimit` | `2000` | 一次 `read` 调用返回的默认和最大行数 |
| `readMaxLineLength` | `2000` | 每行截断前保留的字符数 |
| `readMaxBytes` | `51200` | 一次 `read` 调用所选行的字节上限;溢出时以「已达上限」footer 结束窗口 |
diff --git a/packages/fs/tool-fs/src/index.ts b/packages/fs/tool-fs/src/index.ts
index 41e3be251c..ce7fb84e37 100644
--- a/packages/fs/tool-fs/src/index.ts
+++ b/packages/fs/tool-fs/src/index.ts
@@ -33,7 +33,7 @@ export interface Config {
write?: boolean
/** Register `edit` and its guidance. Defaults to true. */
edit?: boolean
- /** Register `apply_patch` and its guidance beside `edit`. Defaults to false; shipped compositions set it on their `tool-fs` rows. */
+ /** Register `apply_patch` and its guidance. Defaults to the resolved `edit` value. */
applyPatch?: boolean
/** Default and maximum number of lines returned by one `read` call. */
readLimit?: number
@@ -50,16 +50,24 @@ export const Config: z = z.object({
readImage: z.boolean().default(true),
write: z.boolean().default(true),
edit: z.boolean().default(true),
- applyPatch: z.boolean().default(false),
+ applyPatch: z.boolean(),
readLimit: z.number().default(READ_LIMIT),
readMaxLineLength: z.number().default(READ_MAX_LINE_LENGTH),
readMaxBytes: z.number().default(READ_MAX_BYTES),
readStreamMinSize: z.number().default(STREAM_MIN_SIZE),
})
-/** Configuration after schemastery applied the defaults. */
+/** Configuration after schemastery applied its defaults; `applyPatch` stays unset until {@link resolveConfig}. */
+type ParsedConfig = Required> & Pick
+
+/** Configuration with every switch decided. */
type ResolvedConfig = Required
+/** Decide `applyPatch` from `edit` when the composition leaves it unset. */
+function resolveConfig(config: ParsedConfig): ResolvedConfig {
+ return { ...config, applyPatch: config.applyPatch ?? config.edit }
+}
+
/** Every read cap counts lines/chars/bytes — a positive integer, or windowing arithmetic misbehaves silently. */
function assertPositiveInteger(name: string, value: number): void {
if (!Number.isInteger(value) || value < 1) {
@@ -70,7 +78,7 @@ function assertPositiveInteger(name: string, value: number): void {
/** Register the selected filesystem tools; `read_image` additionally requires a mounted attachment store. */
export function apply(ctx: Context, config: Config): void {
// schemastery (Config) has already filled every defaulted field.
- const resolved = config as ResolvedConfig
+ const resolved = resolveConfig(config as ParsedConfig)
assertPositiveInteger('readLimit', resolved.readLimit)
assertPositiveInteger('readMaxLineLength', resolved.readMaxLineLength)
assertPositiveInteger('readMaxBytes', resolved.readMaxBytes)
diff --git a/packages/fs/tool-fs/tests/read-image.spec.ts b/packages/fs/tool-fs/tests/read-image.spec.ts
index 250dcc48dd..5b8f1bce19 100644
--- a/packages/fs/tool-fs/tests/read-image.spec.ts
+++ b/packages/fs/tool-fs/tests/read-image.spec.ts
@@ -927,7 +927,7 @@ describe('registration surface', () => {
it('omits read_image while an attachment store is mounted when readImage is false', async () => {
const ctx = await setup({ toolFs: { readImage: false } })
- expect(ctx.tools.schemas().map(tool => tool.name).sort()).toEqual(['edit', 'read', 'write'])
+ expect(ctx.tools.schemas().map(tool => tool.name).sort()).toEqual(['apply_patch', 'edit', 'read', 'write'])
expect(ctx.tools.get('read_image')).toBeUndefined()
expect((await readImage(ctx, { file_path: 'red.png' }, agentOn('vision-model'))).isError).toBe(true)
})
@@ -968,16 +968,16 @@ describe('registration surface', () => {
const attachmentsFiber = await ctx.plugin(LocalAttachmentStore, { dshHome: home })
const toolFsFiber = await ctx.plugin(ToolFs)
const names = () => ctx.tools.schemas().map(schema => schema.name).sort()
- expect(names()).toEqual(['edit', 'read', 'read_image', 'write'])
+ expect(names()).toEqual(['apply_patch', 'edit', 'read', 'read_image', 'write'])
// Disposing only the attachment store tears down the scoped inject fiber:
// read_image withdraws while the unconditional tools stay registered.
await attachmentsFiber.dispose()
- expect(names()).toEqual(['edit', 'read', 'write'])
+ expect(names()).toEqual(['apply_patch', 'edit', 'read', 'write'])
// Remounting the store restores the conditional registration.
const remounted = await ctx.plugin(LocalAttachmentStore, { dshHome: home })
- expect(names()).toEqual(['edit', 'read', 'read_image', 'write'])
+ expect(names()).toEqual(['apply_patch', 'edit', 'read', 'read_image', 'write'])
// Disposing the whole plugin withdraws every tool, read_image included.
await toolFsFiber.dispose()
diff --git a/packages/fs/tool-fs/tests/tools.spec.ts b/packages/fs/tool-fs/tests/tools.spec.ts
index ce82cbb433..8c924b0352 100644
--- a/packages/fs/tool-fs/tests/tools.spec.ts
+++ b/packages/fs/tool-fs/tests/tools.spec.ts
@@ -160,10 +160,11 @@ describe('current directory resolution', () => {
describe('registration', () => {
it.each([
- { config: { read: false }, tools: ['edit', 'write'], sections: ['tool:edit', 'tool:write'] },
- { config: { write: false }, tools: ['edit', 'read'], sections: ['tool:edit', 'tool:read'] },
+ { config: { read: false }, tools: ['apply_patch', 'edit', 'write'], sections: ['tool:apply_patch', 'tool:edit', 'tool:write'] },
+ { config: { write: false }, tools: ['apply_patch', 'edit', 'read'], sections: ['tool:apply_patch', 'tool:edit', 'tool:read'] },
{ config: { edit: false }, tools: ['read', 'write'], sections: ['tool:read', 'tool:write'] },
- { config: { write: false, applyPatch: true }, tools: ['apply_patch', 'edit', 'read'], sections: ['tool:apply_patch', 'tool:edit', 'tool:read'] },
+ { config: { applyPatch: false }, tools: ['edit', 'read', 'write'], sections: ['tool:edit', 'tool:read', 'tool:write'] },
+ { config: { edit: false, applyPatch: true }, tools: ['apply_patch', 'read', 'write'], sections: ['tool:apply_patch', 'tool:read', 'tool:write'] },
{ config: { read: false, readImage: false, write: false, edit: false }, tools: [], sections: [] },
])('omits disabled tools and their guidance: $config', async ({ config, tools, sections }) => {
const { ctx } = await setup(config)
@@ -182,9 +183,9 @@ describe('registration', () => {
expect((await ToolFs.Config['~standard'].validate(config)).issues).toBeDefined()
})
- it('registers read, write, and edit', async () => {
+ it('registers read, write, edit, and apply_patch, which follows edit unless set', async () => {
const { ctx } = await setup()
- expect(ctx.tools.schemas().map(s => s.name).sort()).toEqual(['edit', 'read', 'write'])
+ expect(ctx.tools.schemas().map(s => s.name).sort()).toEqual(['apply_patch', 'edit', 'read', 'write'])
})
it.each([
@@ -244,10 +245,10 @@ describe('registration', () => {
const fiber = await ctx.plugin(ToolFs)
// Each tool contributes BOTH a schema and a prompt section; disposal must
// withdraw both, not just the schemas.
- expect(ctx.tools.schemas()).toHaveLength(3)
+ expect(ctx.tools.schemas()).toHaveLength(4)
const sectionNames = (a: { sections: { name: string; retire?: boolean }[] }) => a.sections
.filter(s => !s.retire).map(s => s.name).sort()
- expect(sectionNames(await ctx.systemPrompt.assemble())).toEqual(['deployment:persona-prefix', 'deployment:persona-suffix', 'harness:identity', 'tool:edit', 'tool:read', 'tool:write'])
+ expect(sectionNames(await ctx.systemPrompt.assemble())).toEqual(['deployment:persona-prefix', 'deployment:persona-suffix', 'harness:identity', 'tool:apply_patch', 'tool:edit', 'tool:read', 'tool:write'])
await fiber.dispose()
expect(ctx.tools.schemas()).toHaveLength(0)
// Only the system-prompt plugin's own built-in sections remain.
@@ -1183,7 +1184,7 @@ const originalGuidance = {
describe('scope-aware filesystem guidance', () => {
it.each(Array.from({ length: 8 }, (_, mask) => mask))('preserves exact text for visible tools (mask %i)', async (mask) => {
- const { ctx } = await setup()
+ const { ctx } = await setup({ applyPatch: false })
const { key, scope } = await guidanceScope(ctx)
const names = ['read', 'write', 'edit'] as const
const allow = names.filter((_, index) => (mask & (1 << index)) !== 0)
@@ -1206,7 +1207,7 @@ describe('scope-aware filesystem guidance', () => {
})
it('honors deny filters and the existing exemption for own-scope tools', async () => {
- const { ctx } = await setup()
+ const { ctx } = await setup({ applyPatch: false })
const { key, scope } = await guidanceScope(ctx)
const write = ctx.tools.get('write')!
scope.ctx.tools.restrict({ deny: ['write', 'edit'] })
diff --git a/scripts/gen-tool-catalog.ts b/scripts/gen-tool-catalog.ts
index 03a942a914..94c09dd893 100644
--- a/scripts/gen-tool-catalog.ts
+++ b/scripts/gen-tool-catalog.ts
@@ -449,10 +449,10 @@ const TOOL_PACKAGES: ToolPackage[] = [
// The catalog seam marker opts into
// the attachments-conditional image schema without attachment I/O.
await ctx.plugin(CatalogAttachmentStore)
- await ctx.plugin(ToolFs, { applyPatch: true })
+ await ctx.plugin(ToolFs)
},
note:
- 'The read-before-write/edit policy is added by `@deepseek-ai/dsh-fs-observation-policy` (an `fs/*` event-gate plugin, no schema change); the shipped compositions leave its row disabled, so mutations are unconditional unless a deployment enables it. The image tool is not registered without `ctx.attachments`; its schema is route-independent, and execution refuses unless the exact routed model declares image input. `apply_patch` registers only with `applyPatch: true`; the catalog sets it so the schema is documented. `dsh-base` and the Web `standard` preset enable it; the Web `ptc` and `cordis` presets and the PTC overlay state `applyPatch: false`.',
+ 'The read-before-write/edit policy is added by `@deepseek-ai/dsh-fs-observation-policy` (an `fs/*` event-gate plugin, no schema change); the shipped compositions leave its row disabled, so mutations are unconditional unless a deployment enables it. The image tool is not registered without `ctx.attachments`; its schema is route-independent, and execution refuses unless the exact routed model declares image input. `apply_patch` registers when `applyPatch` resolves to true; unset, it follows `edit`, so every shipped composition that keeps `edit` offers it, including the Web `standard`, `ptc`, and `cordis` presets.',
},
{
pkg: '@deepseek-ai/dsh-tool-fs-search',
diff --git a/scripts/smoke-python-runtime.py b/scripts/smoke-python-runtime.py
index 74b2b1dddf..9c7277bd29 100644
--- a/scripts/smoke-python-runtime.py
+++ b/scripts/smoke-python-runtime.py
@@ -1524,7 +1524,6 @@ def smoke_sdk_dynamic_tools(base_url: str, executable: Path, update_snapshots: b
task = root / "dynamic-tool-task.txt"
task.write_text("Call snapshot_ping once.\n", encoding="utf-8")
patch = write_profile_patch(root, "dynamic-tools.patch.yml", sessions, [
- {"id": "tool-fs", "config": {"applyPatch": True}},
{"id": "llm-deepseek", "config": {"models": [
{"id": "smoke-model", "toolUpdate": "addition-only"},
]}},
diff --git a/snapshots/acp/escalation-approved/cordis.yml b/snapshots/acp/escalation-approved/cordis.yml
index 2c75610603..08e9986ee3 100644
--- a/snapshots/acp/escalation-approved/cordis.yml
+++ b/snapshots/acp/escalation-approved/cordis.yml
@@ -83,8 +83,3 @@
- id: session-log-deepseek
config:
enabled: false
-
-# The recorded tool catalog includes the optional patch tool.
-- id: tool-fs
- config:
- applyPatch: true
diff --git a/snapshots/sdk/background-wait-steer/cordis.yml b/snapshots/sdk/background-wait-steer/cordis.yml
index c1c26f5d97..04e4e08f00 100644
--- a/snapshots/sdk/background-wait-steer/cordis.yml
+++ b/snapshots/sdk/background-wait-steer/cordis.yml
@@ -37,8 +37,3 @@
- insert:
- id: background-wait-steer-fixture
name: './wait-fixture.mjs'
-
-# The recorded tool catalog includes the optional patch tool.
-- id: tool-fs
- config:
- applyPatch: true
diff --git a/snapshots/sdk/desktop-context/cordis.yml b/snapshots/sdk/desktop-context/cordis.yml
index 93031877b9..165911c611 100644
--- a/snapshots/sdk/desktop-context/cordis.yml
+++ b/snapshots/sdk/desktop-context/cordis.yml
@@ -34,8 +34,3 @@
- id: time-context
config:
timeZone: UTC
-
-# The recorded tool catalog includes the optional patch tool.
-- id: tool-fs
- config:
- applyPatch: true
diff --git a/snapshots/sdk/desktop-ptc-context/cordis.yml b/snapshots/sdk/desktop-ptc-context/cordis.yml
index c4b82fa29b..99a7be597d 100644
--- a/snapshots/sdk/desktop-ptc-context/cordis.yml
+++ b/snapshots/sdk/desktop-ptc-context/cordis.yml
@@ -41,11 +41,6 @@
- id: tool-executor-ptc
disabled: false
-# The recorded tool catalog includes the optional patch tool.
-- id: tool-fs
- config:
- applyPatch: true
-
# Recorded programs are async function bodies, so replay keeps the per-call runtime.
- id: ptc-runtime
config:
diff --git a/snapshots/sdk/legacy-context.patch.yml b/snapshots/sdk/legacy-context.patch.yml
index 0775a0fee5..d97d66ab4a 100644
--- a/snapshots/sdk/legacy-context.patch.yml
+++ b/snapshots/sdk/legacy-context.patch.yml
@@ -27,8 +27,3 @@
- id: tool-cordis
disabled: true
-
-# The recorded tool catalog includes the optional patch tool.
-- id: tool-fs
- config:
- applyPatch: true
diff --git a/snapshots/sdk/team-default-enabled/session.1.v4.jsonl b/snapshots/sdk/team-default-enabled/session.1.v4.jsonl
index 2c3697dd22..7469cae451 100644
--- a/snapshots/sdk/team-default-enabled/session.1.v4.jsonl
+++ b/snapshots/sdk/team-default-enabled/session.1.v4.jsonl
@@ -6,7 +6,7 @@
{"type":"turn/start","data":{"turn":1}}
{"type":"agent/inbox/spliced","data":{"target":"next-turn","start":0,"removedCount":1,"inserted":[]}}
{"type":"step/start","data":{"turn":1,"step":1}}
-{"type":"system/message","data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"team:policy","order":600,"state":"active","contentIndex":2},{"name":"context:file-reference","order":900,"state":"active","contentIndex":3},{"name":"tool:bash","order":1000,"state":"active","contentIndex":4},{"name":"tool:read","order":1100,"state":"active","contentIndex":5},{"name":"tool:write","order":1200,"state":"active","contentIndex":6},{"name":"tool:edit","order":1300,"state":"active","contentIndex":7},{"name":"tool:glob","order":1400,"state":"active","contentIndex":8},{"name":"tool:grep","order":1500,"state":"active","contentIndex":9},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":10},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":11},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":12},{"name":"tool:goal","order":2400,"state":"active","contentIndex":13},{"name":"tool:schedule","order":2500,"state":"active","contentIndex":14},{"name":"tool:workflow","order":2600,"state":"active","contentIndex":15},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":16},{"name":"ui:deliverable-file-references","order":9000,"state":"active","contentIndex":17}]},"id":"{{message:15}}"}},"surfaceOp":"append"}
+{"type":"system/message","data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"team:policy","order":600,"state":"active","contentIndex":2},{"name":"context:file-reference","order":900,"state":"active","contentIndex":3},{"name":"tool:bash","order":1000,"state":"active","contentIndex":4},{"name":"tool:read","order":1100,"state":"active","contentIndex":5},{"name":"tool:write","order":1200,"state":"active","contentIndex":6},{"name":"tool:edit","order":1300,"state":"active","contentIndex":7},{"name":"tool:apply_patch","order":1350,"state":"active","contentIndex":8},{"name":"tool:glob","order":1400,"state":"active","contentIndex":9},{"name":"tool:grep","order":1500,"state":"active","contentIndex":10},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":11},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":12},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":13},{"name":"tool:goal","order":2400,"state":"active","contentIndex":14},{"name":"tool:schedule","order":2500,"state":"active","contentIndex":15},{"name":"tool:workflow","order":2600,"state":"active","contentIndex":16},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":17},{"name":"ui:deliverable-file-references","order":9000,"state":"active","contentIndex":18}]},"id":"{{message:15}}"}},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"Agent lead sent a message: "},{"type":"text","text":"List the shared tasks, verify Configured Team is present, then reply TEAM_CHILD_OK."},{"type":"text","text":"Your final answer is delivered automatically if your parent is still online. Include the result and relevant evidence in that answer; the parent does not receive your full transcript, tool output, or reasoning. If your last action is a message to your parent, the completion notice omits your final answer; include the result and relevant evidence in that message."}],"source":{"kind":"agent-message","form":"relay","senderSessionId":"{{session:1}}"},"role":"user","id":"{{message:14}}"},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"\nThe following information describes your current session:\n\nCurrent working directory: \"{{cwd}}\".\n\nCurrent DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}\". Some platform temporary areas may also be writable.\n\nApproval prompts are disabled in this session: actions that require approval are rejected automatically — do not request sandbox escalation (do not set `sandbox_permissions`).\n\nYou are a subagent delegated by agent \"lead\".\nYour name is \"agent-1\".\nThe root agent of your collaboration tree is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names.\n\nDelegation depth for `subagent`: current 1, maximum 1, remaining levels 0. Do not call `subagent` at this depth; carry out the work directly.\n\nDelegation depth for `subagent_fork`: current 1, maximum 1, remaining levels 0. Do not call `subagent_fork` at this depth; carry out the work directly.\n\nYou are a delegated subagent: your permission scope was fixed when you were started and cannot be widened from inside this session — operations that require approval are rejected automatically. When the task needs access beyond that scope, do not retry the denied operation; state the limitation in your reply so the delegating agent can handle it. Messages from other agents begin with \"Agent sent a message:\". Other user messages come from the human user, who reads this conversation directly. You can still message other agents to coordinate, but answer the human user in your reply.\n"}],"source":{"kind":"runtime-context","form":"snapshot","sections":[{"name":"working-directory:current","text":"Current working directory: \"{{cwd}}\"."},{"name":"sandbox:policy","text":"Current DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}\". Some platform temporary areas may also be writable."},{"name":"approval:policy","text":"Approval prompts are disabled in this session: actions that require approval are rejected automatically — do not request sandbox escalation (do not set `sandbox_permissions`)."},{"name":"subagent:identity","text":"You are a subagent delegated by agent \"lead\".\nYour name is \"agent-1\".\nThe root agent of your collaboration tree is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names."},{"name":"tool:subagent:depth","text":"Delegation depth for `subagent`: current 1, maximum 1, remaining levels 0. Do not call `subagent` at this depth; carry out the work directly."},{"name":"tool:subagent_fork:depth","text":"Delegation depth for `subagent_fork`: current 1, maximum 1, remaining levels 0. Do not call `subagent_fork` at this depth; carry out the work directly."},{"name":"subagent:delegation","text":"You are a delegated subagent: your permission scope was fixed when you were started and cannot be widened from inside this session — operations that require approval are rejected automatically. When the task needs access beyond that scope, do not retry the denied operation; state the limitation in your reply so the delegating agent can handle it. Messages from other agents begin with \"Agent sent a message:\". Other user messages come from the human user, who reads this conversation directly. You can still message other agents to coordinate, but answer the human user in your reply."}]},"role":"user","id":"{{message:16}}"},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"\nA skill is a reusable set of task-specific instructions. The following skills are available in this session:\n\n\n- `office`: Create, read, edit, and validate Word, PowerPoint, and Excel files; render Office files and PDFs; convert or recalculate. Load first to enable office_render, office_convert, and office_recalculate.\n- `official-plugins`: Check DSH’s optional plugins when the user asks how to do or use something in this app, whether it can, or says a capability is missing or should change: tools, input, thinking or title display, session search, terminals, worktrees, agent teams, desktop control, automation, access, approvals, badges or signatures, plugins or plugin sources. Not a request to develop DSH, even in its own repository: load before reading files or source. Not for ordinary tasks, quoted wishes or declined offers.\n- `personalized-pages`: Plan an optional page or small tool when the user asks for a page, tab, panel, tool or interface in this app (even for one-off use), wants something to keep, revisit or update later, will keep changing data in your answer, or wants a live view of this app’s own data (Sessions, tasks, logs, workspace). Load this before reading any files or source; it says how to submit the proposal. Not for requested files or code, ordinary answers, existing-feature questions, quoted wishes or declined offers.\n\n\nIf the user names a skill, or the task clearly matches a skill's description, call the `skill` tool with the exact skill name before taking task actions. Load all applicable skills, then follow their full instructions. This catalog contains summaries only; do not infer or follow a skill's instructions until it has been loaded.\nA user may also invoke a skill directly; its block then appears in this conversation. Follow it, and do not call the `skill` tool again for that skill.\n"}],"source":{"kind":"skill-catalog","form":"catalog","entries":[{"name":"office","description":"Create, read, edit, and validate Word, PowerPoint, and Excel files; render Office files and PDFs; convert or recalculate. Load first to enable office_render, office_convert, and office_recalculate."},{"name":"official-plugins","description":"Check DSH’s optional plugins when the user asks how to do or use something in this app, whether it can, or says a capability is missing or should change: tools, input, thinking or title display, session search, terminals, worktrees, agent teams, desktop control, automation, access, approvals, badges or signatures, plugins or plugin sources. Not a request to develop DSH, even in its own repository: load before reading files or source. Not for ordinary tasks, quoted wishes or declined offers."},{"name":"personalized-pages","description":"Plan an optional page or small tool when the user asks for a page, tab, panel, tool or interface in this app (even for one-off use), wants something to keep, revisit or update later, will keep changing data in your answer, or wants a live view of this app’s own data (Sessions, tasks, logs, workspace). Load this before reading any files or source; it says how to submit the proposal. Not for requested files or code, ordinary answers, existing-feature questions, quoted wishes or declined offers."}]},"role":"user","id":"{{message:17}}"},"surfaceOp":"append"}
diff --git a/snapshots/sdk/team-default-enabled/session.v4.jsonl b/snapshots/sdk/team-default-enabled/session.v4.jsonl
index 7f6729547f..51550d0d1d 100644
--- a/snapshots/sdk/team-default-enabled/session.v4.jsonl
+++ b/snapshots/sdk/team-default-enabled/session.v4.jsonl
@@ -7,7 +7,7 @@
{"type":"turn/start","data":{"turn":1}}
{"type":"agent/inbox/spliced","data":{"target":"next-turn","start":0,"removedCount":1,"inserted":[]}}
{"type":"step/start","data":{"turn":1,"step":1}}
-{"type":"system/message","data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"team:policy","order":600,"state":"active","contentIndex":2},{"name":"context:file-reference","order":900,"state":"active","contentIndex":3},{"name":"tool:bash","order":1000,"state":"active","contentIndex":4},{"name":"tool:read","order":1100,"state":"active","contentIndex":5},{"name":"tool:write","order":1200,"state":"active","contentIndex":6},{"name":"tool:edit","order":1300,"state":"active","contentIndex":7},{"name":"tool:glob","order":1400,"state":"active","contentIndex":8},{"name":"tool:grep","order":1500,"state":"active","contentIndex":9},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":10},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":11},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":12},{"name":"tool:goal","order":2400,"state":"active","contentIndex":13},{"name":"tool:schedule","order":2500,"state":"active","contentIndex":14},{"name":"tool:workflow","order":2600,"state":"active","contentIndex":15},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":16},{"name":"ui:deliverable-file-references","order":9000,"state":"active","contentIndex":17}]},"id":"{{message:2}}"}},"surfaceOp":"append"}
+{"type":"system/message","data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"team:policy","order":600,"state":"active","contentIndex":2},{"name":"context:file-reference","order":900,"state":"active","contentIndex":3},{"name":"tool:bash","order":1000,"state":"active","contentIndex":4},{"name":"tool:read","order":1100,"state":"active","contentIndex":5},{"name":"tool:write","order":1200,"state":"active","contentIndex":6},{"name":"tool:edit","order":1300,"state":"active","contentIndex":7},{"name":"tool:apply_patch","order":1350,"state":"active","contentIndex":8},{"name":"tool:glob","order":1400,"state":"active","contentIndex":9},{"name":"tool:grep","order":1500,"state":"active","contentIndex":10},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":11},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":12},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":13},{"name":"tool:goal","order":2400,"state":"active","contentIndex":14},{"name":"tool:schedule","order":2500,"state":"active","contentIndex":15},{"name":"tool:workflow","order":2600,"state":"active","contentIndex":16},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":17},{"name":"ui:deliverable-file-references","order":9000,"state":"active","contentIndex":18}]},"id":"{{message:2}}"}},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"Create a shared task titled Configured Team with description Enabled by Cordis patch, delegate verification of the shared task board to a subagent, then reply TEAM_CONFIG_OK."}],"source":{"kind":"user","clientTimeZone":"UTC"},"role":"user","id":"{{message:1}}"},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"\nThe following information describes your current session:\n\nCurrent working directory: \"{{cwd}}\".\n\nCurrent DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}\". Some platform temporary areas may also be writable.\n\nApproval prompts are enabled in this session: operations that require approval may ask through the configured answerers; without an available answerer, the request fails closed.\n\nYou are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names.\n"}],"source":{"kind":"runtime-context","form":"snapshot","sections":[{"name":"working-directory:current","text":"Current working directory: \"{{cwd}}\"."},{"name":"sandbox:policy","text":"Current DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}\". Some platform temporary areas may also be writable."},{"name":"approval:policy","text":"Approval prompts are enabled in this session: operations that require approval may ask through the configured answerers; without an available answerer, the request fails closed."},{"name":"subagent:identity","text":"You are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names."}]},"role":"user","id":"{{message:3}}"},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"\nA skill is a reusable set of task-specific instructions. The following skills are available in this session:\n\n\n- `office`: Create, read, edit, and validate Word, PowerPoint, and Excel files; render Office files and PDFs; convert or recalculate. Load first to enable office_render, office_convert, and office_recalculate.\n- `official-plugins`: Check DSH’s optional plugins when the user asks how to do or use something in this app, whether it can, or says a capability is missing or should change: tools, input, thinking or title display, session search, terminals, worktrees, agent teams, desktop control, automation, access, approvals, badges or signatures, plugins or plugin sources. Not a request to develop DSH, even in its own repository: load before reading files or source. Not for ordinary tasks, quoted wishes or declined offers.\n- `personalized-pages`: Plan an optional page or small tool when the user asks for a page, tab, panel, tool or interface in this app (even for one-off use), wants something to keep, revisit or update later, will keep changing data in your answer, or wants a live view of this app’s own data (Sessions, tasks, logs, workspace). Load this before reading any files or source; it says how to submit the proposal. Not for requested files or code, ordinary answers, existing-feature questions, quoted wishes or declined offers.\n\n\nIf the user names a skill, or the task clearly matches a skill's description, call the `skill` tool with the exact skill name before taking task actions. Load all applicable skills, then follow their full instructions. This catalog contains summaries only; do not infer or follow a skill's instructions until it has been loaded.\nA user may also invoke a skill directly; its block then appears in this conversation. Follow it, and do not call the `skill` tool again for that skill.\n"}],"source":{"kind":"skill-catalog","form":"catalog","entries":[{"name":"office","description":"Create, read, edit, and validate Word, PowerPoint, and Excel files; render Office files and PDFs; convert or recalculate. Load first to enable office_render, office_convert, and office_recalculate."},{"name":"official-plugins","description":"Check DSH’s optional plugins when the user asks how to do or use something in this app, whether it can, or says a capability is missing or should change: tools, input, thinking or title display, session search, terminals, worktrees, agent teams, desktop control, automation, access, approvals, badges or signatures, plugins or plugin sources. Not a request to develop DSH, even in its own repository: load before reading files or source. Not for ordinary tasks, quoted wishes or declined offers."},{"name":"personalized-pages","description":"Plan an optional page or small tool when the user asks for a page, tab, panel, tool or interface in this app (even for one-off use), wants something to keep, revisit or update later, will keep changing data in your answer, or wants a live view of this app’s own data (Sessions, tasks, logs, workspace). Load this before reading any files or source; it says how to submit the proposal. Not for requested files or code, ordinary answers, existing-feature questions, quoted wishes or declined offers."}]},"role":"user","id":"{{message:4}}"},"surfaceOp":"append"}
diff --git a/snapshots/sdk/team-default-enabled/system-prompt.1.expected.md b/snapshots/sdk/team-default-enabled/system-prompt.1.expected.md
index fb5d14e28a..c3800c0c44 100644
--- a/snapshots/sdk/team-default-enabled/system-prompt.1.expected.md
+++ b/snapshots/sdk/team-default-enabled/system-prompt.1.expected.md
@@ -20,6 +20,8 @@ Read an existing file before overwriting it with write and prefer edit for targe
Read a file before editing it unless you just created or edited it in this session.
+Prefer apply_patch over separate edit calls for changes across files or separated regions. Give every hunk enough surrounding context lines to match one place in the current file. The whole patch is checked first (syntax, hunk matching, missing files) and a rejected patch changes nothing; once applying starts, operations run in order, stop at the first failure, and are not rolled back, so re-read affected files before retrying when needed.
+
Use the glob tool — not shell find — to discover files by path pattern.
Use the grep tool — not shell grep or rg — to search file contents. Use read on a matched file when you need surrounding context.
diff --git a/snapshots/sdk/team-default-enabled/system-prompt.expected.md b/snapshots/sdk/team-default-enabled/system-prompt.expected.md
index fb5d14e28a..c3800c0c44 100644
--- a/snapshots/sdk/team-default-enabled/system-prompt.expected.md
+++ b/snapshots/sdk/team-default-enabled/system-prompt.expected.md
@@ -20,6 +20,8 @@ Read an existing file before overwriting it with write and prefer edit for targe
Read a file before editing it unless you just created or edited it in this session.
+Prefer apply_patch over separate edit calls for changes across files or separated regions. Give every hunk enough surrounding context lines to match one place in the current file. The whole patch is checked first (syntax, hunk matching, missing files) and a rejected patch changes nothing; once applying starts, operations run in order, stop at the first failure, and are not rolled back, so re-read affected files before retrying when needed.
+
Use the glob tool — not shell find — to discover files by path pattern.
Use the grep tool — not shell grep or rg — to search file contents. Use read on a matched file when you need surrounding context.
diff --git a/snapshots/sdk/team-default-enabled/tool-schemas.1.expected.json b/snapshots/sdk/team-default-enabled/tool-schemas.1.expected.json
index 8730f8b10f..35d2a1716d 100644
--- a/snapshots/sdk/team-default-enabled/tool-schemas.1.expected.json
+++ b/snapshots/sdk/team-default-enabled/tool-schemas.1.expected.json
@@ -1,5 +1,33 @@
{
"initial": [
+ {
+ "name": "apply_patch",
+ "description": "Create, update, delete, or move UTF-8 text files with one patch; prefer it over multiple edit calls when a change spans several files or separated regions.",
+ "parameters": {
+ "type": "object",
+ "properties": {
+ "input": {
+ "type": "string",
+ "description": "Patch text: start with *** Begin Patch and end with *** End Patch. Use *** Add File: path with + lines; *** Update File: path, optionally followed by *** Move to: path, with @@ or @@ context and space-prefixed context, + added, or - removed lines; *** End of File anchors the last hunk to the file end. Use *** Delete File: path to delete. Paths are relative to the Session working directory."
+ },
+ "sandbox_permissions": {
+ "type": "string",
+ "description": "The narrowest wider sandbox mode for a one-shot retry of the exact operation the sandbox just denied; the retry asks the user for approval.",
+ "enum": [
+ "workspace-write",
+ "danger-full-access"
+ ]
+ },
+ "justification": {
+ "type": "string",
+ "description": "Required with sandbox_permissions: one sentence for the user explaining why this exact file operation needs the wider access. Use the language of the user’s current request."
+ }
+ },
+ "required": [
+ "input"
+ ]
+ }
+ },
{
"name": "ask_user_question",
"description": "Ask the user a concise question when you need confirmation, a choice, or missing information before proceeding. An answer item with empty selected and no custom means the user skipped that question: continue without it, do not ask it again, and do not treat the skip as permission.",
diff --git a/snapshots/sdk/team-default-enabled/tool-schemas.expected.json b/snapshots/sdk/team-default-enabled/tool-schemas.expected.json
index 8730f8b10f..35d2a1716d 100644
--- a/snapshots/sdk/team-default-enabled/tool-schemas.expected.json
+++ b/snapshots/sdk/team-default-enabled/tool-schemas.expected.json
@@ -1,5 +1,33 @@
{
"initial": [
+ {
+ "name": "apply_patch",
+ "description": "Create, update, delete, or move UTF-8 text files with one patch; prefer it over multiple edit calls when a change spans several files or separated regions.",
+ "parameters": {
+ "type": "object",
+ "properties": {
+ "input": {
+ "type": "string",
+ "description": "Patch text: start with *** Begin Patch and end with *** End Patch. Use *** Add File: path with + lines; *** Update File: path, optionally followed by *** Move to: path, with @@ or @@ context and space-prefixed context, + added, or - removed lines; *** End of File anchors the last hunk to the file end. Use *** Delete File: path to delete. Paths are relative to the Session working directory."
+ },
+ "sandbox_permissions": {
+ "type": "string",
+ "description": "The narrowest wider sandbox mode for a one-shot retry of the exact operation the sandbox just denied; the retry asks the user for approval.",
+ "enum": [
+ "workspace-write",
+ "danger-full-access"
+ ]
+ },
+ "justification": {
+ "type": "string",
+ "description": "Required with sandbox_permissions: one sentence for the user explaining why this exact file operation needs the wider access. Use the language of the user’s current request."
+ }
+ },
+ "required": [
+ "input"
+ ]
+ }
+ },
{
"name": "ask_user_question",
"description": "Ask the user a concise question when you need confirmation, a choice, or missing information before proceeding. An answer item with empty selected and no custom means the user skipped that question: continue without it, do not ask it again, and do not treat the skip as permission.",
diff --git a/snapshots/session/subagent-agent-preset/session.1.v4.jsonl b/snapshots/session/subagent-agent-preset/session.1.v4.jsonl
index 8ede1c36ab..1d0e0d59e4 100644
--- a/snapshots/session/subagent-agent-preset/session.1.v4.jsonl
+++ b/snapshots/session/subagent-agent-preset/session.1.v4.jsonl
@@ -8,7 +8,7 @@
{"type":"turn/start","data":{"turn":1}}
{"type":"agent/inbox/spliced","data":{"target":"next-turn","start":0,"removedCount":1,"inserted":[]}}
{"type":"step/start","data":{"turn":1,"step":1}}
-{"type":"system/message","data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tool:bash","order":1000,"state":"active","contentIndex":2},{"name":"tool:read","order":1100,"state":"active","contentIndex":3},{"name":"tool:write","order":1200,"state":"active","contentIndex":4},{"name":"tool:edit","order":1300,"state":"active","contentIndex":5},{"name":"tool:glob","order":1400,"state":"active","contentIndex":6},{"name":"tool:grep","order":1500,"state":"active","contentIndex":7},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":8},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":9},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":10},{"name":"tool:goal","order":2400,"state":"active","contentIndex":11},{"name":"tool:workflow","order":2600,"state":"active","contentIndex":12},{"name":"tool:reviewer_delegate","order":2800,"state":"active","contentIndex":13}]},"id":"{{message:10}}"}},"surfaceOp":"append"}
+{"type":"system/message","data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tool:bash","order":1000,"state":"active","contentIndex":2},{"name":"tool:read","order":1100,"state":"active","contentIndex":3},{"name":"tool:write","order":1200,"state":"active","contentIndex":4},{"name":"tool:edit","order":1300,"state":"active","contentIndex":5},{"name":"tool:apply_patch","order":1350,"state":"active","contentIndex":6},{"name":"tool:glob","order":1400,"state":"active","contentIndex":7},{"name":"tool:grep","order":1500,"state":"active","contentIndex":8},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":9},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":10},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":11},{"name":"tool:goal","order":2400,"state":"active","contentIndex":12},{"name":"tool:workflow","order":2600,"state":"active","contentIndex":13},{"name":"tool:reviewer_delegate","order":2800,"state":"active","contentIndex":14}]},"id":"{{message:10}}"}},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"Agent lead sent a message: "},{"type":"text","text":"Reply with exactly the word CHILD_OK and nothing else."},{"type":"text","text":"Your final answer is delivered automatically if your parent is still online. Include the result and relevant evidence in that answer; the parent does not receive your full transcript, tool output, or reasoning. If your last action is a message to your parent, the completion notice omits your final answer; include the result and relevant evidence in that message."}],"source":{"kind":"agent-message","form":"relay","senderSessionId":"{{session:1}}"},"role":"user","id":"{{message:9}}"},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"\nThe following information describes your current session:\n\nCurrent working directory: \"{{cwd}}\".\n\nCurrent DSH file policy: danger-full-access. The DSH file sandbox does not restrict file modifications by available operations.\n\nApproval prompts are disabled in this session: actions that require approval are rejected automatically — do not request sandbox escalation (do not set `sandbox_permissions`).\n\nYou are a subagent delegated by agent \"lead\".\nYour name is \"agent-1\".\nThe root agent of your collaboration tree is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nWhen you finish, use send_message to send a self-contained result to the agent that delegated you. Message any agent as soon as a finding changes what it should do next; sending a message does not end your turn.\nUse list_agents({}) to find your collaborator agents and their names.\n\nDelegation depth for `subagent`: current 1, maximum 1, remaining levels 0. Do not call `subagent` at this depth; carry out the work directly.\n\nDelegation depth for `subagent_fork`: current 1, maximum 1, remaining levels 0. Do not call `subagent_fork` at this depth; carry out the work directly.\n\nDelegation depth for `reviewer_delegate`: current 1, maximum 1, remaining levels 0. Do not call `reviewer_delegate` at this depth; carry out the work directly.\n\nYou are a delegated subagent: your permission scope was fixed when you were started and cannot be widened from inside this session — operations that require approval are rejected automatically. When the task needs access beyond that scope, do not retry the denied operation; state the limitation in your reply so the delegating agent can handle it. Messages from other agents begin with \"Agent sent a message:\". Other user messages come from the human user, who reads this conversation directly. You can still message other agents to coordinate, but answer the human user in your reply.\n"}],"source":{"kind":"runtime-context","form":"snapshot","sections":[{"name":"working-directory:current","text":"Current working directory: \"{{cwd}}\"."},{"name":"sandbox:policy","text":"Current DSH file policy: danger-full-access. The DSH file sandbox does not restrict file modifications by available operations."},{"name":"approval:policy","text":"Approval prompts are disabled in this session: actions that require approval are rejected automatically — do not request sandbox escalation (do not set `sandbox_permissions`)."},{"name":"subagent:identity","text":"You are a subagent delegated by agent \"lead\".\nYour name is \"agent-1\".\nThe root agent of your collaboration tree is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nWhen you finish, use send_message to send a self-contained result to the agent that delegated you. Message any agent as soon as a finding changes what it should do next; sending a message does not end your turn.\nUse list_agents({}) to find your collaborator agents and their names."},{"name":"tool:subagent:depth","text":"Delegation depth for `subagent`: current 1, maximum 1, remaining levels 0. Do not call `subagent` at this depth; carry out the work directly."},{"name":"tool:subagent_fork:depth","text":"Delegation depth for `subagent_fork`: current 1, maximum 1, remaining levels 0. Do not call `subagent_fork` at this depth; carry out the work directly."},{"name":"tool:reviewer_delegate:depth","text":"Delegation depth for `reviewer_delegate`: current 1, maximum 1, remaining levels 0. Do not call `reviewer_delegate` at this depth; carry out the work directly."},{"name":"subagent:delegation","text":"You are a delegated subagent: your permission scope was fixed when you were started and cannot be widened from inside this session — operations that require approval are rejected automatically. When the task needs access beyond that scope, do not retry the denied operation; state the limitation in your reply so the delegating agent can handle it. Messages from other agents begin with \"Agent sent a message:\". Other user messages come from the human user, who reads this conversation directly. You can still message other agents to coordinate, but answer the human user in your reply."}]},"role":"user","id":"{{message:11}}"},"surfaceOp":"append"}
{"type":"request/header","data":{"header":{"config":{"provider":"deepseek-official","model":"deepseek-v4-flash"},"tools":"{{tools}}"},"reason":"initial"}}
diff --git a/snapshots/session/subagent-agent-preset/session.v4.jsonl b/snapshots/session/subagent-agent-preset/session.v4.jsonl
index a27a0ee32d..4a3e5c44ec 100644
--- a/snapshots/session/subagent-agent-preset/session.v4.jsonl
+++ b/snapshots/session/subagent-agent-preset/session.v4.jsonl
@@ -11,7 +11,7 @@
{"type":"turn/start","data":{"turn":1}}
{"type":"agent/inbox/spliced","data":{"target":"next-turn","start":0,"removedCount":1,"inserted":[]}}
{"type":"step/start","data":{"turn":1,"step":1}}
-{"type":"system/message","data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tool:bash","order":1000,"state":"active","contentIndex":2},{"name":"tool:read","order":1100,"state":"active","contentIndex":3},{"name":"tool:write","order":1200,"state":"active","contentIndex":4},{"name":"tool:edit","order":1300,"state":"active","contentIndex":5},{"name":"tool:glob","order":1400,"state":"active","contentIndex":6},{"name":"tool:grep","order":1500,"state":"active","contentIndex":7},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":8},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":9},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":10},{"name":"tool:goal","order":2400,"state":"active","contentIndex":11},{"name":"tool:workflow","order":2600,"state":"active","contentIndex":12},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":13}]},"id":"{{message:2}}"}},"surfaceOp":"append"}
+{"type":"system/message","data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tool:bash","order":1000,"state":"active","contentIndex":2},{"name":"tool:read","order":1100,"state":"active","contentIndex":3},{"name":"tool:write","order":1200,"state":"active","contentIndex":4},{"name":"tool:edit","order":1300,"state":"active","contentIndex":5},{"name":"tool:apply_patch","order":1350,"state":"active","contentIndex":6},{"name":"tool:glob","order":1400,"state":"active","contentIndex":7},{"name":"tool:grep","order":1500,"state":"active","contentIndex":8},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":9},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":10},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":11},{"name":"tool:goal","order":2400,"state":"active","contentIndex":12},{"name":"tool:workflow","order":2600,"state":"active","contentIndex":13},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":14}]},"id":"{{message:2}}"}},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"Use the subagent tool exactly once with agent_preset reviewer to delegate this subtask to a child agent: 'Reply with exactly the word CHILD_OK and nothing else.' After the subagent returns, reply with the single word PARENT_DONE and stop. Do not use the bash tool."}],"source":{"kind":"user"},"role":"user","id":"{{message:1}}"},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"\nThe following information describes your current session:\n\nCurrent working directory: \"{{cwd}}\".\n\nCurrent DSH file policy: danger-full-access. The DSH file sandbox does not restrict file modifications by available operations.\n\nApproval prompts are disabled in this session: actions that require approval are rejected automatically — do not request sandbox escalation (do not set `sandbox_permissions`).\n\nYou are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names.\n"}],"source":{"kind":"runtime-context","form":"snapshot","sections":[{"name":"working-directory:current","text":"Current working directory: \"{{cwd}}\"."},{"name":"sandbox:policy","text":"Current DSH file policy: danger-full-access. The DSH file sandbox does not restrict file modifications by available operations."},{"name":"approval:policy","text":"Approval prompts are disabled in this session: actions that require approval are rejected automatically — do not request sandbox escalation (do not set `sandbox_permissions`)."},{"name":"subagent:identity","text":"You are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names."}]},"role":"user","id":"{{message:3}}"},"surfaceOp":"append"}
{"type":"request/header","data":{"header":{"config":{"provider":"deepseek-official","model":"deepseek-v4-flash"},"tools":"{{tools}}"},"reason":"initial"}}
diff --git a/snapshots/session/subagent-agent-preset/system-prompt.1.expected.md b/snapshots/session/subagent-agent-preset/system-prompt.1.expected.md
index 33240dd487..1fbdb8ed69 100644
--- a/snapshots/session/subagent-agent-preset/system-prompt.1.expected.md
+++ b/snapshots/session/subagent-agent-preset/system-prompt.1.expected.md
@@ -10,6 +10,8 @@ Read an existing file before overwriting it with write and prefer edit for targe
Read a file before editing it unless you just created or edited it in this session.
+Prefer apply_patch over separate edit calls for changes across files or separated regions. Give every hunk enough surrounding context lines to match one place in the current file. The whole patch is checked first (syntax, hunk matching, missing files) and a rejected patch changes nothing; once applying starts, operations run in order, stop at the first failure, and are not rolled back, so re-read affected files before retrying when needed.
+
Use the glob tool — not shell find — to discover files by path pattern.
Use the grep tool — not shell grep or rg — to search file contents. Use read on a matched file when you need surrounding context.
diff --git a/snapshots/session/subagent-agent-preset/system-prompt.expected.md b/snapshots/session/subagent-agent-preset/system-prompt.expected.md
index a1373866ee..4134cf5635 100644
--- a/snapshots/session/subagent-agent-preset/system-prompt.expected.md
+++ b/snapshots/session/subagent-agent-preset/system-prompt.expected.md
@@ -12,6 +12,8 @@ Read an existing file before overwriting it with write and prefer edit for targe
Read a file before editing it unless you just created or edited it in this session.
+Prefer apply_patch over separate edit calls for changes across files or separated regions. Give every hunk enough surrounding context lines to match one place in the current file. The whole patch is checked first (syntax, hunk matching, missing files) and a rejected patch changes nothing; once applying starts, operations run in order, stop at the first failure, and are not rolled back, so re-read affected files before retrying when needed.
+
Use the glob tool — not shell find — to discover files by path pattern.
Use the grep tool — not shell grep or rg — to search file contents. Use read on a matched file when you need surrounding context.
diff --git a/snapshots/session/subagent-agent-preset/tool-schemas.1.expected.json b/snapshots/session/subagent-agent-preset/tool-schemas.1.expected.json
index b0df435e68..5413497031 100644
--- a/snapshots/session/subagent-agent-preset/tool-schemas.1.expected.json
+++ b/snapshots/session/subagent-agent-preset/tool-schemas.1.expected.json
@@ -1,5 +1,33 @@
{
"initial": [
+ {
+ "name": "apply_patch",
+ "description": "Create, update, delete, or move UTF-8 text files with one patch; prefer it over multiple edit calls when a change spans several files or separated regions.",
+ "parameters": {
+ "type": "object",
+ "properties": {
+ "input": {
+ "type": "string",
+ "description": "Patch text: start with *** Begin Patch and end with *** End Patch. Use *** Add File: path with + lines; *** Update File: path, optionally followed by *** Move to: path, with @@ or @@ context and space-prefixed context, + added, or - removed lines; *** End of File anchors the last hunk to the file end. Use *** Delete File: path to delete. Paths are relative to the Session working directory."
+ },
+ "sandbox_permissions": {
+ "type": "string",
+ "description": "The narrowest wider sandbox mode for a one-shot retry of the exact operation the sandbox just denied; the retry asks the user for approval.",
+ "enum": [
+ "workspace-write",
+ "danger-full-access"
+ ]
+ },
+ "justification": {
+ "type": "string",
+ "description": "Required with sandbox_permissions: one sentence for the user explaining why this exact file operation needs the wider access. Use the language of the user’s current request."
+ }
+ },
+ "required": [
+ "input"
+ ]
+ }
+ },
{
"name": "bash",
"description": "Execute a bash command (`bash -c`) and return its stdout/stderr. Each call runs in a fresh shell; pass `workdir` instead of using `cd`. Managed `$DSH_*` variables expose current harness environment facts. Long output is truncated to its tail; the full output is saved to a file whose path is reported when available. Provide `description` before `command` in the arguments. Before any delete or move, verify that the resolved absolute target path is the intended one; never run it against a computed path you have not checked. An unset variable expands to an empty string, so guard variables in such paths with `${VAR:?}`. Commands may run under a file sandbox; a blocked file operation is reported as `[sandbox: file access denied under mode]`, a policy denial: do not retry another way.",
diff --git a/snapshots/session/subagent-agent-preset/tool-schemas.expected.json b/snapshots/session/subagent-agent-preset/tool-schemas.expected.json
index cce4364f45..f67c62d191 100644
--- a/snapshots/session/subagent-agent-preset/tool-schemas.expected.json
+++ b/snapshots/session/subagent-agent-preset/tool-schemas.expected.json
@@ -1,5 +1,33 @@
{
"initial": [
+ {
+ "name": "apply_patch",
+ "description": "Create, update, delete, or move UTF-8 text files with one patch; prefer it over multiple edit calls when a change spans several files or separated regions.",
+ "parameters": {
+ "type": "object",
+ "properties": {
+ "input": {
+ "type": "string",
+ "description": "Patch text: start with *** Begin Patch and end with *** End Patch. Use *** Add File: path with + lines; *** Update File: path, optionally followed by *** Move to: path, with @@ or @@ context and space-prefixed context, + added, or - removed lines; *** End of File anchors the last hunk to the file end. Use *** Delete File: path to delete. Paths are relative to the Session working directory."
+ },
+ "sandbox_permissions": {
+ "type": "string",
+ "description": "The narrowest wider sandbox mode for a one-shot retry of the exact operation the sandbox just denied; the retry asks the user for approval.",
+ "enum": [
+ "workspace-write",
+ "danger-full-access"
+ ]
+ },
+ "justification": {
+ "type": "string",
+ "description": "Required with sandbox_permissions: one sentence for the user explaining why this exact file operation needs the wider access. Use the language of the user’s current request."
+ }
+ },
+ "required": [
+ "input"
+ ]
+ }
+ },
{
"name": "bash",
"description": "Execute a bash command (`bash -c`) and return its stdout/stderr. Each call runs in a fresh shell; pass `workdir` instead of using `cd`. Managed `$DSH_*` variables expose current harness environment facts. Long output is truncated to its tail; the full output is saved to a file whose path is reported when available. Provide `description` before `command` in the arguments. Before any delete or move, verify that the resolved absolute target path is the intended one; never run it against a computed path you have not checked. An unset variable expands to an empty string, so guard variables in such paths with `${VAR:?}`. Commands may run under a file sandbox; a blocked file operation is reported as `[sandbox: file access denied under mode]`, a policy denial: do not retry another way.",
diff --git a/snapshots/session/subagent-no-message-tool/cordis.snapshot.yml b/snapshots/session/subagent-no-message-tool/cordis.snapshot.yml
index 380fbee018..24ba160026 100644
--- a/snapshots/session/subagent-no-message-tool/cordis.snapshot.yml
+++ b/snapshots/session/subagent-no-message-tool/cordis.snapshot.yml
@@ -63,8 +63,6 @@
id: parent
plugins:
- name: '@deepseek-ai/dsh-tool-fs'
- config:
- applyPatch: true
- name: '@deepseek-ai/dsh-tool-fs-search'
config:
sampleOverCapGlobResults: false
diff --git a/snapshots/session/subagent-no-message-tool/cordis.yml b/snapshots/session/subagent-no-message-tool/cordis.yml
index fa1f0dbd6c..5d4851818d 100644
--- a/snapshots/session/subagent-no-message-tool/cordis.yml
+++ b/snapshots/session/subagent-no-message-tool/cordis.yml
@@ -22,8 +22,6 @@
id: parent
plugins:
- name: '@deepseek-ai/dsh-tool-fs'
- config:
- applyPatch: true
- name: '@deepseek-ai/dsh-tool-fs-search'
config:
sampleOverCapGlobResults: false
diff --git a/snapshots/session/subagent-tool-filter/cordis.snapshot.yml b/snapshots/session/subagent-tool-filter/cordis.snapshot.yml
index 95a4704dda..d8e94149f0 100644
--- a/snapshots/session/subagent-tool-filter/cordis.snapshot.yml
+++ b/snapshots/session/subagent-tool-filter/cordis.snapshot.yml
@@ -60,8 +60,6 @@
id: parent
plugins:
- name: '@deepseek-ai/dsh-tool-fs'
- config:
- applyPatch: true
- name: '@deepseek-ai/dsh-tool-fs-search'
config:
sampleOverCapGlobResults: false
diff --git a/snapshots/session/subagent-tool-filter/cordis.yml b/snapshots/session/subagent-tool-filter/cordis.yml
index 89d231bedd..d879f555f8 100644
--- a/snapshots/session/subagent-tool-filter/cordis.yml
+++ b/snapshots/session/subagent-tool-filter/cordis.yml
@@ -19,8 +19,6 @@
id: parent
plugins:
- name: '@deepseek-ai/dsh-tool-fs'
- config:
- applyPatch: true
- name: '@deepseek-ai/dsh-tool-fs-search'
config:
sampleOverCapGlobResults: false
diff --git a/snapshots/session/text-turn/cordis.yml b/snapshots/session/text-turn/cordis.yml
index 59ced934d8..dd4fe733e6 100644
--- a/snapshots/session/text-turn/cordis.yml
+++ b/snapshots/session/text-turn/cordis.yml
@@ -79,8 +79,3 @@
- id: session-log-deepseek
config:
enabled: false
-
-# The recorded tool catalog includes the optional patch tool.
-- id: tool-fs
- config:
- applyPatch: true
diff --git a/snapshots/web/creator-persona/session.v4.jsonl b/snapshots/web/creator-persona/session.v4.jsonl
index 4e5cc93170..bb8e9a89f0 100644
--- a/snapshots/web/creator-persona/session.v4.jsonl
+++ b/snapshots/web/creator-persona/session.v4.jsonl
@@ -6,7 +6,7 @@
{"type":"turn/start","data":{"turn":1}}
{"type":"agent/inbox/spliced","data":{"target":"next-turn","start":0,"removedCount":1,"inserted":[]}}
{"type":"step/start","data":{"turn":1,"step":1}}
-{"type":"system/message","data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"context:file-reference","order":900,"state":"active","contentIndex":2},{"name":"tool:bash","order":1000,"state":"active","contentIndex":3},{"name":"tool:read","order":1100,"state":"active","contentIndex":4},{"name":"tool:write","order":1200,"state":"active","contentIndex":5},{"name":"tool:edit","order":1300,"state":"active","contentIndex":6},{"name":"tool:glob","order":1400,"state":"active","contentIndex":7},{"name":"tool:grep","order":1500,"state":"active","contentIndex":8},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":9},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":10},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":11},{"name":"tool:goal","order":2400,"state":"active","contentIndex":12},{"name":"tool:schedule","order":2500,"state":"active","contentIndex":13},{"name":"tool:workflow","order":2600,"state":"active","contentIndex":14},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":15},{"name":"ui:deliverable-file-references","order":9000,"state":"active","contentIndex":16},{"name":"harness:source","order":10000,"state":"active","contentIndex":17},{"name":"app:web-surface","order":10100,"state":"active","contentIndex":18}]},"id":"{{message:2}}"}},"surfaceOp":"append"}
+{"type":"system/message","data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"context:file-reference","order":900,"state":"active","contentIndex":2},{"name":"tool:bash","order":1000,"state":"active","contentIndex":3},{"name":"tool:read","order":1100,"state":"active","contentIndex":4},{"name":"tool:write","order":1200,"state":"active","contentIndex":5},{"name":"tool:edit","order":1300,"state":"active","contentIndex":6},{"name":"tool:apply_patch","order":1350,"state":"active","contentIndex":7},{"name":"tool:glob","order":1400,"state":"active","contentIndex":8},{"name":"tool:grep","order":1500,"state":"active","contentIndex":9},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":10},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":11},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":12},{"name":"tool:goal","order":2400,"state":"active","contentIndex":13},{"name":"tool:schedule","order":2500,"state":"active","contentIndex":14},{"name":"tool:workflow","order":2600,"state":"active","contentIndex":15},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":16},{"name":"ui:deliverable-file-references","order":9000,"state":"active","contentIndex":17},{"name":"harness:source","order":10000,"state":"active","contentIndex":18},{"name":"app:web-surface","order":10100,"state":"active","contentIndex":19}]},"id":"{{message:2}}"}},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"Reply READY without using tools or changing files."}],"source":{"kind":"user","rpcId":"{{rpc:1}}","clientTimeZone":"{{clientTimeZone}}"},"role":"user","id":"{{message:1}}"},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"\nThe following information describes your current session:\n\nCurrent working directory: \"{{cwd}}\".\n\nCurrent DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}\". Some platform temporary areas may also be writable.\n\nApproval prompts are enabled in this session: operations that require approval may ask through the configured answerers; without an available answerer, the request fails closed.\n\nYou are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names.\n\nCurrent DeepSeek Harness implementation checkout: \"{{sourceRoot}}\".\n\nCurrent DeepSeek Harness Web GUI URL: \"{{webUrl}}\".\n"}],"source":{"kind":"runtime-context","form":"snapshot","sections":[{"name":"working-directory:current","text":"Current working directory: \"{{cwd}}\"."},{"name":"sandbox:policy","text":"Current DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}\". Some platform temporary areas may also be writable."},{"name":"approval:policy","text":"Approval prompts are enabled in this session: operations that require approval may ask through the configured answerers; without an available answerer, the request fails closed."},{"name":"subagent:identity","text":"You are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names."},{"name":"harness:source","text":"Current DeepSeek Harness implementation checkout: \"{{sourceRoot}}\"."},{"name":"app:web-surface","text":"Current DeepSeek Harness Web GUI URL: \"{{webUrl}}\"."}]},"role":"user","id":"{{message:3}}"},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"\nA skill is a reusable set of task-specific instructions. The following skills are available in this session:\n\n\n- `dsh-doc`: Use when a task needs facts about DeepSeek Harness (DSH) itself, such as how a feature, setting, plugin, agent preset, tool, or Cordis API of the running installation works; when the user asks to design, review, build, install, enable, or debug a DSH plugin, bundle, MCP connection, agent preset, plugin icon or detail page, or a DSH tool definition or skill; and when upgrading a plugin or profile to a newer DSH release. Loading it grants no permission to change files or the profile.\n- `office`: Create, read, edit, and validate Word, PowerPoint, and Excel files; render Office files and PDFs; convert or recalculate. Load first to enable office_render, office_convert, and office_recalculate.\n\n\nIf the user names a skill, or the task clearly matches a skill's description, call the `skill` tool with the exact skill name before taking task actions. Load all applicable skills, then follow their full instructions. This catalog contains summaries only; do not infer or follow a skill's instructions until it has been loaded.\nA user may also invoke a skill directly; its block then appears in this conversation. Follow it, and do not call the `skill` tool again for that skill.\n"}],"source":{"kind":"skill-catalog","form":"catalog","entries":[{"name":"dsh-doc","description":"Use when a task needs facts about DeepSeek Harness (DSH) itself, such as how a feature, setting, plugin, agent preset, tool, or Cordis API of the running installation works; when the user asks to design, review, build, install, enable, or debug a DSH plugin, bundle, MCP connection, agent preset, plugin icon or detail page, or a DSH tool definition or skill; and when upgrading a plugin or profile to a newer DSH release. Loading it grants no permission to change files or the profile."},{"name":"office","description":"Create, read, edit, and validate Word, PowerPoint, and Excel files; render Office files and PDFs; convert or recalculate. Load first to enable office_render, office_convert, and office_recalculate."}]},"role":"user","id":"{{message:4}}"},"surfaceOp":"append"}
diff --git a/snapshots/web/creator-persona/system-prompt.expected.md b/snapshots/web/creator-persona/system-prompt.expected.md
index b56406addb..329292126f 100644
--- a/snapshots/web/creator-persona/system-prompt.expected.md
+++ b/snapshots/web/creator-persona/system-prompt.expected.md
@@ -12,6 +12,8 @@ Read an existing file before overwriting it with write and prefer edit for targe
Read a file before editing it unless you just created or edited it in this session.
+Prefer apply_patch over separate edit calls for changes across files or separated regions. Give every hunk enough surrounding context lines to match one place in the current file. The whole patch is checked first (syntax, hunk matching, missing files) and a rejected patch changes nothing; once applying starts, operations run in order, stop at the first failure, and are not rolled back, so re-read affected files before retrying when needed.
+
Use the glob tool — not shell find — to discover files by path pattern.
Use the grep tool — not shell grep or rg — to search file contents. Use read on a matched file when you need surrounding context.
diff --git a/snapshots/web/creator-persona/tool-schemas.expected.json b/snapshots/web/creator-persona/tool-schemas.expected.json
index 66e6381ba6..f7a29f0980 100644
--- a/snapshots/web/creator-persona/tool-schemas.expected.json
+++ b/snapshots/web/creator-persona/tool-schemas.expected.json
@@ -1,5 +1,33 @@
{
"initial": [
+ {
+ "name": "apply_patch",
+ "description": "Create, update, delete, or move UTF-8 text files with one patch; prefer it over multiple edit calls when a change spans several files or separated regions.",
+ "parameters": {
+ "type": "object",
+ "properties": {
+ "input": {
+ "type": "string",
+ "description": "Patch text: start with *** Begin Patch and end with *** End Patch. Use *** Add File: path with + lines; *** Update File: path, optionally followed by *** Move to: path, with @@ or @@ context and space-prefixed context, + added, or - removed lines; *** End of File anchors the last hunk to the file end. Use *** Delete File: path to delete. Paths are relative to the Session working directory."
+ },
+ "sandbox_permissions": {
+ "type": "string",
+ "description": "The narrowest wider sandbox mode for a one-shot retry of the exact operation the sandbox just denied; the retry asks the user for approval.",
+ "enum": [
+ "workspace-write",
+ "danger-full-access"
+ ]
+ },
+ "justification": {
+ "type": "string",
+ "description": "Required with sandbox_permissions: one sentence for the user explaining why this exact file operation needs the wider access. Use the language of the user’s current request."
+ }
+ },
+ "required": [
+ "input"
+ ]
+ }
+ },
{
"name": "ask_user_question",
"description": "Ask the user a concise question when you need confirmation, a choice, or missing information before proceeding. An answer item with empty selected and no custom means the user skipped that question: continue without it, do not ask it again, and do not treat the skip as permission.",
diff --git a/snapshots/web/official-subagent-bundle/session.v4.jsonl b/snapshots/web/official-subagent-bundle/session.v4.jsonl
index 6a7b0b8afe..f6eb9848bb 100644
--- a/snapshots/web/official-subagent-bundle/session.v4.jsonl
+++ b/snapshots/web/official-subagent-bundle/session.v4.jsonl
@@ -7,7 +7,7 @@
{"type":"turn/start","data":{"turn":1}}
{"type":"agent/inbox/spliced","data":{"target":"next-turn","start":0,"removedCount":1,"inserted":[]}}
{"type":"step/start","data":{"turn":1,"step":1}}
-{"type":"system/message","data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tools:ptc-only","order":800,"state":"active","contentIndex":2},{"name":"context:file-reference","order":900,"state":"active","contentIndex":3},{"name":"tool:bash","order":1000,"state":"active","contentIndex":4},{"name":"tool:read","order":1100,"state":"active","contentIndex":5},{"name":"tool:write","order":1200,"state":"active","contentIndex":6},{"name":"tool:edit","order":1300,"state":"active","contentIndex":7},{"name":"tool:glob","order":1400,"state":"active","contentIndex":8},{"name":"tool:grep","order":1500,"state":"active","contentIndex":9},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":10},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":11},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":12},{"name":"tool:goal","order":2400,"state":"active","contentIndex":13},{"name":"tool:schedule","order":2500,"state":"active","contentIndex":14},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":15},{"name":"tools:sdk","order":5000,"state":"active","contentIndex":16},{"name":"ui:deliverable-file-references","order":9000,"state":"active","contentIndex":17},{"name":"harness:source","order":10000,"state":"active","contentIndex":18},{"name":"app:web-surface","order":10100,"state":"active","contentIndex":19}]},"id":"{{message:2}}"}},"surfaceOp":"append"}
+{"type":"system/message","data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tools:ptc-only","order":800,"state":"active","contentIndex":2},{"name":"context:file-reference","order":900,"state":"active","contentIndex":3},{"name":"tool:bash","order":1000,"state":"active","contentIndex":4},{"name":"tool:read","order":1100,"state":"active","contentIndex":5},{"name":"tool:write","order":1200,"state":"active","contentIndex":6},{"name":"tool:edit","order":1300,"state":"active","contentIndex":7},{"name":"tool:apply_patch","order":1350,"state":"active","contentIndex":8},{"name":"tool:glob","order":1400,"state":"active","contentIndex":9},{"name":"tool:grep","order":1500,"state":"active","contentIndex":10},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":11},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":12},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":13},{"name":"tool:goal","order":2400,"state":"active","contentIndex":14},{"name":"tool:schedule","order":2500,"state":"active","contentIndex":15},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":16},{"name":"tools:sdk","order":5000,"state":"active","contentIndex":17},{"name":"ui:deliverable-file-references","order":9000,"state":"active","contentIndex":18},{"name":"harness:source","order":10000,"state":"active","contentIndex":19},{"name":"app:web-surface","order":10100,"state":"active","contentIndex":20}]},"id":"{{message:2}}"}},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"Delegate a self-contained task to the official Claude Code subagent through its generated tools SDK in one run_code program. Ask it to reply with OFFICIAL_SUBAGENT_OK exactly, print its child ID, and wait for its completion notice before replying DONE."}],"source":{"kind":"user","rpcId":"{{rpc:1}}","clientTimeZone":"{{clientTimeZone}}"},"role":"user","id":"{{message:1}}"},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"\nThe following information describes your current session:\n\nCurrent working directory: \"{{cwd}}\".\n\nCurrent DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}\". Some platform temporary areas may also be writable.\n\nApproval prompts are enabled in this session: operations that require approval may ask through the configured answerers; without an available answerer, the request fails closed.\n\nYou are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names.\n\nCurrent DeepSeek Harness implementation checkout: \"{{sourceRoot}}\".\n\nCurrent DeepSeek Harness Web GUI URL: \"{{webUrl}}\".\n"}],"source":{"kind":"runtime-context","form":"snapshot","sections":[{"name":"working-directory:current","text":"Current working directory: \"{{cwd}}\"."},{"name":"sandbox:policy","text":"Current DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}\". Some platform temporary areas may also be writable."},{"name":"approval:policy","text":"Approval prompts are enabled in this session: operations that require approval may ask through the configured answerers; without an available answerer, the request fails closed."},{"name":"subagent:identity","text":"You are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names."},{"name":"harness:source","text":"Current DeepSeek Harness implementation checkout: \"{{sourceRoot}}\"."},{"name":"app:web-surface","text":"Current DeepSeek Harness Web GUI URL: \"{{webUrl}}\"."}]},"role":"user","id":"{{message:3}}"},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"\nA skill is a reusable set of task-specific instructions. The following skills are available in this session:\n\n\n- `dsh-doc`: Use when a task needs facts about DeepSeek Harness (DSH) itself, such as how a feature, setting, plugin, agent preset, tool, or Cordis API of the running installation works; when the user asks to design, review, build, install, enable, or debug a DSH plugin, bundle, MCP connection, agent preset, plugin icon or detail page, or a DSH tool definition or skill; and when upgrading a plugin or profile to a newer DSH release. Loading it grants no permission to change files or the profile.\n- `office`: Create, read, edit, and validate Word, PowerPoint, and Excel files; render Office files and PDFs; convert or recalculate. Load first to enable office_render, office_convert, and office_recalculate.\n\n\nIf the user names a skill, or the task clearly matches a skill's description, call the `skill` tool with the exact skill name before taking task actions. Load all applicable skills, then follow their full instructions. This catalog contains summaries only; do not infer or follow a skill's instructions until it has been loaded.\nA user may also invoke a skill directly; its block then appears in this conversation. Follow it, and do not call the `skill` tool again for that skill.\n"}],"source":{"kind":"skill-catalog","form":"catalog","entries":[{"name":"dsh-doc","description":"Use when a task needs facts about DeepSeek Harness (DSH) itself, such as how a feature, setting, plugin, agent preset, tool, or Cordis API of the running installation works; when the user asks to design, review, build, install, enable, or debug a DSH plugin, bundle, MCP connection, agent preset, plugin icon or detail page, or a DSH tool definition or skill; and when upgrading a plugin or profile to a newer DSH release. Loading it grants no permission to change files or the profile."},{"name":"office","description":"Create, read, edit, and validate Word, PowerPoint, and Excel files; render Office files and PDFs; convert or recalculate. Load first to enable office_render, office_convert, and office_recalculate."}]},"role":"user","id":"{{message:4}}"},"surfaceOp":"append"}
diff --git a/snapshots/web/official-subagent-bundle/system-prompt.expected.md b/snapshots/web/official-subagent-bundle/system-prompt.expected.md
index c99f0cd448..5a9554d76f 100644
--- a/snapshots/web/official-subagent-bundle/system-prompt.expected.md
+++ b/snapshots/web/official-subagent-bundle/system-prompt.expected.md
@@ -14,6 +14,8 @@ Read an existing file before overwriting it with write and prefer edit for targe
Read a file before editing it unless you just created or edited it in this session.
+Prefer apply_patch over separate edit calls for changes across files or separated regions. Give every hunk enough surrounding context lines to match one place in the current file. The whole patch is checked first (syntax, hunk matching, missing files) and a rejected patch changes nothing; once applying starts, operations run in order, stop at the first failure, and are not rolled back, so re-read affected files before retrying when needed.
+
Use the glob tool — not shell find — to discover files by path pattern.
Use the grep tool — not shell grep or rg — to search file contents. Use read on a matched file when you need surrounding context.
@@ -55,6 +57,15 @@ declare class Image { private constructor(); readonly attachmentId: string; read
declare function inspect(...values: unknown[]): void;
interface ToolArgsMap {
+ /** Create, update, delete, or move UTF-8 text files with one patch; prefer it over multiple edit calls when a change spans several files or separated regions. */
+ apply_patch: {
+ /** Patch text: start with *** Begin Patch and end with *** End Patch. Use *** Add File: path with + lines; *** Update File: path, optionally followed by *** Move to: path, with @@ or @@ context and space-prefixed context, + added, or - removed lines; *** End of File anchors the last hunk to the file end. Use *** Delete File: path to delete. Paths are relative to the Session working directory. */
+ input: string;
+ /** The narrowest wider sandbox mode for a one-shot retry of the exact operation the sandbox just denied; the retry asks the user for approval. */
+ sandbox_permissions?: "workspace-write" | "danger-full-access";
+ /** Required with sandbox_permissions: one sentence for the user explaining why this exact file operation needs the wider access. Use the language of the user’s current request. */
+ justification?: string;
+ } & Record;
/** Ask the user a concise question when you need confirmation, a choice, or missing information before proceeding. An answer item with empty selected and no custom means the user skipped that question: continue without it, do not ask it again, and do not treat the skip as permission. */
ask_user_question: {
/** Questions to ask the user before continuing. */
@@ -348,6 +359,27 @@ interface ToolArgsMap {
}
interface ToolOutputMap {
+ apply_patch: {
+ phase: "commit";
+ cancelled: boolean;
+ operations: ({
+ index: number;
+ kind: "add" | "update" | "delete" | "move";
+ path: string;
+ destination?: string;
+ patchLine: number;
+ status: "completed" | "failed" | "unknown" | "skipped";
+ code?: string;
+ message?: string;
+ hunkLine?: number;
+ changes?: ({
+ path: string;
+ before: string | null;
+ after: string | null;
+ })[];
+ })[];
+ affectedPaths: string[];
+ };
ask_user_question: {
answers: {
id: string;
diff --git a/snapshots/web/optional-string-editor/session.v4.jsonl b/snapshots/web/optional-string-editor/session.v4.jsonl
index 7c0133b3ff..0c64f95be1 100644
--- a/snapshots/web/optional-string-editor/session.v4.jsonl
+++ b/snapshots/web/optional-string-editor/session.v4.jsonl
@@ -7,7 +7,7 @@
{"type":"turn/start","data":{"turn":1}}
{"type":"agent/inbox/spliced","data":{"target":"next-turn","start":0,"removedCount":1,"inserted":[]}}
{"type":"step/start","data":{"turn":1,"step":1}}
-{"type":"system/message","data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tools:ptc-only","order":800,"state":"active","contentIndex":2},{"name":"context:file-reference","order":900,"state":"active","contentIndex":3},{"name":"tool:bash","order":1000,"state":"active","contentIndex":4},{"name":"tool:read","order":1100,"state":"active","contentIndex":5},{"name":"tool:write","order":1200,"state":"active","contentIndex":6},{"name":"tool:edit","order":1300,"state":"active","contentIndex":7},{"name":"tool:glob","order":1400,"state":"active","contentIndex":8},{"name":"tool:grep","order":1500,"state":"active","contentIndex":9},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":10},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":11},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":12},{"name":"tool:goal","order":2400,"state":"active","contentIndex":13},{"name":"tool:schedule","order":2500,"state":"active","contentIndex":14},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":15},{"name":"tools:sdk","order":5000,"state":"active","contentIndex":16},{"name":"ui:deliverable-file-references","order":9000,"state":"active","contentIndex":17},{"name":"harness:source","order":10000,"state":"active","contentIndex":18},{"name":"app:web-surface","order":10100,"state":"active","contentIndex":19}]},"id":"{{message:2}}"}},"surfaceOp":"append"}
+{"type":"system/message","data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tools:ptc-only","order":800,"state":"active","contentIndex":2},{"name":"context:file-reference","order":900,"state":"active","contentIndex":3},{"name":"tool:bash","order":1000,"state":"active","contentIndex":4},{"name":"tool:read","order":1100,"state":"active","contentIndex":5},{"name":"tool:write","order":1200,"state":"active","contentIndex":6},{"name":"tool:edit","order":1300,"state":"active","contentIndex":7},{"name":"tool:apply_patch","order":1350,"state":"active","contentIndex":8},{"name":"tool:glob","order":1400,"state":"active","contentIndex":9},{"name":"tool:grep","order":1500,"state":"active","contentIndex":10},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":11},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":12},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":13},{"name":"tool:goal","order":2400,"state":"active","contentIndex":14},{"name":"tool:schedule","order":2500,"state":"active","contentIndex":15},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":16},{"name":"tools:sdk","order":5000,"state":"active","contentIndex":17},{"name":"ui:deliverable-file-references","order":9000,"state":"active","contentIndex":18},{"name":"harness:source","order":10000,"state":"active","contentIndex":19},{"name":"app:web-surface","order":10100,"state":"active","contentIndex":20}]},"id":"{{message:2}}"}},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"Use the optional string editor from the generated tools SDK in one run_code program to create edited.txt in the working directory containing exactly PTC_EDITOR_OK followed by a newline. Print the editor result, then reply DONE."}],"source":{"kind":"user","rpcId":"{{rpc:1}}","clientTimeZone":"{{clientTimeZone}}"},"role":"user","id":"{{message:1}}"},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"\nThe following information describes your current session:\n\nCurrent working directory: \"{{cwd}}\".\n\nCurrent DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}\". Some platform temporary areas may also be writable.\n\nApproval prompts are enabled in this session: operations that require approval may ask through the configured answerers; without an available answerer, the request fails closed.\n\nYou are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names.\n\nCurrent DeepSeek Harness implementation checkout: \"{{sourceRoot}}\".\n\nCurrent DeepSeek Harness Web GUI URL: \"{{webUrl}}\".\n"}],"source":{"kind":"runtime-context","form":"snapshot","sections":[{"name":"working-directory:current","text":"Current working directory: \"{{cwd}}\"."},{"name":"sandbox:policy","text":"Current DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}\". Some platform temporary areas may also be writable."},{"name":"approval:policy","text":"Approval prompts are enabled in this session: operations that require approval may ask through the configured answerers; without an available answerer, the request fails closed."},{"name":"subagent:identity","text":"You are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names."},{"name":"harness:source","text":"Current DeepSeek Harness implementation checkout: \"{{sourceRoot}}\"."},{"name":"app:web-surface","text":"Current DeepSeek Harness Web GUI URL: \"{{webUrl}}\"."}]},"role":"user","id":"{{message:3}}"},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"\nA skill is a reusable set of task-specific instructions. The following skills are available in this session:\n\n\n- `dsh-doc`: Use when a task needs facts about DeepSeek Harness (DSH) itself, such as how a feature, setting, plugin, agent preset, tool, or Cordis API of the running installation works; when the user asks to design, review, build, install, enable, or debug a DSH plugin, bundle, MCP connection, agent preset, plugin icon or detail page, or a DSH tool definition or skill; and when upgrading a plugin or profile to a newer DSH release. Loading it grants no permission to change files or the profile.\n- `office`: Create, read, edit, and validate Word, PowerPoint, and Excel files; render Office files and PDFs; convert or recalculate. Load first to enable office_render, office_convert, and office_recalculate.\n\n\nIf the user names a skill, or the task clearly matches a skill's description, call the `skill` tool with the exact skill name before taking task actions. Load all applicable skills, then follow their full instructions. This catalog contains summaries only; do not infer or follow a skill's instructions until it has been loaded.\nA user may also invoke a skill directly; its block then appears in this conversation. Follow it, and do not call the `skill` tool again for that skill.\n"}],"source":{"kind":"skill-catalog","form":"catalog","entries":[{"name":"dsh-doc","description":"Use when a task needs facts about DeepSeek Harness (DSH) itself, such as how a feature, setting, plugin, agent preset, tool, or Cordis API of the running installation works; when the user asks to design, review, build, install, enable, or debug a DSH plugin, bundle, MCP connection, agent preset, plugin icon or detail page, or a DSH tool definition or skill; and when upgrading a plugin or profile to a newer DSH release. Loading it grants no permission to change files or the profile."},{"name":"office","description":"Create, read, edit, and validate Word, PowerPoint, and Excel files; render Office files and PDFs; convert or recalculate. Load first to enable office_render, office_convert, and office_recalculate."}]},"role":"user","id":"{{message:4}}"},"surfaceOp":"append"}
diff --git a/snapshots/web/optional-string-editor/system-prompt.expected.md b/snapshots/web/optional-string-editor/system-prompt.expected.md
index 728a5ac155..9afb6a9ffa 100644
--- a/snapshots/web/optional-string-editor/system-prompt.expected.md
+++ b/snapshots/web/optional-string-editor/system-prompt.expected.md
@@ -14,6 +14,8 @@ Read an existing file before overwriting it with write and prefer edit for targe
Read a file before editing it unless you just created or edited it in this session.
+Prefer apply_patch over separate edit calls for changes across files or separated regions. Give every hunk enough surrounding context lines to match one place in the current file. The whole patch is checked first (syntax, hunk matching, missing files) and a rejected patch changes nothing; once applying starts, operations run in order, stop at the first failure, and are not rolled back, so re-read affected files before retrying when needed.
+
Use the glob tool — not shell find — to discover files by path pattern.
Use the grep tool — not shell grep or rg — to search file contents. Use read on a matched file when you need surrounding context.
@@ -55,6 +57,15 @@ declare class Image { private constructor(); readonly attachmentId: string; read
declare function inspect(...values: unknown[]): void;
interface ToolArgsMap {
+ /** Create, update, delete, or move UTF-8 text files with one patch; prefer it over multiple edit calls when a change spans several files or separated regions. */
+ apply_patch: {
+ /** Patch text: start with *** Begin Patch and end with *** End Patch. Use *** Add File: path with + lines; *** Update File: path, optionally followed by *** Move to: path, with @@ or @@ context and space-prefixed context, + added, or - removed lines; *** End of File anchors the last hunk to the file end. Use *** Delete File: path to delete. Paths are relative to the Session working directory. */
+ input: string;
+ /** The narrowest wider sandbox mode for a one-shot retry of the exact operation the sandbox just denied; the retry asks the user for approval. */
+ sandbox_permissions?: "workspace-write" | "danger-full-access";
+ /** Required with sandbox_permissions: one sentence for the user explaining why this exact file operation needs the wider access. Use the language of the user’s current request. */
+ justification?: string;
+ } & Record;
/** Ask the user a concise question when you need confirmation, a choice, or missing information before proceeding. An answer item with empty selected and no custom means the user skipped that question: continue without it, do not ask it again, and do not treat the skip as permission. */
ask_user_question: {
/** Questions to ask the user before continuing. */
@@ -356,6 +367,27 @@ interface ToolArgsMap {
}
interface ToolOutputMap {
+ apply_patch: {
+ phase: "commit";
+ cancelled: boolean;
+ operations: ({
+ index: number;
+ kind: "add" | "update" | "delete" | "move";
+ path: string;
+ destination?: string;
+ patchLine: number;
+ status: "completed" | "failed" | "unknown" | "skipped";
+ code?: string;
+ message?: string;
+ hunkLine?: number;
+ changes?: ({
+ path: string;
+ before: string | null;
+ after: string | null;
+ })[];
+ })[];
+ affectedPaths: string[];
+ };
ask_user_question: {
answers: {
id: string;
diff --git a/snapshots/web/present/session.v4.jsonl b/snapshots/web/present/session.v4.jsonl
index 54e100afa3..025cba8513 100644
--- a/snapshots/web/present/session.v4.jsonl
+++ b/snapshots/web/present/session.v4.jsonl
@@ -6,7 +6,7 @@
{"type":"turn/start","data":{"turn":1}}
{"type":"agent/inbox/spliced","data":{"target":"next-turn","start":0,"removedCount":1,"inserted":[]}}
{"type":"step/start","data":{"turn":1,"step":1}}
-{"type":"system/message","data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tools:ptc-only","order":800,"state":"active","contentIndex":2},{"name":"context:file-reference","order":900,"state":"active","contentIndex":3},{"name":"tool:bash","order":1000,"state":"active","contentIndex":4},{"name":"tool:read","order":1100,"state":"active","contentIndex":5},{"name":"tool:write","order":1200,"state":"active","contentIndex":6},{"name":"tool:edit","order":1300,"state":"active","contentIndex":7},{"name":"tool:glob","order":1400,"state":"active","contentIndex":8},{"name":"tool:grep","order":1500,"state":"active","contentIndex":9},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":10},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":11},{"name":"tool:goal","order":2400,"state":"active","contentIndex":12},{"name":"tool:schedule","order":2500,"state":"active","contentIndex":13},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":14},{"name":"tools:sdk","order":5000,"state":"active","contentIndex":15},{"name":"ui:deliverable-file-references","order":9000,"state":"active","contentIndex":16},{"name":"harness:source","order":10000,"state":"active","contentIndex":17},{"name":"app:web-surface","order":10100,"state":"active","contentIndex":18}]},"id":"{{message:2}}"}},"surfaceOp":"append"}
+{"type":"system/message","data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tools:ptc-only","order":800,"state":"active","contentIndex":2},{"name":"context:file-reference","order":900,"state":"active","contentIndex":3},{"name":"tool:bash","order":1000,"state":"active","contentIndex":4},{"name":"tool:read","order":1100,"state":"active","contentIndex":5},{"name":"tool:write","order":1200,"state":"active","contentIndex":6},{"name":"tool:edit","order":1300,"state":"active","contentIndex":7},{"name":"tool:apply_patch","order":1350,"state":"active","contentIndex":8},{"name":"tool:glob","order":1400,"state":"active","contentIndex":9},{"name":"tool:grep","order":1500,"state":"active","contentIndex":10},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":11},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":12},{"name":"tool:goal","order":2400,"state":"active","contentIndex":13},{"name":"tool:schedule","order":2500,"state":"active","contentIndex":14},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":15},{"name":"tools:sdk","order":5000,"state":"active","contentIndex":16},{"name":"ui:deliverable-file-references","order":9000,"state":"active","contentIndex":17},{"name":"harness:source","order":10000,"state":"active","contentIndex":18},{"name":"app:web-surface","order":10100,"state":"active","contentIndex":19}]},"id":"{{message:2}}"}},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"Use one run_code program to do the following in order. Call present for missing.txt and catch its error without creating that file. Use bash to run exactly `printf \"DELIVERED_REPORT\\n\" > report.txt; printf \"DELIVERED_NOTE\\n\" > 说明.txt`. Call present for report.txt and 说明.txt. After present succeeds, deliberately throw the string \"AFTER_PRESENT\" (not an Error object) from that same run_code program. Do not retry the program or create any other files. Finish by mentioning `report.txt` and `说明.txt` in inline code, and put PRESENT_DONE in a separate paragraph."}],"source":{"kind":"user","rpcId":"{{rpc:1}}","clientTimeZone":"{{clientTimeZone}}"},"role":"user","id":"{{message:1}}"},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"\nThe following information describes your current session:\n\nCurrent working directory: \"{{cwd}}\".\n\nCurrent DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}\". Some platform temporary areas may also be writable.\n\nApproval prompts are enabled in this session: operations that require approval may ask through the configured answerers; without an available answerer, the request fails closed.\n\nYou are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names.\n\nCurrent DeepSeek Harness implementation checkout: \"{{sourceRoot}}\".\n\nCurrent DeepSeek Harness Web GUI URL: \"{{webUrl}}\".\n"}],"source":{"kind":"runtime-context","form":"snapshot","sections":[{"name":"working-directory:current","text":"Current working directory: \"{{cwd}}\"."},{"name":"sandbox:policy","text":"Current DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}\". Some platform temporary areas may also be writable."},{"name":"approval:policy","text":"Approval prompts are enabled in this session: operations that require approval may ask through the configured answerers; without an available answerer, the request fails closed."},{"name":"subagent:identity","text":"You are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names."},{"name":"harness:source","text":"Current DeepSeek Harness implementation checkout: \"{{sourceRoot}}\"."},{"name":"app:web-surface","text":"Current DeepSeek Harness Web GUI URL: \"{{webUrl}}\"."}]},"role":"user","id":"{{message:3}}"},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"\nA skill is a reusable set of task-specific instructions. The following skills are available in this session:\n\n\n- `dsh-doc`: Use when a task needs facts about DeepSeek Harness (DSH) itself, such as how a feature, setting, plugin, agent preset, tool, or Cordis API of the running installation works; when the user asks to design, review, build, install, enable, or debug a DSH plugin, bundle, MCP connection, agent preset, plugin icon or detail page, or a DSH tool definition or skill; and when upgrading a plugin or profile to a newer DSH release. Loading it grants no permission to change files or the profile.\n- `office`: Create, read, edit, and validate Word, PowerPoint, and Excel files; render Office files and PDFs; convert or recalculate. Load first to enable office_render, office_convert, and office_recalculate.\n\n\nIf the user names a skill, or the task clearly matches a skill's description, call the `skill` tool with the exact skill name before taking task actions. Load all applicable skills, then follow their full instructions. This catalog contains summaries only; do not infer or follow a skill's instructions until it has been loaded.\nA user may also invoke a skill directly; its block then appears in this conversation. Follow it, and do not call the `skill` tool again for that skill.\n"}],"source":{"kind":"skill-catalog","form":"catalog","entries":[{"name":"dsh-doc","description":"Use when a task needs facts about DeepSeek Harness (DSH) itself, such as how a feature, setting, plugin, agent preset, tool, or Cordis API of the running installation works; when the user asks to design, review, build, install, enable, or debug a DSH plugin, bundle, MCP connection, agent preset, plugin icon or detail page, or a DSH tool definition or skill; and when upgrading a plugin or profile to a newer DSH release. Loading it grants no permission to change files or the profile."},{"name":"office","description":"Create, read, edit, and validate Word, PowerPoint, and Excel files; render Office files and PDFs; convert or recalculate. Load first to enable office_render, office_convert, and office_recalculate."}]},"role":"user","id":"{{message:4}}"},"surfaceOp":"append"}
diff --git a/snapshots/web/ptc-escalation-approved-scoped/session.v4.jsonl b/snapshots/web/ptc-escalation-approved-scoped/session.v4.jsonl
index 8df47b1abd..75a8743a29 100644
--- a/snapshots/web/ptc-escalation-approved-scoped/session.v4.jsonl
+++ b/snapshots/web/ptc-escalation-approved-scoped/session.v4.jsonl
@@ -10,7 +10,7 @@
{"type":"turn/start","data":{"turn":1}}
{"type":"agent/inbox/spliced","data":{"target":"next-turn","start":0,"removedCount":1,"inserted":[]}}
{"type":"step/start","data":{"turn":1,"step":1}}
-{"type":"system/message","data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tools:ptc-only","order":800,"state":"active","contentIndex":2},{"name":"context:file-reference","order":900,"state":"active","contentIndex":3},{"name":"tool:bash","order":1000,"state":"active","contentIndex":4},{"name":"tool:read","order":1100,"state":"active","contentIndex":5},{"name":"tool:write","order":1200,"state":"active","contentIndex":6},{"name":"tool:edit","order":1300,"state":"active","contentIndex":7},{"name":"tool:glob","order":1400,"state":"active","contentIndex":8},{"name":"tool:grep","order":1500,"state":"active","contentIndex":9},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":10},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":11},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":12},{"name":"tool:goal","order":2400,"state":"active","contentIndex":13},{"name":"tool:schedule","order":2500,"state":"active","contentIndex":14},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":15},{"name":"tools:sdk","order":5000,"state":"active","contentIndex":16},{"name":"ui:deliverable-file-references","order":9000,"state":"active","contentIndex":17},{"name":"harness:source","order":10000,"state":"active","contentIndex":18},{"name":"app:web-surface","order":10100,"state":"active","contentIndex":19}]},"id":"{{message:2}}"}},"surfaceOp":"append"}
+{"type":"system/message","data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tools:ptc-only","order":800,"state":"active","contentIndex":2},{"name":"context:file-reference","order":900,"state":"active","contentIndex":3},{"name":"tool:bash","order":1000,"state":"active","contentIndex":4},{"name":"tool:read","order":1100,"state":"active","contentIndex":5},{"name":"tool:write","order":1200,"state":"active","contentIndex":6},{"name":"tool:edit","order":1300,"state":"active","contentIndex":7},{"name":"tool:apply_patch","order":1350,"state":"active","contentIndex":8},{"name":"tool:glob","order":1400,"state":"active","contentIndex":9},{"name":"tool:grep","order":1500,"state":"active","contentIndex":10},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":11},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":12},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":13},{"name":"tool:goal","order":2400,"state":"active","contentIndex":14},{"name":"tool:schedule","order":2500,"state":"active","contentIndex":15},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":16},{"name":"tools:sdk","order":5000,"state":"active","contentIndex":17},{"name":"ui:deliverable-file-references","order":9000,"state":"active","contentIndex":18},{"name":"harness:source","order":10000,"state":"active","contentIndex":19},{"name":"app:web-surface","order":10100,"state":"active","contentIndex":20}]},"id":"{{message:2}}"}},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"Use run_code with timeoutMs 120000 and direct Node filesystem access to create approved.txt in the working directory containing exactly \"approved\\n\". Use await import(\"node:fs/promises\") and writeFile; do not call nested tools. First attempt the write under the current read-only sandbox without escalation. In that first program, catch only filesystem errors with code EPERM, EACCES or EROFS and use `inspect(...)` to display exactly \"EXPECTED_SANDBOX_DENIAL\"; rethrow any other error. If the sandbox denies it, explicitly retry the program with sandbox_permissions \"workspace-write\" and justification \"Create the file requested by the user\". I will answer the approval prompt. In the approved retry, also declare `const escalationMarker = \"ESCALATED\"`. After the file is written, run one more run_code program without escalation that uses `inspect(...)` to display `{ escalationMarker: typeof escalationMarker, fs: typeof fs }`. Then reply DONE and stop."}],"source":{"kind":"user","rpcId":"{{rpc:1}}","clientTimeZone":"{{clientTimeZone}}"},"role":"user","id":"{{message:1}}"},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"\nThe following information describes your current session:\n\nCurrent working directory: \"{{cwd}}\".\n\nCurrent DSH file policy: read-only. Any available operation enforced by the DSH file sandbox cannot modify files in the standing mode. Do not refuse a required modification from this policy alone: try an available tool normally and follow any denial and escalation guidance it returns.\n\nApproval prompts are enabled in this session: operations that require approval may ask through the configured answerers; without an available answerer, the request fails closed.\n\nYou are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names.\n\nCurrent DeepSeek Harness implementation checkout: \"{{sourceRoot}}\".\n\nCurrent DeepSeek Harness Web GUI URL: \"{{webUrl}}\".\n"}],"source":{"kind":"runtime-context","form":"snapshot","sections":[{"name":"working-directory:current","text":"Current working directory: \"{{cwd}}\"."},{"name":"sandbox:policy","text":"Current DSH file policy: read-only. Any available operation enforced by the DSH file sandbox cannot modify files in the standing mode. Do not refuse a required modification from this policy alone: try an available tool normally and follow any denial and escalation guidance it returns."},{"name":"approval:policy","text":"Approval prompts are enabled in this session: operations that require approval may ask through the configured answerers; without an available answerer, the request fails closed."},{"name":"subagent:identity","text":"You are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names."},{"name":"harness:source","text":"Current DeepSeek Harness implementation checkout: \"{{sourceRoot}}\"."},{"name":"app:web-surface","text":"Current DeepSeek Harness Web GUI URL: \"{{webUrl}}\"."}]},"role":"user","id":"{{message:3}}"},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"\nA skill is a reusable set of task-specific instructions. The following skills are available in this session:\n\n\n- `dsh-doc`: Use when a task needs facts about DeepSeek Harness (DSH) itself, such as how a feature, setting, plugin, agent preset, tool, or Cordis API of the running installation works; when the user asks to design, review, build, install, enable, or debug a DSH plugin, bundle, MCP connection, agent preset, plugin icon or detail page, or a DSH tool definition or skill; and when upgrading a plugin or profile to a newer DSH release. Loading it grants no permission to change files or the profile.\n- `office`: Create, read, edit, and validate Word, PowerPoint, and Excel files; render Office files and PDFs; convert or recalculate. Load first to enable office_render, office_convert, and office_recalculate.\n\n\nIf the user names a skill, or the task clearly matches a skill's description, call the `skill` tool with the exact skill name before taking task actions. Load all applicable skills, then follow their full instructions. This catalog contains summaries only; do not infer or follow a skill's instructions until it has been loaded.\nA user may also invoke a skill directly; its block then appears in this conversation. Follow it, and do not call the `skill` tool again for that skill.\n"}],"source":{"kind":"skill-catalog","form":"catalog","entries":[{"name":"dsh-doc","description":"Use when a task needs facts about DeepSeek Harness (DSH) itself, such as how a feature, setting, plugin, agent preset, tool, or Cordis API of the running installation works; when the user asks to design, review, build, install, enable, or debug a DSH plugin, bundle, MCP connection, agent preset, plugin icon or detail page, or a DSH tool definition or skill; and when upgrading a plugin or profile to a newer DSH release. Loading it grants no permission to change files or the profile."},{"name":"office","description":"Create, read, edit, and validate Word, PowerPoint, and Excel files; render Office files and PDFs; convert or recalculate. Load first to enable office_render, office_convert, and office_recalculate."}]},"role":"user","id":"{{message:4}}"},"surfaceOp":"append"}
diff --git a/snapshots/web/ptc-escalation-approved/session.v4.jsonl b/snapshots/web/ptc-escalation-approved/session.v4.jsonl
index 6d0e830d25..d6c80fac51 100644
--- a/snapshots/web/ptc-escalation-approved/session.v4.jsonl
+++ b/snapshots/web/ptc-escalation-approved/session.v4.jsonl
@@ -10,7 +10,7 @@
{"type":"turn/start","data":{"turn":1}}
{"type":"agent/inbox/spliced","data":{"target":"next-turn","start":0,"removedCount":1,"inserted":[]}}
{"type":"step/start","data":{"turn":1,"step":1}}
-{"type":"system/message","data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tools:ptc-only","order":800,"state":"active","contentIndex":2},{"name":"context:file-reference","order":900,"state":"active","contentIndex":3},{"name":"tool:bash","order":1000,"state":"active","contentIndex":4},{"name":"tool:read","order":1100,"state":"active","contentIndex":5},{"name":"tool:write","order":1200,"state":"active","contentIndex":6},{"name":"tool:edit","order":1300,"state":"active","contentIndex":7},{"name":"tool:glob","order":1400,"state":"active","contentIndex":8},{"name":"tool:grep","order":1500,"state":"active","contentIndex":9},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":10},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":11},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":12},{"name":"tool:goal","order":2400,"state":"active","contentIndex":13},{"name":"tool:schedule","order":2500,"state":"active","contentIndex":14},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":15},{"name":"tools:sdk","order":5000,"state":"active","contentIndex":16},{"name":"ui:deliverable-file-references","order":9000,"state":"active","contentIndex":17},{"name":"harness:source","order":10000,"state":"active","contentIndex":18},{"name":"app:web-surface","order":10100,"state":"active","contentIndex":19}]},"id":"{{message:2}}"}},"surfaceOp":"append"}
+{"type":"system/message","data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tools:ptc-only","order":800,"state":"active","contentIndex":2},{"name":"context:file-reference","order":900,"state":"active","contentIndex":3},{"name":"tool:bash","order":1000,"state":"active","contentIndex":4},{"name":"tool:read","order":1100,"state":"active","contentIndex":5},{"name":"tool:write","order":1200,"state":"active","contentIndex":6},{"name":"tool:edit","order":1300,"state":"active","contentIndex":7},{"name":"tool:apply_patch","order":1350,"state":"active","contentIndex":8},{"name":"tool:glob","order":1400,"state":"active","contentIndex":9},{"name":"tool:grep","order":1500,"state":"active","contentIndex":10},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":11},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":12},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":13},{"name":"tool:goal","order":2400,"state":"active","contentIndex":14},{"name":"tool:schedule","order":2500,"state":"active","contentIndex":15},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":16},{"name":"tools:sdk","order":5000,"state":"active","contentIndex":17},{"name":"ui:deliverable-file-references","order":9000,"state":"active","contentIndex":18},{"name":"harness:source","order":10000,"state":"active","contentIndex":19},{"name":"app:web-surface","order":10100,"state":"active","contentIndex":20}]},"id":"{{message:2}}"}},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"Use run_code with timeoutMs 120000 and direct Node filesystem access to create approved.txt in the working directory containing exactly \"approved\\n\". Use await import(\"node:fs/promises\") and writeFile; do not call nested tools. First attempt the write under the current read-only sandbox without escalation. In that first program, catch only filesystem errors with code EPERM, EACCES or EROFS and use `inspect(...)` to display exactly \"EXPECTED_SANDBOX_DENIAL\"; rethrow any other error. If the sandbox denies it, explicitly retry the program with sandbox_permissions \"workspace-write\" and justification \"Create the file requested by the user\". I will answer the approval prompt. After the file is written, reply DONE and stop."}],"source":{"kind":"user","rpcId":"{{rpc:1}}","clientTimeZone":"{{clientTimeZone}}"},"role":"user","id":"{{message:1}}"},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"\nThe following information describes your current session:\n\nCurrent working directory: \"{{cwd}}\".\n\nCurrent DSH file policy: read-only. Any available operation enforced by the DSH file sandbox cannot modify files in the standing mode. Do not refuse a required modification from this policy alone: try an available tool normally and follow any denial and escalation guidance it returns.\n\nApproval prompts are enabled in this session: operations that require approval may ask through the configured answerers; without an available answerer, the request fails closed.\n\nYou are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names.\n\nCurrent DeepSeek Harness implementation checkout: \"{{sourceRoot}}\".\n\nCurrent DeepSeek Harness Web GUI URL: \"{{webUrl}}\".\n"}],"source":{"kind":"runtime-context","form":"snapshot","sections":[{"name":"working-directory:current","text":"Current working directory: \"{{cwd}}\"."},{"name":"sandbox:policy","text":"Current DSH file policy: read-only. Any available operation enforced by the DSH file sandbox cannot modify files in the standing mode. Do not refuse a required modification from this policy alone: try an available tool normally and follow any denial and escalation guidance it returns."},{"name":"approval:policy","text":"Approval prompts are enabled in this session: operations that require approval may ask through the configured answerers; without an available answerer, the request fails closed."},{"name":"subagent:identity","text":"You are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names."},{"name":"harness:source","text":"Current DeepSeek Harness implementation checkout: \"{{sourceRoot}}\"."},{"name":"app:web-surface","text":"Current DeepSeek Harness Web GUI URL: \"{{webUrl}}\"."}]},"role":"user","id":"{{message:3}}"},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"\nA skill is a reusable set of task-specific instructions. The following skills are available in this session:\n\n\n- `dsh-doc`: Use when a task needs facts about DeepSeek Harness (DSH) itself, such as how a feature, setting, plugin, agent preset, tool, or Cordis API of the running installation works; when the user asks to design, review, build, install, enable, or debug a DSH plugin, bundle, MCP connection, agent preset, plugin icon or detail page, or a DSH tool definition or skill; and when upgrading a plugin or profile to a newer DSH release. Loading it grants no permission to change files or the profile.\n- `office`: Create, read, edit, and validate Word, PowerPoint, and Excel files; render Office files and PDFs; convert or recalculate. Load first to enable office_render, office_convert, and office_recalculate.\n\n\nIf the user names a skill, or the task clearly matches a skill's description, call the `skill` tool with the exact skill name before taking task actions. Load all applicable skills, then follow their full instructions. This catalog contains summaries only; do not infer or follow a skill's instructions until it has been loaded.\nA user may also invoke a skill directly; its block then appears in this conversation. Follow it, and do not call the `skill` tool again for that skill.\n"}],"source":{"kind":"skill-catalog","form":"catalog","entries":[{"name":"dsh-doc","description":"Use when a task needs facts about DeepSeek Harness (DSH) itself, such as how a feature, setting, plugin, agent preset, tool, or Cordis API of the running installation works; when the user asks to design, review, build, install, enable, or debug a DSH plugin, bundle, MCP connection, agent preset, plugin icon or detail page, or a DSH tool definition or skill; and when upgrading a plugin or profile to a newer DSH release. Loading it grants no permission to change files or the profile."},{"name":"office","description":"Create, read, edit, and validate Word, PowerPoint, and Excel files; render Office files and PDFs; convert or recalculate. Load first to enable office_render, office_convert, and office_recalculate."}]},"role":"user","id":"{{message:4}}"},"surfaceOp":"append"}
diff --git a/snapshots/web/ptc-round-scoped/session.v4.jsonl b/snapshots/web/ptc-round-scoped/session.v4.jsonl
index 660dcc4568..f0809a3806 100644
--- a/snapshots/web/ptc-round-scoped/session.v4.jsonl
+++ b/snapshots/web/ptc-round-scoped/session.v4.jsonl
@@ -6,7 +6,7 @@
{"type":"turn/start","data":{"turn":1}}
{"type":"agent/inbox/spliced","data":{"target":"next-turn","start":0,"removedCount":1,"inserted":[]}}
{"type":"step/start","data":{"turn":1,"step":1}}
-{"type":"system/message","data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tools:ptc-only","order":800,"state":"active","contentIndex":2},{"name":"context:file-reference","order":900,"state":"active","contentIndex":3},{"name":"tool:bash","order":1000,"state":"active","contentIndex":4},{"name":"tool:read","order":1100,"state":"active","contentIndex":5},{"name":"tool:write","order":1200,"state":"active","contentIndex":6},{"name":"tool:edit","order":1300,"state":"active","contentIndex":7},{"name":"tool:glob","order":1400,"state":"active","contentIndex":8},{"name":"tool:grep","order":1500,"state":"active","contentIndex":9},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":10},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":11},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":12},{"name":"tool:goal","order":2400,"state":"active","contentIndex":13},{"name":"tool:schedule","order":2500,"state":"active","contentIndex":14},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":15},{"name":"tools:sdk","order":5000,"state":"active","contentIndex":16},{"name":"ui:deliverable-file-references","order":9000,"state":"active","contentIndex":17},{"name":"harness:source","order":10000,"state":"active","contentIndex":18},{"name":"app:web-surface","order":10100,"state":"active","contentIndex":19}]},"id":"{{message:2}}"}},"surfaceOp":"append"}
+{"type":"system/message","data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tools:ptc-only","order":800,"state":"active","contentIndex":2},{"name":"context:file-reference","order":900,"state":"active","contentIndex":3},{"name":"tool:bash","order":1000,"state":"active","contentIndex":4},{"name":"tool:read","order":1100,"state":"active","contentIndex":5},{"name":"tool:write","order":1200,"state":"active","contentIndex":6},{"name":"tool:edit","order":1300,"state":"active","contentIndex":7},{"name":"tool:apply_patch","order":1350,"state":"active","contentIndex":8},{"name":"tool:glob","order":1400,"state":"active","contentIndex":9},{"name":"tool:grep","order":1500,"state":"active","contentIndex":10},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":11},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":12},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":13},{"name":"tool:goal","order":2400,"state":"active","contentIndex":14},{"name":"tool:schedule","order":2500,"state":"active","contentIndex":15},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":16},{"name":"tools:sdk","order":5000,"state":"active","contentIndex":17},{"name":"ui:deliverable-file-references","order":9000,"state":"active","contentIndex":18},{"name":"harness:source","order":10000,"state":"active","contentIndex":19},{"name":"app:web-surface","order":10100,"state":"active","contentIndex":20}]},"id":"{{message:2}}"}},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"Using ONE run_code program: run bash `echo CODE_ROUND_OK`, then read the file missing.txt catching its error in the program. Use `inspect(...)` to display an object with both outcomes. Then reply DONE and stop."}],"source":{"kind":"user","rpcId":"{{rpc:1}}","clientTimeZone":"{{clientTimeZone}}"},"role":"user","id":"{{message:1}}"},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"\nThe following information describes your current session:\n\nCurrent working directory: \"{{cwd}}\".\n\nCurrent DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}\". Some platform temporary areas may also be writable.\n\nApproval prompts are enabled in this session: operations that require approval may ask through the configured answerers; without an available answerer, the request fails closed.\n\nYou are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names.\n\nCurrent DeepSeek Harness implementation checkout: \"{{sourceRoot}}\".\n\nCurrent DeepSeek Harness Web GUI URL: \"{{webUrl}}\".\n"}],"source":{"kind":"runtime-context","form":"snapshot","sections":[{"name":"working-directory:current","text":"Current working directory: \"{{cwd}}\"."},{"name":"sandbox:policy","text":"Current DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}\". Some platform temporary areas may also be writable."},{"name":"approval:policy","text":"Approval prompts are enabled in this session: operations that require approval may ask through the configured answerers; without an available answerer, the request fails closed."},{"name":"subagent:identity","text":"You are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names."},{"name":"harness:source","text":"Current DeepSeek Harness implementation checkout: \"{{sourceRoot}}\"."},{"name":"app:web-surface","text":"Current DeepSeek Harness Web GUI URL: \"{{webUrl}}\"."}]},"role":"user","id":"{{message:3}}"},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"\nA skill is a reusable set of task-specific instructions. The following skills are available in this session:\n\n\n- `dsh-doc`: Use when a task needs facts about DeepSeek Harness (DSH) itself, such as how a feature, setting, plugin, agent preset, tool, or Cordis API of the running installation works; when the user asks to design, review, build, install, enable, or debug a DSH plugin, bundle, MCP connection, agent preset, plugin icon or detail page, or a DSH tool definition or skill; and when upgrading a plugin or profile to a newer DSH release. Loading it grants no permission to change files or the profile.\n- `office`: Create, read, edit, and validate Word, PowerPoint, and Excel files; render Office files and PDFs; convert or recalculate. Load first to enable office_render, office_convert, and office_recalculate.\n\n\nIf the user names a skill, or the task clearly matches a skill's description, call the `skill` tool with the exact skill name before taking task actions. Load all applicable skills, then follow their full instructions. This catalog contains summaries only; do not infer or follow a skill's instructions until it has been loaded.\nA user may also invoke a skill directly; its block then appears in this conversation. Follow it, and do not call the `skill` tool again for that skill.\n"}],"source":{"kind":"skill-catalog","form":"catalog","entries":[{"name":"dsh-doc","description":"Use when a task needs facts about DeepSeek Harness (DSH) itself, such as how a feature, setting, plugin, agent preset, tool, or Cordis API of the running installation works; when the user asks to design, review, build, install, enable, or debug a DSH plugin, bundle, MCP connection, agent preset, plugin icon or detail page, or a DSH tool definition or skill; and when upgrading a plugin or profile to a newer DSH release. Loading it grants no permission to change files or the profile."},{"name":"office","description":"Create, read, edit, and validate Word, PowerPoint, and Excel files; render Office files and PDFs; convert or recalculate. Load first to enable office_render, office_convert, and office_recalculate."}]},"role":"user","id":"{{message:4}}"},"surfaceOp":"append"}
diff --git a/snapshots/web/ptc-round-scoped/system-prompt.expected.md b/snapshots/web/ptc-round-scoped/system-prompt.expected.md
index 0240fc97ca..0496b0c2c0 100644
--- a/snapshots/web/ptc-round-scoped/system-prompt.expected.md
+++ b/snapshots/web/ptc-round-scoped/system-prompt.expected.md
@@ -14,6 +14,8 @@ Read an existing file before overwriting it with write and prefer edit for targe
Read a file before editing it unless you just created or edited it in this session.
+Prefer apply_patch over separate edit calls for changes across files or separated regions. Give every hunk enough surrounding context lines to match one place in the current file. The whole patch is checked first (syntax, hunk matching, missing files) and a rejected patch changes nothing; once applying starts, operations run in order, stop at the first failure, and are not rolled back, so re-read affected files before retrying when needed.
+
Use the glob tool — not shell find — to discover files by path pattern.
Use the grep tool — not shell grep or rg — to search file contents. Use read on a matched file when you need surrounding context.
@@ -55,6 +57,15 @@ declare class Image { private constructor(); readonly attachmentId: string; read
declare function inspect(...values: unknown[]): void;
interface ToolArgsMap {
+ /** Create, update, delete, or move UTF-8 text files with one patch; prefer it over multiple edit calls when a change spans several files or separated regions. */
+ apply_patch: {
+ /** Patch text: start with *** Begin Patch and end with *** End Patch. Use *** Add File: path with + lines; *** Update File: path, optionally followed by *** Move to: path, with @@ or @@ context and space-prefixed context, + added, or - removed lines; *** End of File anchors the last hunk to the file end. Use *** Delete File: path to delete. Paths are relative to the Session working directory. */
+ input: string;
+ /** The narrowest wider sandbox mode for a one-shot retry of the exact operation the sandbox just denied; the retry asks the user for approval. */
+ sandbox_permissions?: "workspace-write" | "danger-full-access";
+ /** Required with sandbox_permissions: one sentence for the user explaining why this exact file operation needs the wider access. Use the language of the user’s current request. */
+ justification?: string;
+ } & Record;
/** Ask the user a concise question when you need confirmation, a choice, or missing information before proceeding. An answer item with empty selected and no custom means the user skipped that question: continue without it, do not ask it again, and do not treat the skip as permission. */
ask_user_question: {
/** Questions to ask the user before continuing. */
@@ -339,6 +350,27 @@ interface ToolArgsMap {
}
interface ToolOutputMap {
+ apply_patch: {
+ phase: "commit";
+ cancelled: boolean;
+ operations: ({
+ index: number;
+ kind: "add" | "update" | "delete" | "move";
+ path: string;
+ destination?: string;
+ patchLine: number;
+ status: "completed" | "failed" | "unknown" | "skipped";
+ code?: string;
+ message?: string;
+ hunkLine?: number;
+ changes?: ({
+ path: string;
+ before: string | null;
+ after: string | null;
+ })[];
+ })[];
+ affectedPaths: string[];
+ };
ask_user_question: {
answers: {
id: string;
diff --git a/snapshots/web/ptc-round/session.v4.jsonl b/snapshots/web/ptc-round/session.v4.jsonl
index 9db6b47a13..4748af0ea3 100644
--- a/snapshots/web/ptc-round/session.v4.jsonl
+++ b/snapshots/web/ptc-round/session.v4.jsonl
@@ -6,7 +6,7 @@
{"type":"turn/start","data":{"turn":1}}
{"type":"agent/inbox/spliced","data":{"target":"next-turn","start":0,"removedCount":1,"inserted":[]}}
{"type":"step/start","data":{"turn":1,"step":1}}
-{"type":"system/message","data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tools:ptc-only","order":800,"state":"active","contentIndex":2},{"name":"context:file-reference","order":900,"state":"active","contentIndex":3},{"name":"tool:bash","order":1000,"state":"active","contentIndex":4},{"name":"tool:read","order":1100,"state":"active","contentIndex":5},{"name":"tool:write","order":1200,"state":"active","contentIndex":6},{"name":"tool:edit","order":1300,"state":"active","contentIndex":7},{"name":"tool:glob","order":1400,"state":"active","contentIndex":8},{"name":"tool:grep","order":1500,"state":"active","contentIndex":9},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":10},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":11},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":12},{"name":"tool:goal","order":2400,"state":"active","contentIndex":13},{"name":"tool:schedule","order":2500,"state":"active","contentIndex":14},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":15},{"name":"tools:sdk","order":5000,"state":"active","contentIndex":16},{"name":"ui:deliverable-file-references","order":9000,"state":"active","contentIndex":17},{"name":"harness:source","order":10000,"state":"active","contentIndex":18},{"name":"app:web-surface","order":10100,"state":"active","contentIndex":19}]},"id":"{{message:2}}"}},"surfaceOp":"append"}
+{"type":"system/message","data":{"turn":1,"step":1,"message":{"role":"system","content":[{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"},{"type":"text","text":"{{system}}"}],"source":{"kind":"system-prompt","sections":[{"name":"harness:identity","order":-1000,"state":"active","contentIndex":0},{"name":"deployment:persona-prefix","order":0,"state":"active","contentIndex":1},{"name":"tools:ptc-only","order":800,"state":"active","contentIndex":2},{"name":"context:file-reference","order":900,"state":"active","contentIndex":3},{"name":"tool:bash","order":1000,"state":"active","contentIndex":4},{"name":"tool:read","order":1100,"state":"active","contentIndex":5},{"name":"tool:write","order":1200,"state":"active","contentIndex":6},{"name":"tool:edit","order":1300,"state":"active","contentIndex":7},{"name":"tool:apply_patch","order":1350,"state":"active","contentIndex":8},{"name":"tool:glob","order":1400,"state":"active","contentIndex":9},{"name":"tool:grep","order":1500,"state":"active","contentIndex":10},{"name":"tool:jobs","order":1600,"state":"active","contentIndex":11},{"name":"tool:web_search","order":2000,"state":"active","contentIndex":12},{"name":"tool:web_fetch","order":2100,"state":"active","contentIndex":13},{"name":"tool:goal","order":2400,"state":"active","contentIndex":14},{"name":"tool:schedule","order":2500,"state":"active","contentIndex":15},{"name":"tool:subagent","order":2800,"state":"active","contentIndex":16},{"name":"tools:sdk","order":5000,"state":"active","contentIndex":17},{"name":"ui:deliverable-file-references","order":9000,"state":"active","contentIndex":18},{"name":"harness:source","order":10000,"state":"active","contentIndex":19},{"name":"app:web-surface","order":10100,"state":"active","contentIndex":20}]},"id":"{{message:2}}"}},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"Using ONE run_code program: run bash `echo CODE_ROUND_OK`, then read the file missing.txt catching its error in the program. Use `inspect(...)` to display an object with both outcomes. Then reply DONE and stop."}],"source":{"kind":"user","rpcId":"{{rpc:1}}","clientTimeZone":"{{clientTimeZone}}"},"role":"user","id":"{{message:1}}"},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"\nThe following information describes your current session:\n\nCurrent working directory: \"{{cwd}}\".\n\nCurrent DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}\". Some platform temporary areas may also be writable.\n\nApproval prompts are enabled in this session: operations that require approval may ask through the configured answerers; without an available answerer, the request fails closed.\n\nYou are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names.\n\nCurrent DeepSeek Harness implementation checkout: \"{{sourceRoot}}\".\n\nCurrent DeepSeek Harness Web GUI URL: \"{{webUrl}}\".\n"}],"source":{"kind":"runtime-context","form":"snapshot","sections":[{"name":"working-directory:current","text":"Current working directory: \"{{cwd}}\"."},{"name":"sandbox:policy","text":"Current DSH file policy: workspace-write. Any available operation enforced by the DSH file sandbox may modify files under the session workspace: \"{{cwd}}\". Some platform temporary areas may also be writable."},{"name":"approval:policy","text":"Approval prompts are enabled in this session: operations that require approval may ask through the configured answerers; without an available answerer, the request fails closed."},{"name":"subagent:identity","text":"You are the root agent. Your name is \"lead\".\n\nTo message other agents, use send_message({ agent: \"\", message: \"...\" }).\nUse list_agents({}) to find your collaborator agents and their names."},{"name":"harness:source","text":"Current DeepSeek Harness implementation checkout: \"{{sourceRoot}}\"."},{"name":"app:web-surface","text":"Current DeepSeek Harness Web GUI URL: \"{{webUrl}}\"."}]},"role":"user","id":"{{message:3}}"},"surfaceOp":"append"}
{"type":"user/message","data":{"content":[{"type":"text","text":"\nA skill is a reusable set of task-specific instructions. The following skills are available in this session:\n\n\n- `dsh-doc`: Use when a task needs facts about DeepSeek Harness (DSH) itself, such as how a feature, setting, plugin, agent preset, tool, or Cordis API of the running installation works; when the user asks to design, review, build, install, enable, or debug a DSH plugin, bundle, MCP connection, agent preset, plugin icon or detail page, or a DSH tool definition or skill; and when upgrading a plugin or profile to a newer DSH release. Loading it grants no permission to change files or the profile.\n- `office`: Create, read, edit, and validate Word, PowerPoint, and Excel files; render Office files and PDFs; convert or recalculate. Load first to enable office_render, office_convert, and office_recalculate.\n\n\nIf the user names a skill, or the task clearly matches a skill's description, call the `skill` tool with the exact skill name before taking task actions. Load all applicable skills, then follow their full instructions. This catalog contains summaries only; do not infer or follow a skill's instructions until it has been loaded.\nA user may also invoke a skill directly; its block then appears in this conversation. Follow it, and do not call the `skill` tool again for that skill.\n"}],"source":{"kind":"skill-catalog","form":"catalog","entries":[{"name":"dsh-doc","description":"Use when a task needs facts about DeepSeek Harness (DSH) itself, such as how a feature, setting, plugin, agent preset, tool, or Cordis API of the running installation works; when the user asks to design, review, build, install, enable, or debug a DSH plugin, bundle, MCP connection, agent preset, plugin icon or detail page, or a DSH tool definition or skill; and when upgrading a plugin or profile to a newer DSH release. Loading it grants no permission to change files or the profile."},{"name":"office","description":"Create, read, edit, and validate Word, PowerPoint, and Excel files; render Office files and PDFs; convert or recalculate. Load first to enable office_render, office_convert, and office_recalculate."}]},"role":"user","id":"{{message:4}}"},"surfaceOp":"append"}
diff --git a/snapshots/web/ptc-round/system-prompt.expected.md b/snapshots/web/ptc-round/system-prompt.expected.md
index 87b28cfa92..f7a5c0ec16 100644
--- a/snapshots/web/ptc-round/system-prompt.expected.md
+++ b/snapshots/web/ptc-round/system-prompt.expected.md
@@ -14,6 +14,8 @@ Read an existing file before overwriting it with write and prefer edit for targe
Read a file before editing it unless you just created or edited it in this session.
+Prefer apply_patch over separate edit calls for changes across files or separated regions. Give every hunk enough surrounding context lines to match one place in the current file. The whole patch is checked first (syntax, hunk matching, missing files) and a rejected patch changes nothing; once applying starts, operations run in order, stop at the first failure, and are not rolled back, so re-read affected files before retrying when needed.
+
Use the glob tool — not shell find — to discover files by path pattern.
Use the grep tool — not shell grep or rg — to search file contents. Use read on a matched file when you need surrounding context.
@@ -55,6 +57,15 @@ declare class Image { private constructor(); readonly attachmentId: string; read
declare function inspect(...values: unknown[]): void;
interface ToolArgsMap {
+ /** Create, update, delete, or move UTF-8 text files with one patch; prefer it over multiple edit calls when a change spans several files or separated regions. */
+ apply_patch: {
+ /** Patch text: start with *** Begin Patch and end with *** End Patch. Use *** Add File: path with + lines; *** Update File: path, optionally followed by *** Move to: path, with @@ or @@ context and space-prefixed context, + added, or - removed lines; *** End of File anchors the last hunk to the file end. Use *** Delete File: path to delete. Paths are relative to the Session working directory. */
+ input: string;
+ /** The narrowest wider sandbox mode for a one-shot retry of the exact operation the sandbox just denied; the retry asks the user for approval. */
+ sandbox_permissions?: "workspace-write" | "danger-full-access";
+ /** Required with sandbox_permissions: one sentence for the user explaining why this exact file operation needs the wider access. Use the language of the user’s current request. */
+ justification?: string;
+ } & Record;
/** Ask the user a concise question when you need confirmation, a choice, or missing information before proceeding. An answer item with empty selected and no custom means the user skipped that question: continue without it, do not ask it again, and do not treat the skip as permission. */
ask_user_question: {
/** Questions to ask the user before continuing. */
@@ -339,6 +350,27 @@ interface ToolArgsMap {
}
interface ToolOutputMap {
+ apply_patch: {
+ phase: "commit";
+ cancelled: boolean;
+ operations: ({
+ index: number;
+ kind: "add" | "update" | "delete" | "move";
+ path: string;
+ destination?: string;
+ patchLine: number;
+ status: "completed" | "failed" | "unknown" | "skipped";
+ code?: string;
+ message?: string;
+ hunkLine?: number;
+ changes?: ({
+ path: string;
+ before: string | null;
+ after: string | null;
+ })[];
+ })[];
+ affectedPaths: string[];
+ };
ask_user_question: {
answers: {
id: string;